diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2005-02-21 13:45:04 +0100 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 23:36:13 -0700 |
commit | 5ef42682053f57fc031d420f0a2ae3e204421b8d (patch) | |
tree | 7ddd231fd445f1dfc10f2f22e1dae7b551a0ced9 | |
parent | 7e720bd4ad8257d81d273d98294ebbcc03ade9ba (diff) |
[PATCH] switch device type to enum
-rw-r--r-- | namedev.c | 4 | ||||
-rw-r--r-- | udev.c | 2 | ||||
-rw-r--r-- | udev.h | 8 | ||||
-rw-r--r-- | udev_add.c | 14 | ||||
-rw-r--r-- | udev_remove.c | 2 | ||||
-rw-r--r-- | udev_utils.c | 10 | ||||
-rw-r--r-- | udevtest.c | 2 |
7 files changed, 23 insertions, 19 deletions
@@ -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); @@ -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; } @@ -48,6 +48,14 @@ #define DEFAULT_PARTITIONS_COUNT 15 +enum device_type { + UNKNOWN, + CLASS, + BLOCK, + NET, + PHYSDEV, +}; + struct udevice { char devpath[DEVPATH_SIZE]; char subsystem[SUBSYSTEM_SIZE]; diff --git a/udev_add.c b/udev_add.c index 66264f06e0..eeab1ca174 100644 --- a/udev_add.c +++ b/udev_add.c @@ -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); diff --git a/udev_remove.c b/udev_remove.c index 3a3db737c1..0ba6962cad 100644 --- a/udev_remove.c +++ b/udev_remove.c @@ -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); diff --git a/udev_utils.c b/udev_utils.c index fda1f42f7e..e6580d2c0a 100644 --- a/udev_utils.c +++ b/udev_utils.c @@ -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"); diff --git a/udevtest.c b/udevtest.c index 4b94442608..4e02ac7dbc 100644 --- a/udevtest.c +++ b/udevtest.c @@ -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; } |