1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-30 14:55:26 +03:00

udevadm: info - fix lookup-by-name

This commit is contained in:
Kay Sievers 2008-09-15 12:01:35 -07:00
parent 0518da3b74
commit 9a8047fa29

View File

@ -182,12 +182,10 @@ static int export_all_cb(struct udev *udev,
static struct udev_device *lookup_device_by_name(struct udev *udev, const char *name) static struct udev_device *lookup_device_by_name(struct udev *udev, const char *name)
{ {
#if 0 struct udev_device *udev_device = NULL;
/* FIXME */
LIST_HEAD(name_list); LIST_HEAD(name_list);
int count; int count;
struct name_entry *device; struct name_entry *device;
int rc = -1;
count = udev_db_get_devices_by_name(udev, name, &name_list); count = udev_db_get_devices_by_name(udev, name, &name_list);
if (count <= 0) if (count <= 0)
@ -195,7 +193,7 @@ static struct udev_device *lookup_device_by_name(struct udev *udev, const char *
info(udev, "found %i devices for '%s'\n", count, name); info(udev, "found %i devices for '%s'\n", count, name);
/* select the device that seems to match */ /* select the device that matches */
list_for_each_entry(device, &name_list, node) { list_for_each_entry(device, &name_list, node) {
struct udevice *udevice_loop; struct udevice *udevice_loop;
char filename[UTIL_PATH_SIZE]; char filename[UTIL_PATH_SIZE];
@ -207,7 +205,6 @@ static struct udev_device *lookup_device_by_name(struct udev *udev, const char *
if (udev_db_get_device(udevice_loop, device->name) != 0) if (udev_db_get_device(udevice_loop, device->name) != 0)
goto next; goto next;
info(udev, "found db entry '%s'\n", device->name); info(udev, "found db entry '%s'\n", device->name);
/* make sure, we don't get a link of a different device */ /* make sure, we don't get a link of a different device */
util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename));
util_strlcat(filename, "/", sizeof(filename)); util_strlcat(filename, "/", sizeof(filename));
@ -218,17 +215,15 @@ static struct udev_device *lookup_device_by_name(struct udev *udev, const char *
info(udev, "skip '%s', dev_t doesn't match\n", udevice_loop->name); info(udev, "skip '%s', dev_t doesn't match\n", udevice_loop->name);
goto next; goto next;
} }
rc = 0; udev_device = udev_device_new_from_devpath(udev, udevice_loop->dev->devpath);
*udevice = udevice_loop; udev_device_cleanup(udevice_loop);
break; break;
next: next:
udev_device_cleanup(udevice_loop); udev_device_cleanup(udevice_loop);
} }
out: out:
name_list_cleanup(udev, &name_list); name_list_cleanup(udev, &name_list);
return rc; return udev_device;
#endif
return NULL;
} }
static int add_devlink_cb(struct udev_device *device, const char *value, void *data) static int add_devlink_cb(struct udev_device *device, const char *value, void *data)
@ -439,7 +434,7 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
switch (action) { switch (action) {
case ACTION_QUERY: case ACTION_QUERY:
if (device == NULL) { if (device == NULL) {
fprintf(stderr, "query needs --path= or node --name= specified\n"); fprintf(stderr, "query needs a valid device specified by --path= or --name=\n");
rc = 4; rc = 4;
goto exit; goto exit;
} }
@ -480,7 +475,7 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
break; break;
case ACTION_ATTRIBUTE_WALK: case ACTION_ATTRIBUTE_WALK:
if (device == NULL) { if (device == NULL) {
fprintf(stderr, "attribute walk needs --path or node --name specified\n"); fprintf(stderr, "query needs a valid device specified by --path= or --name=\n");
rc = 5; rc = 5;
goto exit; goto exit;
} }