diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-03-18 12:51:57 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2007-03-18 12:51:57 +0100 |
commit | 24f0605c1fec98b77eddb880a405289b08cb5670 (patch) | |
tree | 9278532852e3c6d13234da786baca185549aca0f /udev_db.c | |
parent | 31de3a2ba18ffa011f5054016ccc4a500cbe0cc3 (diff) |
priority based symlink handling
Symlinks can have priorities now, the priority is assigned to the device
and specified with OPTIONS="link_priority=100". Devices with higher
priorities overwrite the symlinks of devices with lower priorities.
If the device, that currently owns the link goes away, the symlink
will be removed, and recreated, pointing to the next device with the
highest actual priority.
This should solve the issue, that inserting an USB-stick may overwrite the
/dev/disk/by-id/-link of another disk, and removes the entire link after the
USB-stick is disconnected. If no priorities are specified, the new link will
overwrite the current one, and if the device goes away, it will restore
the old link. It should be possible to assign lower priorities to removable
devices, if needed.
In multipath setups, we see several devices, which all connect to the same
volume, and therefore all try to create the same metadata-links. The
different path-devices are combined into one device-mapper device, which also
contains the same metadata. It should be possible, to assign multipath-table
device-mapper devices a higher priority, so path-devices that appear and
disappear, will not overwrite or delete the device-mapper device links.
Diffstat (limited to 'udev_db.c')
-rw-r--r-- | udev_db.c | 62 |
1 files changed, 0 insertions, 62 deletions
@@ -296,68 +296,6 @@ int udev_db_delete_device(struct udevice *udev) return 0; } -int udev_db_lookup_name(const char *name, char *devpath, size_t len) -{ - char dirname[PATH_MAX]; - size_t start; - DIR *dir; - int found = 0; - - strlcpy(dirname, udev_root, sizeof(dirname)); - start = strlcat(dirname, "/"DB_NAME_INDEX_DIR"/", sizeof(dirname)); - strlcat(dirname, name, sizeof(dirname)); - path_encode(&dirname[start], sizeof(dirname) - start); - - dir = opendir(dirname); - if (dir == NULL) { - info("no index directory '%s': %s", dirname, strerror(errno)); - return -1; - } - - info("found index directory '%s'", dirname); - while (!found) { - struct dirent *ent; - char device[PATH_SIZE]; - struct udevice *udev; - - ent = readdir(dir); - if (ent == NULL || ent->d_name[0] == '\0') - break; - if (ent->d_name[0] == '.') - continue; - - strlcpy(device, ent->d_name, sizeof(device)); - path_decode(device); - udev = udev_device_init(NULL); - if (udev == NULL) - break; - if (udev_db_get_device(udev, device) == 0) { - char filename[PATH_SIZE]; - struct stat statbuf; - - info("found db entry '%s'", device); - strlcpy(filename, udev_root, sizeof(filename)); - strlcat(filename, "/", sizeof(filename)); - strlcat(filename, name, sizeof(filename)); - /* make sure device entry matches dev_t */ - if (stat(filename, &statbuf) == 0) { - if (statbuf.st_rdev == udev->devt) { - info("node '%s' matches dev_t", udev->name); - strlcpy(devpath, device, len); - found = 1; - } - } - } - udev_device_cleanup(udev); - } - - closedir(dir); - if (found) - return 0; - else - return -1; -} - int udev_db_get_all_entries(struct list_head *name_list) { char dbpath[PATH_MAX]; |