diff options
author | Kay Sievers <kay.sievers@novell.com> | 2007-05-08 17:17:33 +1000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2007-05-08 17:17:33 +1000 |
commit | 54bad3644f4ea8132a789e827d05d2e712b4f547 (patch) | |
tree | 2cc04f49d0b3ef104ee2741425e095cf5888d89b /Detail.c | |
parent | 2fb749d1b7588985b1834e43de4ec5685d0b8d26 (diff) | |
download | mdadm-54bad3644f4ea8132a789e827d05d2e712b4f547.tar.gz mdadm-54bad3644f4ea8132a789e827d05d2e712b4f547.tar.xz mdadm-54bad3644f4ea8132a789e827d05d2e712b4f547.zip |
Add --export option to --detail to use key=value pairs.
udev likes to get information about a device as key=value pairs so it
can create disk/by-id links etc. So add --export flag which causes
the output of --detail to easily parsable.
From: Kay Sievers <kay.sievers@novell.com>
Diffstat (limited to 'Detail.c')
-rw-r--r-- | Detail.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -31,7 +31,7 @@ #include "md_p.h" #include "md_u.h" -int Detail(char *dev, int brief, int test, char *homehost) +int Detail(char *dev, int brief, int export, int test, char *homehost) { /* * Print out details for an md array by using @@ -128,7 +128,18 @@ int Detail(char *dev, int brief, int test, char *homehost) /* Ok, we have some info to print... */ c = map_num(pers, array.level); - if (brief) + + if (export) { + if (c) + printf("MD_LEVEL=%s\n", c); + printf("MD_DEVICES=%d\n", array.raid_disks); + printf("MD_METADATA=%d.%d\n", array.major_version, + array.minor_version); + st->ss->export_super(super); + goto out; + } + + if (brief) printf("ARRAY %s level=%s num-devices=%d", dev, c?c:"-unknown-",array.raid_disks ); else { mdu_bitmap_file_t bmf; @@ -360,6 +371,7 @@ This is pretty boring if (brief > 1 && devices) printf("\n devices=%s", devices); if (brief) printf("\n"); +out: if (test && (rv&2)) rv &= ~1; close(fd); return rv; |