diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-05-04 04:52:31 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-05-04 04:52:31 +0200 |
commit | cb14f4543a941ff8a22ef2725df86b3b0190a189 (patch) | |
tree | 76de627af3c20265971df6ac1619fb6f26e35171 /udev/lib | |
parent | 9379b7c16dd3b2f11d9e69c063706037ae001a0a (diff) |
handle devtmpfs nodes
UDev follows the kernel given name, and re-uses the kernel created
device node. If the kernel and spcecified udev rules disagree, the
udev specified node node is created and the kernel-created on is
deleted.
Diffstat (limited to 'udev/lib')
-rw-r--r-- | udev/lib/libudev-device.c | 17 | ||||
-rw-r--r-- | udev/lib/libudev-monitor.c | 17 | ||||
-rw-r--r-- | udev/lib/libudev-private.h | 2 |
3 files changed, 31 insertions, 5 deletions
diff --git a/udev/lib/libudev-device.c b/udev/lib/libudev-device.c index 92b2d18b83..8e29efff86 100644 --- a/udev/lib/libudev-device.c +++ b/udev/lib/libudev-device.c @@ -37,6 +37,7 @@ struct udev_device { char *action; char *devpath_old; char *physdevpath; + char *knodename; char **envp; char *monitor_buf; size_t monitor_buf_len; @@ -208,6 +209,8 @@ int udev_device_read_uevent_file(struct udev_device *udev_device) maj = strtoull(&line[6], NULL, 10); else if (strncmp(line, "MINOR=", 6) == 0) min = strtoull(&line[6], NULL, 10); + else if (strncmp(line, "DEVNAME=", 8) == 0) + udev_device_set_knodename(udev_device, &line[8]); udev_device_add_property_from_string(udev_device, line); } @@ -621,6 +624,7 @@ void udev_device_unref(struct udev_device *udev_device) free(udev_device->action); free(udev_device->driver); free(udev_device->devpath_old); + free(udev_device->knodename); free(udev_device->physdevpath); udev_list_cleanup_entries(udev_device->udev, &udev_device->sysattr_list); free(udev_device->envp); @@ -1175,6 +1179,19 @@ int udev_device_set_devpath_old(struct udev_device *udev_device, const char *dev return 0; } +const char *udev_device_get_knodename(struct udev_device *udev_device) +{ + return udev_device->knodename; +} + +int udev_device_set_knodename(struct udev_device *udev_device, const char *knodename) +{ + udev_device->knodename = strdup(knodename); + if (udev_device->knodename == NULL) + return -ENOMEM; + return 0; +} + const char *udev_device_get_physdevpath(struct udev_device *udev_device) { return udev_device->physdevpath; diff --git a/udev/lib/libudev-monitor.c b/udev/lib/libudev-monitor.c index c87ff7434f..fc904c4a7c 100644 --- a/udev/lib/libudev-monitor.c +++ b/udev/lib/libudev-monitor.c @@ -445,6 +445,7 @@ struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monito int action_set = 0; int maj = 0; int min = 0; + int is_kernel = 0; retry: if (udev_monitor == NULL) @@ -480,9 +481,12 @@ retry: info(udev_monitor->udev, "unicast netlink message ignored\n"); return NULL; } - if ((snl.nl_groups == UDEV_MONITOR_KERNEL) && (snl.nl_pid > 0)) { - info(udev_monitor->udev, "multicast kernel netlink message from pid %d ignored\n", snl.nl_pid); - return NULL; + if (snl.nl_groups == UDEV_MONITOR_KERNEL) { + if (snl.nl_pid > 0) { + info(udev_monitor->udev, "multicast kernel netlink message from pid %d ignored\n", snl.nl_pid); + return NULL; + } + is_kernel = 1; } } @@ -551,7 +555,10 @@ retry: } else if (strncmp(key, "DEVTYPE=", 8) == 0) { udev_device_set_devtype(udev_device, &key[8]); } else if (strncmp(key, "DEVNAME=", 8) == 0) { - udev_device_set_devnode(udev_device, &key[8]); + if (is_kernel) + udev_device_set_knodename(udev_device, &key[8]); + else + udev_device_set_devnode(udev_device, &key[8]); } else if (strncmp(key, "DEVLINKS=", 9) == 0) { char devlinks[UTIL_PATH_SIZE]; char *slink; @@ -586,7 +593,7 @@ retry: } else if (strncmp(key, "TIMEOUT=", 8) == 0) { udev_device_set_timeout(udev_device, strtoull(&key[8], NULL, 10)); } else if (strncmp(key, "PHYSDEV", 7) == 0) { - /* skip deprecated values */ + /* suppress deprecated values */ continue; } else { udev_device_add_property_from_string(udev_device, key); diff --git a/udev/lib/libudev-private.h b/udev/lib/libudev-private.h index b283ff4ac3..8723cd7914 100644 --- a/udev/lib/libudev-private.h +++ b/udev/lib/libudev-private.h @@ -62,6 +62,8 @@ int udev_device_set_action(struct udev_device *udev_device, const char *action); int udev_device_set_driver(struct udev_device *udev_device, const char *driver); const char *udev_device_get_devpath_old(struct udev_device *udev_device); int udev_device_set_devpath_old(struct udev_device *udev_device, const char *devpath_old); +const char *udev_device_get_knodename(struct udev_device *udev_device); +int udev_device_set_knodename(struct udev_device *udev_device, const char *knodename); const char *udev_device_get_physdevpath(struct udev_device *udev_device); int udev_device_set_physdevpath(struct udev_device *udev_device, const char *physdevpath); int udev_device_get_timeout(struct udev_device *udev_device); |