Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(744)

Unified Diff: src/mm-plugin-base.c

Issue 2118005: Don't probe virtual devices before they exist (Closed) Base URL: git://git.chromium.org/modemmanager.git
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mm-plugin-base.c
diff --git a/src/mm-plugin-base.c b/src/mm-plugin-base.c
index 8537b4d0cfc208144cf21ccb5df67a02fea704a9..255cdb1024ccccdc45932e8affd8825a39b66b74 100644
--- a/src/mm-plugin-base.c
+++ b/src/mm-plugin-base.c
@@ -18,6 +18,8 @@
#include <stdio.h>
#include <stdlib.h>
+
+#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
@@ -898,6 +900,20 @@ real_find_physical_device (MMPluginBase *plugin, GUdevDevice *child)
return physdev;
}
+static gboolean
+device_file_exists(const char *name)
+{
+ char *devfile;
+ struct stat s;
+ int result;
+
+ devfile = g_strdup_printf ("/dev/%s", name);
+ result = stat (devfile, &s);
+ g_free (devfile);
+
+ return (0 == result) ? TRUE : FALSE;
+}
+
static MMPluginSupportsResult
supports_port (MMPlugin *plugin,
const char *subsys,
@@ -930,6 +946,10 @@ supports_port (MMPlugin *plugin,
for (idx = 0; virtual_port[idx]; idx++) {
if (strcmp(name, virtual_port[idx]))
continue;
+
+ if (!device_file_exists(virtual_port[idx]))
+ continue;
+
task = supports_task_new (self, port, port, "virtual", callback, callback_data);
g_assert (task);
g_hash_table_insert (priv->tasks, g_strdup (key), g_object_ref (task));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698