chiark / gitweb /
[PATCH] determine device type in udev_init_device()
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Mon, 21 Feb 2005 14:01:53 +0000 (15:01 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 06:36:13 +0000 (23:36 -0700)
namedev.c
udev.c
udev_utils.c

index 0463d4df0b6625dc03b4570eae8c1e71fbe96070..a365574435785b61b0ce5193aadeabbcdb6c0306 100644 (file)
--- a/namedev.c
+++ b/namedev.c
@@ -201,7 +201,6 @@ static void apply_format(struct udevice *udev, char *string, size_t maxsize,
                dbg("format=%c, string='%s', tail='%s'",c , string, tail);
                attr = get_format_attribute(&tail);
 
                dbg("format=%c, string='%s', tail='%s'",c , string, tail);
                attr = get_format_attribute(&tail);
 
-
                switch (c) {
                case 'p':
                        if (strlen(udev->devpath) == 0)
                switch (c) {
                case 'p':
                        if (strlen(udev->devpath) == 0)
diff --git a/udev.c b/udev.c
index 5dbade3c6f6dffb7cfb91f385944552090c459d3..7854bc74d0a2f4a8e7f98c3881bf4946c13de409 100644 (file)
--- a/udev.c
+++ b/udev.c
@@ -152,18 +152,15 @@ int main(int argc, char *argv[], char *envp[])
        /* older kernels passed the SUBSYSTEM only as argument */
        if (!subsystem && argc == 2)
                subsystem = argv[1];
        /* older kernels passed the SUBSYSTEM only as argument */
        if (!subsystem && argc == 2)
                subsystem = argv[1];
-       udev_init_device(&udev, devpath, subsystem);
 
        if (!action) {
                dbg("no action");
                goto hotplug;
        }
 
        if (!action) {
                dbg("no action");
                goto hotplug;
        }
-
        if (!subsystem) {
                dbg("no subsystem");
                goto hotplug;
        }
        if (!subsystem) {
                dbg("no subsystem");
                goto hotplug;
        }
-
        if (!devpath) {
                dbg("no devpath");
                goto hotplug;
        if (!devpath) {
                dbg("no devpath");
                goto hotplug;
@@ -173,7 +170,9 @@ int main(int argc, char *argv[], char *envp[])
        if (udev_log)
                setenv("UDEV_LOG", "1", 1);
 
        if (udev_log)
                setenv("UDEV_LOG", "1", 1);
 
-       if ((strncmp(devpath, "/block/", 7) == 0) || (strncmp(devpath, "/class/", 7) == 0)) {
+       udev_init_device(&udev, devpath, subsystem);
+
+       if (udev.type == BLOCK || udev.type == CLASS || udev.type == NET) {
                if (strcmp(action, "add") == 0) {
                        /* wait for sysfs and possibly add node */
                        dbg("udev add");
                if (strcmp(action, "add") == 0) {
                        /* wait for sysfs and possibly add node */
                        dbg("udev add");
@@ -221,7 +220,7 @@ int main(int argc, char *argv[], char *envp[])
                        if (udev_dev_d)
                                udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX);
                }
                        if (udev_dev_d)
                                udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX);
                }
-       } else if ((strncmp(devpath, "/devices/", 9) == 0)) {
+       } else if (udev.type == PHYSDEV) {
                if (strcmp(action, "add") == 0) {
                        /* wait for sysfs */
                        dbg("devices add");
                if (strcmp(action, "add") == 0) {
                        /* wait for sysfs */
                        dbg("devices add");
index ea4aa25c90310a3e49d4d1d16b10e053bbce200c..c1e497626ee4283940d1aefbe62d4b054258a1de 100644 (file)
@@ -60,6 +60,8 @@ int udev_init_device(struct udevice *udev, const char* devpath, const char *subs
                udev->type = NET;
        else if (strncmp(udev->devpath, "/class/", 7) == 0)
                udev->type = CLASS;
                udev->type = NET;
        else if (strncmp(udev->devpath, "/class/", 7) == 0)
                udev->type = CLASS;
+       else if (strncmp(udev->devpath, "/devices/", 9) == 0)
+               udev->type = PHYSDEV;
 
        udev->mode = 0660;
        strcpy(udev->owner, "root");
 
        udev->mode = 0660;
        strcpy(udev->owner, "root");
@@ -293,8 +295,7 @@ static int name_list_add(struct list_head *name_list, const char *name, int sort
 }
 
 /* calls function for every file found in specified directory */
 }
 
 /* calls function for every file found in specified directory */
-int call_foreach_file(file_fnct_t fnct, const char *dirname,
-                     const char *suffix, void *data)
+int call_foreach_file(file_fnct_t fnct, const char *dirname, const char *suffix, void *data)
 {
        struct dirent *ent;
        DIR *dir;
 {
        struct dirent *ent;
        DIR *dir;