chiark / gitweb /
[PATCH] switch device type to enum
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Mon, 21 Feb 2005 12:45:04 +0000 (13:45 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 06:36:13 +0000 (23:36 -0700)
namedev.c
udev.c
udev.h
udev_add.c
udev_remove.c
udev_utils.c
udevtest.c

index e317cc685b0079e9d78552ae57dd7e9967279428..146dad604b2f639096d98abb14d9e6a787f5f8b7 100644 (file)
--- a/namedev.c
+++ b/namedev.c
@@ -771,7 +771,7 @@ int namedev_name_device(struct udevice *udev, struct sysfs_class_device *class_d
                                dbg_parse("remove event should be ignored");
                        }
                        /* apply all_partitions option only at a main block device */
-                       if (dev->partitions && udev->type == 'b' && udev->kernel_number[0] == '\0') {
+                       if (dev->partitions && udev->type == BLOCK && udev->kernel_number[0] == '\0') {
                                udev->partitions = dev->partitions;
                                dbg("creation of partition nodes requested");
                        }
@@ -815,7 +815,7 @@ int namedev_name_device(struct udevice *udev, struct sysfs_class_device *class_d
                                strfieldcpy(udev->config_file, dev->config_file);
                                udev->config_line = dev->config_line;
 
-                               if (udev->type != 'n')
+                               if (udev->type != NET)
                                        dbg("name, '%s' is going to have owner='%s', group='%s', mode=%#o partitions=%i",
                                            udev->name, udev->owner, udev->group, udev->mode, udev->partitions);
 
diff --git a/udev.c b/udev.c
index 122d34c1a5397b7e85ae20ea3c027eaefac3725d..5dbade3c6f6dffb7cfb91f385944552090c459d3 100644 (file)
--- a/udev.c
+++ b/udev.c
@@ -179,7 +179,7 @@ int main(int argc, char *argv[], char *envp[])
                        dbg("udev add");
 
                        /* skip subsystems without "dev", but handle net devices */
-                       if (udev.type != 'n' && subsystem_expect_no_dev(udev.subsystem)) {
+                       if (udev.type != NET && subsystem_expect_no_dev(udev.subsystem)) {
                                dbg("don't care about '%s' devices", udev.subsystem);
                                goto hotplug;
                        }
diff --git a/udev.h b/udev.h
index 2d2ef364b6084c47d26c2f967059c45b6a38f96e..17ff4031c90dde49b00031d1529156598fb450d9 100644 (file)
--- a/udev.h
+++ b/udev.h
 
 #define DEFAULT_PARTITIONS_COUNT       15
 
+enum device_type {
+       UNKNOWN,
+       CLASS,
+       BLOCK,
+       NET,
+       PHYSDEV,
+};
+
 struct udevice {
        char devpath[DEVPATH_SIZE];
        char subsystem[SUBSYSTEM_SIZE];
index 66264f06e0771b3b85e0a05d6a7d8540719db504..eeab1ca174e2102bc419ebb77daf171502bc5092 100644 (file)
@@ -70,16 +70,12 @@ int udev_make_node(struct udevice *udev, const char *file, dev_t devt, mode_t mo
 
 create:
        switch (udev->type) {
-       case 'b':
+       case BLOCK:
                mode |= S_IFBLK;
                break;
-       case 'c':
-       case 'u':
+       case CLASS:
                mode |= S_IFCHR;
                break;
-       case 'p':
-               mode |= S_IFIFO;
-               break;
        default:
                dbg("unknown node type %c\n", udev->type);
                return -EINVAL;
@@ -277,7 +273,7 @@ int udev_add_device(struct udevice *udev, struct sysfs_class_device *class_dev)
        char *pos;
        int retval = 0;
 
-       if (udev->type == 'b' || udev->type == 'c') {
+       if (udev->type == BLOCK || udev->type == CLASS) {
                udev->devt = get_devt(class_dev);
                if (!udev->devt) {
                        dbg("no dev-file found, do nothing");
@@ -292,7 +288,7 @@ int udev_add_device(struct udevice *udev, struct sysfs_class_device *class_dev)
 
        selinux_init();
 
-       if (udev->type == 'b' || udev->type == 'c') {
+       if (udev->type == BLOCK || udev->type == CLASS) {
                retval = create_node(udev, class_dev);
                if (retval != 0)
                        goto exit;
@@ -305,7 +301,7 @@ int udev_add_device(struct udevice *udev, struct sysfs_class_device *class_dev)
                snprintf(udev->devname, NAME_SIZE, "%s/%s", udev_root, udev->name);
                udev->devname[NAME_SIZE-1] = '\0';
 
-       } else if (udev->type == 'n') {
+       } else if (udev->type == NET) {
                /* look if we want to change the name of the netif */
                if (strcmp(udev->name, udev->kernel_name) != 0) {
                        retval = rename_net_if(udev);
index 3a3db737c186bd7763f92bd8399cdfc8305e0b22..0ba6962cad660f481714d91ebb2c235a79e0b363 100644 (file)
@@ -147,7 +147,7 @@ int udev_remove_device(struct udevice *udev)
        const char *temp;
        int retval;
 
-       if (udev->type != 'b' && udev->type != 'c')
+       if (udev->type != BLOCK && udev->type != CLASS)
                return 0;
 
        retval = udev_db_get_device(udev);
index fda1f42f7e0272c8957822a8e2be107b4ba20c9d..e6580d2c0acdca0404e17b2cddb1eee19ec0ad6d 100644 (file)
@@ -47,15 +47,15 @@ void udev_init_device(struct udevice *udev, const char* devpath, const char *sub
                strfieldcpy(udev->subsystem, subsystem);
 
        if (strcmp(udev->subsystem, "block") == 0)
-               udev->type = 'b';
+               udev->type = BLOCK;
        else if (strcmp(udev->subsystem, "net") == 0)
-               udev->type = 'n';
+               udev->type = NET;
        else if (strncmp(udev->devpath, "/block/", 7) == 0)
-               udev->type = 'b';
+               udev->type = BLOCK;
        else if (strncmp(udev->devpath, "/class/net/", 11) == 0)
-               udev->type = 'n';
+               udev->type = NET;
        else if (strncmp(udev->devpath, "/class/", 7) == 0)
-               udev->type = 'c';
+               udev->type = CLASS;
 
        udev->mode = 0660;
        strcpy(udev->owner, "root");
index 4b94442608641b677e07beebf5a878dcdbf55308..4e02ac7dbc2b4f351947c1793a31d68ba405a11e 100644 (file)
@@ -94,7 +94,7 @@ int main(int argc, char *argv[], char *envp[])
        udev_init_device(&udev, devpath, subsystem);
 
        /* skip subsystems without "dev", but handle net devices */
-       if (udev.type != 'n' && subsystem_expect_no_dev(udev.subsystem)) {
+       if (udev.type != NET && subsystem_expect_no_dev(udev.subsystem)) {
                info("don't care about '%s' devices", udev.subsystem);
                return 2;
        }