diff options
author | Elly Jones <ellyjones@google.com> | 2010-12-20 12:41:03 -0500 |
---|---|---|
committer | Elly Jones <ellyjones@google.com> | 2010-12-20 12:41:03 -0500 |
commit | 48169926f47377c2a9a2201cd77294dff4876e28 (patch) | |
tree | 57e8c5f964ce1f90da8c812cfe304249ffa8f5be /src/mm-plugin-base.c | |
parent | 575ba873380af798225d732779ca581936b8adeb (diff) |
Don't probe virtual devices before they exist
Prevent ModemManager from probing virtual devices before their
associated files exist in /dev tree.
Contributed by Nasser Grainawi <nasser@codeaurora.org>
Review URL: http://codereview.chromium.org/2118005
(cherry picked from commit 617660e3572a7b79ed83f9fc0fda89b7efcb2d4d)
Conflicts:
src/mm-plugin-base.c
Change-Id: Ie5e8b98fb6b6c69e294175523ef99c934092433b
Diffstat (limited to 'src/mm-plugin-base.c')
-rw-r--r-- | src/mm-plugin-base.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mm-plugin-base.c b/src/mm-plugin-base.c index a5f53a20..5a86b977 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> @@ -1021,6 +1023,20 @@ get_driver_name (GUdevDevice *device) return ret; } +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, @@ -1053,6 +1069,9 @@ 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, physdev_path, "virtual", callback, callback_data); g_assert (task); g_hash_table_insert (priv->tasks, g_strdup (key), g_object_ref (task)); |