X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev%2Fudevadm-info.c;h=b3b31ebafe459abc971527b05a2f82c51448989a;hb=dc1791a9e6b59bd070a5f9c01b2214a1f8d69a82;hp=5f6209af2a772666082f7b12e6964666dab173c8;hpb=a89d342dfb45b54e29381af9dbc495bbb2b057af;p=elogind.git diff --git a/udev/udevadm-info.c b/udev/udevadm-info.c index 5f6209af2..b3b31ebaf 100644 --- a/udev/udevadm-info.c +++ b/udev/udevadm-info.c @@ -142,10 +142,6 @@ static void print_record(struct udev_device *device) if (i != 0) printf("L: %i\n", i); - i = udev_device_get_watch_handle(device); - if (i >= 0) - printf("W: %u\n", i); - udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(device)) { len = strlen(udev_get_dev_path(udev_device_get_udev(device))); printf("S: %s\n", &udev_list_entry_get_name(list_entry)[len+1]); @@ -158,7 +154,7 @@ static void print_record(struct udev_device *device) printf("\n"); } -static int stat_device(const char *name, int export, const char *prefix) +static int stat_device(const char *name, bool export, const char *prefix) { struct stat statbuf; @@ -202,8 +198,8 @@ static int export_devices(struct udev *udev) int udevadm_info(struct udev *udev, int argc, char *argv[]) { struct udev_device *device = NULL; - int root = 0; - int export = 0; + bool root = 0; + bool export = 0; const char *export_prefix = NULL; char path[UTIL_PATH_SIZE]; char name[UTIL_PATH_SIZE]; @@ -242,11 +238,11 @@ int udevadm_info(struct udev *udev, int argc, char *argv[]) QUERY_ALL, } query = QUERY_NONE; - while (1) { + for (;;) { int option; struct stat statbuf; - option = getopt_long(argc, argv, "aed:n:p:q:rxPVh", options, NULL); + option = getopt_long(argc, argv, "aed:n:p:q:rxP:Vh", options, NULL); if (option == -1) break; @@ -328,7 +324,7 @@ int udevadm_info(struct udev *udev, int argc, char *argv[]) case 'r': if (action == ACTION_NONE) action = ACTION_ROOT; - root = 1; + root = true; break; case 'd': action = ACTION_DEVICE_ID_FILE; @@ -341,7 +337,7 @@ int udevadm_info(struct udev *udev, int argc, char *argv[]) export_devices(udev); goto exit; case 'x': - export = 1; + export = true; break; case 'P': export_prefix = optarg; @@ -421,7 +417,17 @@ int udevadm_info(struct udev *udev, int argc, char *argv[]) case QUERY_PROPERTY: list_entry = udev_device_get_properties_list_entry(device); while (list_entry != NULL) { - printf("%s=%s\n", udev_list_entry_get_name(list_entry), udev_list_entry_get_value(list_entry)); + if (export) { + const char *prefix = export_prefix; + + if (prefix == NULL) + prefix = ""; + printf("%s%s='%s'\n", prefix, + udev_list_entry_get_name(list_entry), + udev_list_entry_get_value(list_entry)); + } else { + printf("%s=%s\n", udev_list_entry_get_name(list_entry), udev_list_entry_get_value(list_entry)); + } list_entry = udev_list_entry_get_next(list_entry); } break;