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
This commit is contained in:
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -1021,6 +1023,20 @@ get_driver_name (GUdevDevice *device)
|
|||||||
return ret;
|
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
|
static MMPluginSupportsResult
|
||||||
supports_port (MMPlugin *plugin,
|
supports_port (MMPlugin *plugin,
|
||||||
const char *subsys,
|
const char *subsys,
|
||||||
@@ -1053,6 +1069,9 @@ supports_port (MMPlugin *plugin,
|
|||||||
for (idx = 0; virtual_port[idx]; idx++) {
|
for (idx = 0; virtual_port[idx]; idx++) {
|
||||||
if (strcmp(name, virtual_port[idx]))
|
if (strcmp(name, virtual_port[idx]))
|
||||||
continue;
|
continue;
|
||||||
|
if (!device_file_exists(virtual_port[idx]))
|
||||||
|
continue;
|
||||||
|
|
||||||
task = supports_task_new (self, port, physdev_path, "virtual", callback, callback_data);
|
task = supports_task_new (self, port, physdev_path, "virtual", callback, callback_data);
|
||||||
g_assert (task);
|
g_assert (task);
|
||||||
g_hash_table_insert (priv->tasks, g_strdup (key), g_object_ref (task));
|
g_hash_table_insert (priv->tasks, g_strdup (key), g_object_ref (task));
|
||||||
|
Reference in New Issue
Block a user