summaryrefslogtreecommitdiff
path: root/udev
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2010-12-09 21:10:30 +0100
committerKay Sievers <kay.sievers@vrfy.org>2010-12-10 01:18:14 +0100
commit88163971b93260474bf2dd3195dc4e72098584ba (patch)
treed3cf94ea2c3e351739bcb2c3301dd4df7c8c8244 /udev
parent8ba13ec1cd00b86001b4344aec11ae0a64395f7b (diff)
udevadm: info - honor --export and --export-prefix for property query
The output will always be quoted: $ udevadm info --export --export-prefix=MY_ --query=property --name=sda MY_UDEV_LOG='3' MY_DEVPATH='/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda' MY_MAJOR='259' MY_MINOR='0' MY_DEVNAME='sda' MY_DEVTYPE='disk' MY_SUBSYSTEM='block'
Diffstat (limited to 'udev')
-rw-r--r--udev/udevadm-info.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/udev/udevadm-info.c b/udev/udevadm-info.c
index 9bd60c7243..b3b31ebafe 100644
--- a/udev/udevadm-info.c
+++ b/udev/udevadm-info.c
@@ -154,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;
@@ -198,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];
@@ -324,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;
@@ -337,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;
@@ -417,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;