aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2012-03-03 15:09:07 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2012-03-03 15:09:07 +0100
commite8cfc3f693e8a0cbfc489564c76e00c074f63066 (patch)
tree6b89cd91d9fc4b8138b3c5ea08c7c619f1bc0017
parent97e528164183c9a9b4768b0d078b3039a1a6ae36 (diff)
downloadbusybox-w32-e8cfc3f693e8a0cbfc489564c76e00c074f63066.tar.gz
busybox-w32-e8cfc3f693e8a0cbfc489564c76e00c074f63066.tar.bz2
busybox-w32-e8cfc3f693e8a0cbfc489564c76e00c074f63066.zip
blkid: if parameters are given, do not scan /dev
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/volume_id.h2
-rw-r--r--util-linux/blkid.c5
-rw-r--r--util-linux/volume_id/get_devname.c24
3 files changed, 17 insertions, 14 deletions
diff --git a/include/volume_id.h b/include/volume_id.h
index 4a78cd1e4..a83da899e 100644
--- a/include/volume_id.h
+++ b/include/volume_id.h
@@ -20,7 +20,7 @@
20 20
21char *get_devname_from_label(const char *spec); 21char *get_devname_from_label(const char *spec);
22char *get_devname_from_uuid(const char *spec); 22char *get_devname_from_uuid(const char *spec);
23void display_uuid_cache(void); 23void display_uuid_cache(int scan_devices);
24 24
25/* Returns: 25/* Returns:
26 * 0: no UUID= or LABEL= prefix found 26 * 0: no UUID= or LABEL= prefix found
diff --git a/util-linux/blkid.c b/util-linux/blkid.c
index a9fd9f361..1bbc80311 100644
--- a/util-linux/blkid.c
+++ b/util-linux/blkid.c
@@ -18,11 +18,14 @@
18int blkid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 18int blkid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
19int blkid_main(int argc UNUSED_PARAM, char **argv) 19int blkid_main(int argc UNUSED_PARAM, char **argv)
20{ 20{
21 int scan_devices = 1;
22
21 while (*++argv) { 23 while (*++argv) {
22 /* Note: bogus device names don't cause any error messages */ 24 /* Note: bogus device names don't cause any error messages */
23 add_to_uuid_cache(*argv); 25 add_to_uuid_cache(*argv);
26 scan_devices = 0;
24 } 27 }
25 28
26 display_uuid_cache(); 29 display_uuid_cache(scan_devices);
27 return 0; 30 return 0;
28} 31}
diff --git a/util-linux/volume_id/get_devname.c b/util-linux/volume_id/get_devname.c
index d81e24438..230102d89 100644
--- a/util-linux/volume_id/get_devname.c
+++ b/util-linux/volume_id/get_devname.c
@@ -115,7 +115,7 @@ uuidcache_check_device(const char *device,
115} 115}
116 116
117static struct uuidCache_s* 117static struct uuidCache_s*
118uuidcache_init(void) 118uuidcache_init(int scan_devices)
119{ 119{
120 dbg("DBG: uuidCache=%x, uuidCache"); 120 dbg("DBG: uuidCache=%x, uuidCache");
121 if (uuidCache) 121 if (uuidCache)
@@ -131,12 +131,12 @@ uuidcache_init(void)
131 * This is unacceptably complex. Let's just scan /dev. 131 * This is unacceptably complex. Let's just scan /dev.
132 * (Maybe add scanning of /sys/block/XXX/dev for devices 132 * (Maybe add scanning of /sys/block/XXX/dev for devices
133 * somehow not having their /dev/XXX entries created?) */ 133 * somehow not having their /dev/XXX entries created?) */
134 134 if (scan_devices)
135 recursive_action("/dev", ACTION_RECURSE, 135 recursive_action("/dev", ACTION_RECURSE,
136 uuidcache_check_device, /* file_action */ 136 uuidcache_check_device, /* file_action */
137 NULL, /* dir_action */ 137 NULL, /* dir_action */
138 NULL, /* userData */ 138 NULL, /* userData */
139 0 /* depth */); 139 0 /* depth */);
140 140
141 return uuidCache; 141 return uuidCache;
142} 142}
@@ -150,7 +150,7 @@ get_spec_by_x(int n, const char *t, int *majorPtr, int *minorPtr)
150{ 150{
151 struct uuidCache_s *uc; 151 struct uuidCache_s *uc;
152 152
153 uc = uuidcache_init(); 153 uc = uuidcache_init(/*scan_devices:*/ 1);
154 while (uc) { 154 while (uc) {
155 switch (n) { 155 switch (n) {
156 case UUID: 156 case UUID:
@@ -215,11 +215,11 @@ get_spec_by_volume_label(const char *s, int *major, int *minor)
215#endif // UNUSED 215#endif // UNUSED
216 216
217/* Used by blkid */ 217/* Used by blkid */
218void display_uuid_cache(void) 218void display_uuid_cache(int scan_devices)
219{ 219{
220 struct uuidCache_s *uc; 220 struct uuidCache_s *uc;
221 221
222 uc = uuidcache_init(); 222 uc = uuidcache_init(scan_devices);
223 while (uc) { 223 while (uc) {
224 printf("%s:", uc->device); 224 printf("%s:", uc->device);
225 if (uc->label[0]) 225 if (uc->label[0])
@@ -264,7 +264,7 @@ char *get_devname_from_label(const char *spec)
264{ 264{
265 struct uuidCache_s *uc; 265 struct uuidCache_s *uc;
266 266
267 uc = uuidcache_init(); 267 uc = uuidcache_init(/*scan_devices:*/ 1);
268 while (uc) { 268 while (uc) {
269 if (uc->label[0] && strcmp(spec, uc->label) == 0) { 269 if (uc->label[0] && strcmp(spec, uc->label) == 0) {
270 return xstrdup(uc->device); 270 return xstrdup(uc->device);
@@ -278,7 +278,7 @@ char *get_devname_from_uuid(const char *spec)
278{ 278{
279 struct uuidCache_s *uc; 279 struct uuidCache_s *uc;
280 280
281 uc = uuidcache_init(); 281 uc = uuidcache_init(/*scan_devices:*/ 1);
282 while (uc) { 282 while (uc) {
283 /* case of hex numbers doesn't matter */ 283 /* case of hex numbers doesn't matter */
284 if (strcasecmp(spec, uc->uc_uuid) == 0) { 284 if (strcasecmp(spec, uc->uc_uuid) == 0) {