diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-08-19 20:49:49 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-08-19 20:49:49 +0200 |
commit | 2ffc9cc1917b1bb6fe86881a94a47dce9aa15168 (patch) | |
tree | 842ba77f43018179ce42e5433ce1c6cd63559c60 /libudev/libudev-device-private.c | |
parent | 24d1fea8bd609f9eb7901efd7cba7f2dee05f557 (diff) |
change database file names
With very deeply nested devices, We can not use a single file
name to carry an entire DEVPATH. Use <subsystem>:<sysname> as
the database filename, which should also simplify the handling
of devices moving around, as these values will not change but
still be unique.
For the name stack we use the <maj>:<min> now as the filename.
> On Tue, Aug 18, 2009 at 09:59:56AM -0400, Ric Wheeler wrote:
> The first is that udev grumbles during boot about "file name too long"
> like the following:
>
> Aug 17 06:49:58 megadeth udevd-event[20447]: unable to create db file
> '/dev/.udev/db/\x2fdevices\x2fpci0000:00\x2f0000:00:04.0\x2f0000:17:00.0\x2f0000:18:0a.0\x2f0000:1f:00.0\x2fhost11\x2fport-11:0\x2fexpander-11:0\x2fport-11:0:0\x2fexpander-11:1\x2fport-11:1:0\x2fexpander-11:2\x2fport-11:2:17\x2fexpander-11:3\x2fport-11:3:1\x2fend_device-11:3:1\x2fbsg\x2fend_device-11:3:1':
> File name too long
Diffstat (limited to 'libudev/libudev-device-private.c')
-rw-r--r-- | libudev/libudev-device-private.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/libudev/libudev-device-private.c b/libudev/libudev-device-private.c index 68dc0a5b98..80a4da4c96 100644 --- a/libudev/libudev-device-private.c +++ b/libudev/libudev-device-private.c @@ -21,16 +21,6 @@ #include "libudev.h" #include "libudev-private.h" -static size_t devpath_to_db_path(struct udev *udev, const char *devpath, char *filename, size_t len) -{ - char *s; - size_t l; - - s = filename; - l = util_strpcpyl(&s, len, udev_get_dev_path(udev), "/.udev/db/", NULL); - return util_path_encode(devpath, s, l); -} - int udev_device_update_db(struct udev_device *udev_device) { struct udev *udev = udev_device_get_udev(udev_device); @@ -43,8 +33,8 @@ int udev_device_update_db(struct udev_device *udev_device) struct udev_list_entry *list_entry; int ret; - devpath_to_db_path(udev, udev_device_get_devpath(udev_device), filename, sizeof(filename)); - util_create_path(udev, filename); + util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.udev/db/", + udev_device_get_subsystem(udev_device), ":", udev_device_get_sysname(udev_device), NULL); unlink(filename); udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device)) @@ -78,11 +68,13 @@ int udev_device_update_db(struct udev_device *udev_device) } info(udev, "create db link (%s)\n", target); udev_selinux_setfscreatecon(udev, filename, S_IFLNK); + util_create_path(udev, filename); ret = symlink(target, filename); udev_selinux_resetfscreatecon(udev); if (ret == 0) goto out; file: + util_create_path(udev, filename); f = fopen(filename, "w"); if (f == NULL) { err(udev, "unable to create db file '%s': %m\n", filename); @@ -122,18 +114,21 @@ int udev_device_delete_db(struct udev_device *udev_device) struct udev *udev = udev_device_get_udev(udev_device); char filename[UTIL_PATH_SIZE]; - devpath_to_db_path(udev, udev_device_get_devpath(udev_device), filename, sizeof(filename)); + util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.udev/db/", + udev_device_get_subsystem(udev_device), ":", udev_device_get_sysname(udev_device), NULL); unlink(filename); return 0; } -int udev_device_rename_db(struct udev_device *udev_device, const char *devpath_old) +int udev_device_rename_db(struct udev_device *udev_device) { struct udev *udev = udev_device_get_udev(udev_device); char filename_old[UTIL_PATH_SIZE]; char filename[UTIL_PATH_SIZE]; - devpath_to_db_path(udev, devpath_old, filename_old, sizeof(filename_old)); - devpath_to_db_path(udev, udev_device_get_devpath(udev_device), filename, sizeof(filename)); + util_strscpyl(filename_old, sizeof(filename_old), udev_get_dev_path(udev), "/.udev/db/", + udev_device_get_subsystem(udev_device), ":", udev_device_get_sysname_old(udev_device), NULL); + util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.udev/db/", + udev_device_get_subsystem(udev_device), ":", udev_device_get_sysname(udev_device), NULL); return rename(filename_old, filename); } |