aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-03-17 09:21:26 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-03-17 09:21:26 +0000
commitc5b737231debe51edb769a0b5667ee9719e560e0 (patch)
tree9abeaec24486a888ef3bbfe2c179180dbecafd35
parent592d4fe7722b094b18194cdf6a692a71a116e4ca (diff)
downloadbusybox-w32-c5b737231debe51edb769a0b5667ee9719e560e0.tar.gz
busybox-w32-c5b737231debe51edb769a0b5667ee9719e560e0.tar.bz2
busybox-w32-c5b737231debe51edb769a0b5667ee9719e560e0.zip
volude_id: remove unused fields and functions which were setting them
function old new delta uuidcache_init 567 704 +137 findfs_main - 125 +125 packed_usage 23662 23694 +32 static.drive_name_string - 14 +14 applet_names 1815 1822 +7 applet_main 1104 1108 +4 volume_id_open_node 35 38 +3 applet_nameofs 552 554 +2 get_devname_from_label 78 79 +1 applet_install_loc 138 139 +1 volume_id_set_label_unicode16 31 27 -4 volume_id_set_label_string 74 70 -4 get_devname_from_uuid 63 59 -4 fs1 12 8 -4 volume_id_set_unicode16 209 202 -7 volume_id_free_buffer 71 56 -15 free_volume_id 52 37 -15 volume_id_probe_luks 97 79 -18 volume_id_set_usage_part 21 - -21 volume_id_probe_ufs 148 126 -22 volume_id_probe_lsi_mega_raid 131 108 -23 volume_id_probe_highpoint_45x_raid 127 104 -23 volume_id_probe_highpoint_37x_raid 87 63 -24 volume_id_set_usage 28 - -28 volume_id_probe_romfs 121 93 -28 volume_id_set_label_raw 30 - -30 volume_id_probe_promise_fasttrack_raid 174 144 -30 volume_id_set_uuid 373 342 -31 volume_id_probe_xfs 122 91 -31 volume_id_probe_jfs 138 107 -31 volume_id_probe_ocfs2 139 107 -32 volume_id_probe_lvm1 90 58 -32 volume_id_probe_cramfs 106 63 -43 volume_id_probe_via_raid 145 101 -44 volume_id_probe_intel_software_raid 153 108 -45 volume_id_probe_minix 121 74 -47 volume_id_probe_udf 682 632 -50 volume_id_probe_nvidia_raid 158 108 -50 volume_id_probe_lvm2 128 78 -50 volume_id_probe_hpfs 117 67 -50 volume_id_probe_ext 143 93 -50 volume_id_probe_linux_raid 191 139 -52 volume_id_probe_sysv 244 187 -57 volume_id_probe_silicon_medley_raid 158 97 -61 usage_to_string 64 - -64 volume_id_probe_linux_swap 263 198 -65 volume_id_get_buffer 372 307 -65 volume_id_probe_iso9660 412 332 -80 volume_id_probe_hfs_hfsplus 888 806 -82 volume_id_probe_ntfs 396 294 -102 volume_id_probe_vfat 980 872 -108 volume_id_probe_reiserfs 417 268 -149 dev_get_major_minor 175 - -175 uuidcache_check_device 692 499 -193 volume_id_probe_mac_partition_map 697 - -697 ------------------------------------------------------------------------------ (add/remove: 2/6 grow/shrink: 8/39 up/down: 326/-2836) Total: -2510 bytes text data bss dec hex filename 797220 662 7420 805302 c49b6 busybox_old 794244 662 7420 802326 c3e16 busybox_unstripped
-rw-r--r--TODO_config_nommu2
-rw-r--r--include/applets.h2
-rw-r--r--scripts/defconfig2
-rw-r--r--util-linux/Config.in30
-rw-r--r--util-linux/Kbuild56
-rw-r--r--util-linux/volume_id/Kbuild5
-rw-r--r--util-linux/volume_id/cramfs.c10
-rw-r--r--util-linux/volume_id/ext.c20
-rw-r--r--util-linux/volume_id/fat.c28
-rw-r--r--util-linux/volume_id/get_devname.c216
-rw-r--r--util-linux/volume_id/hfs.c15
-rw-r--r--util-linux/volume_id/highpoint.c8
-rw-r--r--util-linux/volume_id/hpfs.c7
-rw-r--r--util-linux/volume_id/iso9660.c19
-rw-r--r--util-linux/volume_id/isw_raid.c6
-rw-r--r--util-linux/volume_id/jfs.c6
-rw-r--r--util-linux/volume_id/linux_raid.c12
-rw-r--r--util-linux/volume_id/linux_swap.c14
-rw-r--r--util-linux/volume_id/lsi_raid.c4
-rw-r--r--util-linux/volume_id/luks.c5
-rw-r--r--util-linux/volume_id/lvm.c13
-rw-r--r--util-linux/volume_id/minix.c25
-rw-r--r--util-linux/volume_id/ntfs.c20
-rw-r--r--util-linux/volume_id/nvidia_raid.c6
-rw-r--r--util-linux/volume_id/ocfs2.c8
-rw-r--r--util-linux/volume_id/promise_raid.c4
-rw-r--r--util-linux/volume_id/reiserfs.c27
-rw-r--r--util-linux/volume_id/romfs.c6
-rw-r--r--util-linux/volume_id/silicon_raid.c8
-rw-r--r--util-linux/volume_id/sysv.c10
-rw-r--r--util-linux/volume_id/udf.c6
-rw-r--r--util-linux/volume_id/ufs.c4
-rw-r--r--util-linux/volume_id/util.c17
-rw-r--r--util-linux/volume_id/via_raid.c8
-rw-r--r--util-linux/volume_id/volume_id.c13
-rw-r--r--util-linux/volume_id/volume_id_internal.h44
-rw-r--r--util-linux/volume_id/xfs.c6
37 files changed, 365 insertions, 327 deletions
diff --git a/TODO_config_nommu b/TODO_config_nommu
index 29c7580e3..e62856875 100644
--- a/TODO_config_nommu
+++ b/TODO_config_nommu
@@ -510,8 +510,6 @@ CONFIG_FEATURE_VOLUMEID_HPFS=y
510CONFIG_FEATURE_VOLUMEID_ROMFS=y 510CONFIG_FEATURE_VOLUMEID_ROMFS=y
511CONFIG_FEATURE_VOLUMEID_SYSV=y 511CONFIG_FEATURE_VOLUMEID_SYSV=y
512CONFIG_FEATURE_VOLUMEID_MINIX=y 512CONFIG_FEATURE_VOLUMEID_MINIX=y
513CONFIG_FEATURE_VOLUMEID_MAC=y
514CONFIG_FEATURE_VOLUMEID_MSDOS=y
515CONFIG_FEATURE_VOLUMEID_OCFS2=y 513CONFIG_FEATURE_VOLUMEID_OCFS2=y
516CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID=y 514CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID=y
517CONFIG_FEATURE_VOLUMEID_ISWRAID=y 515CONFIG_FEATURE_VOLUMEID_ISWRAID=y
diff --git a/include/applets.h b/include/applets.h
index c2a089c69..13c464887 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -155,7 +155,7 @@ USE_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_NEVER))
155USE_FETCHMAIL(APPLET_ODDNAME(fetchmail, sendgetmail, _BB_DIR_USR_BIN, _BB_SUID_NEVER, fetchmail)) 155USE_FETCHMAIL(APPLET_ODDNAME(fetchmail, sendgetmail, _BB_DIR_USR_BIN, _BB_SUID_NEVER, fetchmail))
156USE_FEATURE_GREP_FGREP_ALIAS(APPLET_NOUSAGE(fgrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER)) 156USE_FEATURE_GREP_FGREP_ALIAS(APPLET_NOUSAGE(fgrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER))
157USE_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_NEVER, find)) 157USE_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_NEVER, find))
158//USE_FINDFS(APPLET_NOUSAGE(findfs, tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) 158USE_FINDFS(APPLET(findfs, _BB_DIR_SBIN, _BB_SUID_NEVER))
159USE_FOLD(APPLET(fold, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 159USE_FOLD(APPLET(fold, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
160USE_FREE(APPLET(free, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 160USE_FREE(APPLET(free, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
161USE_FREERAMDISK(APPLET(freeramdisk, _BB_DIR_SBIN, _BB_SUID_NEVER)) 161USE_FREERAMDISK(APPLET(freeramdisk, _BB_DIR_SBIN, _BB_SUID_NEVER))
diff --git a/scripts/defconfig b/scripts/defconfig
index a42f6e41e..6dbe5d146 100644
--- a/scripts/defconfig
+++ b/scripts/defconfig
@@ -506,8 +506,6 @@ CONFIG_FEATURE_USE_TERMIOS=y
506# CONFIG_FEATURE_VOLUMEID_ROMFS is not set 506# CONFIG_FEATURE_VOLUMEID_ROMFS is not set
507# CONFIG_FEATURE_VOLUMEID_SYSV is not set 507# CONFIG_FEATURE_VOLUMEID_SYSV is not set
508# CONFIG_FEATURE_VOLUMEID_MINIX is not set 508# CONFIG_FEATURE_VOLUMEID_MINIX is not set
509# CONFIG_FEATURE_VOLUMEID_MAC is not set
510# CONFIG_FEATURE_VOLUMEID_MSDOS is not set
511# CONFIG_FEATURE_VOLUMEID_OCFS2 is not set 509# CONFIG_FEATURE_VOLUMEID_OCFS2 is not set
512# CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID is not set 510# CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID is not set
513# CONFIG_FEATURE_VOLUMEID_ISWRAID is not set 511# CONFIG_FEATURE_VOLUMEID_ISWRAID is not set
diff --git a/util-linux/Config.in b/util-linux/Config.in
index 25c7a1efc..a1e843a3d 100644
--- a/util-linux/Config.in
+++ b/util-linux/Config.in
@@ -159,7 +159,7 @@ config FINDFS
159 package. However, the e2fsprogs version only support ext2/3. This 159 package. However, the e2fsprogs version only support ext2/3. This
160 version supports those in addition to FAT, swap, and ReiserFS. 160 version supports those in addition to FAT, swap, and ReiserFS.
161 WARNING: 161 WARNING:
162 With all submodules selected, it will add ~11k to busybox. 162 With all submodules selected, it will add ~9k to busybox.
163 163
164config FREERAMDISK 164config FREERAMDISK
165 bool "freeramdisk" 165 bool "freeramdisk"
@@ -518,19 +518,20 @@ config FEATURE_VOLUMEID_MINIX
518 help 518 help
519 TODO 519 TODO
520 520
521config FEATURE_VOLUMEID_MAC 521### These only detect partition tables - not used (yet?)
522 bool "mac filesystem" 522### config FEATURE_VOLUMEID_MAC
523 default n 523### bool "mac filesystem"
524 depends on VOLUMEID 524### default n
525 help 525### depends on VOLUMEID
526 TODO 526### help
527 527### TODO
528config FEATURE_VOLUMEID_MSDOS 528###
529 bool "msdos filesystem" 529### config FEATURE_VOLUMEID_MSDOS
530 default n 530### bool "msdos filesystem"
531 depends on VOLUMEID 531### default n
532 help 532### depends on VOLUMEID
533 TODO 533### help
534### TODO
534 535
535config FEATURE_VOLUMEID_OCFS2 536config FEATURE_VOLUMEID_OCFS2
536 bool "ocfs2 filesystem" 537 bool "ocfs2 filesystem"
@@ -638,7 +639,6 @@ config FEATURE_MOUNT_LABEL
638 bool "Support specifiying devices by label or UUID" 639 bool "Support specifiying devices by label or UUID"
639 default n 640 default n
640 depends on MOUNT 641 depends on MOUNT
641 select FINDFS
642 help 642 help
643 This allows for specifying a device by label or uuid, rather than by 643 This allows for specifying a device by label or uuid, rather than by
644 name. This feature utilizes the same functionality as findfs. 644 name. This feature utilizes the same functionality as findfs.
diff --git a/util-linux/Kbuild b/util-linux/Kbuild
index 0f33c6be2..b4e051589 100644
--- a/util-linux/Kbuild
+++ b/util-linux/Kbuild
@@ -5,31 +5,31 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8lib-$(CONFIG_DMESG) +=dmesg.o 8lib-$(CONFIG_DMESG) += dmesg.o
9lib-$(CONFIG_FBSET) +=fbset.o 9lib-$(CONFIG_FBSET) += fbset.o
10lib-$(CONFIG_FDFLUSH) +=freeramdisk.o 10lib-$(CONFIG_FDFLUSH) += freeramdisk.o
11lib-$(CONFIG_FDFORMAT) +=fdformat.o 11lib-$(CONFIG_FDFORMAT) += fdformat.o
12lib-$(CONFIG_FDISK) +=fdisk.o 12lib-$(CONFIG_FDISK) += fdisk.o
13lib-$(CONFIG_FINDFS) +=findfs.o 13lib-$(CONFIG_FINDFS) += findfs.o
14lib-$(CONFIG_FREERAMDISK) +=freeramdisk.o 14lib-$(CONFIG_FREERAMDISK) += freeramdisk.o
15lib-$(CONFIG_FSCK_MINIX) +=fsck_minix.o 15lib-$(CONFIG_FSCK_MINIX) += fsck_minix.o
16lib-$(CONFIG_GETOPT) +=getopt.o 16lib-$(CONFIG_GETOPT) += getopt.o
17lib-$(CONFIG_HEXDUMP) +=hexdump.o 17lib-$(CONFIG_HEXDUMP) += hexdump.o
18lib-$(CONFIG_HWCLOCK) +=hwclock.o 18lib-$(CONFIG_HWCLOCK) += hwclock.o
19lib-$(CONFIG_IPCRM) +=ipcrm.o 19lib-$(CONFIG_IPCRM) += ipcrm.o
20lib-$(CONFIG_IPCS) +=ipcs.o 20lib-$(CONFIG_IPCS) += ipcs.o
21lib-$(CONFIG_LOSETUP) +=losetup.o 21lib-$(CONFIG_LOSETUP) += losetup.o
22lib-$(CONFIG_MDEV) +=mdev.o 22lib-$(CONFIG_MDEV) += mdev.o
23lib-$(CONFIG_MKFS_MINIX) +=mkfs_minix.o 23lib-$(CONFIG_MKFS_MINIX) += mkfs_minix.o
24lib-$(CONFIG_MKSWAP) +=mkswap.o 24lib-$(CONFIG_MKSWAP) += mkswap.o
25lib-$(CONFIG_MORE) +=more.o 25lib-$(CONFIG_MORE) += more.o
26lib-$(CONFIG_MOUNT) +=mount.o 26lib-$(CONFIG_MOUNT) += mount.o
27lib-$(CONFIG_PIVOT_ROOT) +=pivot_root.o 27lib-$(CONFIG_PIVOT_ROOT) += pivot_root.o
28lib-$(CONFIG_RDATE) +=rdate.o 28lib-$(CONFIG_RDATE) += rdate.o
29lib-$(CONFIG_READPROFILE) +=readprofile.o 29lib-$(CONFIG_READPROFILE) += readprofile.o
30lib-$(CONFIG_RTCWAKE) +=rtcwake.o 30lib-$(CONFIG_RTCWAKE) += rtcwake.o
31lib-$(CONFIG_SCRIPT) +=script.o 31lib-$(CONFIG_SCRIPT) += script.o
32lib-$(CONFIG_SETARCH) +=setarch.o 32lib-$(CONFIG_SETARCH) += setarch.o
33lib-$(CONFIG_SWAPONOFF) +=swaponoff.o 33lib-$(CONFIG_SWAPONOFF) += swaponoff.o
34lib-$(CONFIG_SWITCH_ROOT) +=switch_root.o 34lib-$(CONFIG_SWITCH_ROOT) += switch_root.o
35lib-$(CONFIG_UMOUNT) +=umount.o 35lib-$(CONFIG_UMOUNT) += umount.o
diff --git a/util-linux/volume_id/Kbuild b/util-linux/volume_id/Kbuild
index c2eb01564..96cd8807b 100644
--- a/util-linux/volume_id/Kbuild
+++ b/util-linux/volume_id/Kbuild
@@ -25,8 +25,9 @@ lib-$(CONFIG_FEATURE_VOLUMEID_JFS) += jfs.o
25lib-$(CONFIG_FEATURE_VOLUMEID_LINUXRAID) += linux_raid.o 25lib-$(CONFIG_FEATURE_VOLUMEID_LINUXRAID) += linux_raid.o
26lib-$(CONFIG_FEATURE_VOLUMEID_LINUXSWAP) += linux_swap.o 26lib-$(CONFIG_FEATURE_VOLUMEID_LINUXSWAP) += linux_swap.o
27lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o 27lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o
28lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o 28### unused
29lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o 29### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o
30### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o
30lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o 31lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o
31lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o 32lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o
32lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o 33lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o
diff --git a/util-linux/volume_id/cramfs.c b/util-linux/volume_id/cramfs.c
index fd6e87522..63b0c7cad 100644
--- a/util-linux/volume_id/cramfs.c
+++ b/util-linux/volume_id/cramfs.c
@@ -21,7 +21,7 @@
21#include "volume_id_internal.h" 21#include "volume_id_internal.h"
22 22
23struct cramfs_super { 23struct cramfs_super {
24 uint8_t magic[4]; 24 uint32_t magic;
25 uint32_t size; 25 uint32_t size;
26 uint32_t flags; 26 uint32_t flags;
27 uint32_t future; 27 uint32_t future;
@@ -45,12 +45,12 @@ int volume_id_probe_cramfs(struct volume_id *id, uint64_t off)
45 if (cs == NULL) 45 if (cs == NULL)
46 return -1; 46 return -1;
47 47
48 if (memcmp(cs->magic, "\x45\x3d\xcd\x28", 4) == 0) { 48 if (cs->magic == cpu_to_be32(0x453dcd28)) {
49 volume_id_set_label_raw(id, cs->name, 16); 49// volume_id_set_label_raw(id, cs->name, 16);
50 volume_id_set_label_string(id, cs->name, 16); 50 volume_id_set_label_string(id, cs->name, 16);
51 51
52 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 52// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
53 id->type = "cramfs"; 53// id->type = "cramfs";
54 return 0; 54 return 0;
55 } 55 }
56 56
diff --git a/util-linux/volume_id/ext.c b/util-linux/volume_id/ext.c
index 3c07f5301..db29dae70 100644
--- a/util-linux/volume_id/ext.c
+++ b/util-linux/volume_id/ext.c
@@ -47,25 +47,27 @@ int volume_id_probe_ext(struct volume_id *id, uint64_t off)
47{ 47{
48 struct ext2_super_block *es; 48 struct ext2_super_block *es;
49 49
50 dbg("probing at offset 0x%llx", (unsigned long long) off); 50 dbg("ext: probing at offset 0x%llx", (unsigned long long) off);
51 51
52 es = volume_id_get_buffer(id, off + EXT_SUPERBLOCK_OFFSET, 0x200); 52 es = volume_id_get_buffer(id, off + EXT_SUPERBLOCK_OFFSET, 0x200);
53 if (es == NULL) 53 if (es == NULL)
54 return -1; 54 return -1;
55 55
56 if (es->magic[0] != 0123 || 56 if (es->magic[0] != 0123 || es->magic[1] != 0357) {
57 es->magic[1] != 0357) 57 dbg("ext: no magic found");
58 return -1; 58 return -1;
59 }
59 60
60 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 61// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
61 volume_id_set_label_raw(id, es->volume_name, 16); 62// volume_id_set_label_raw(id, es->volume_name, 16);
62 volume_id_set_label_string(id, es->volume_name, 16); 63 volume_id_set_label_string(id, es->volume_name, 16);
63 volume_id_set_uuid(id, es->uuid, UUID_DCE); 64 volume_id_set_uuid(id, es->uuid, UUID_DCE);
65 dbg("ext: label '%s' uuid '%s'", id->label, id->uuid);
64 66
65 if ((le32_to_cpu(es->feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0) 67// if ((le32_to_cpu(es->feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0)
66 id->type = "ext3"; 68// id->type = "ext3";
67 else 69// else
68 id->type = "ext2"; 70// id->type = "ext2";
69 71
70 return 0; 72 return 0;
71} 73}
diff --git a/util-linux/volume_id/fat.c b/util-linux/volume_id/fat.c
index 4c2a91749..779971cc9 100644
--- a/util-linux/volume_id/fat.c
+++ b/util-linux/volume_id/fat.c
@@ -227,14 +227,16 @@ int volume_id_probe_vfat(struct volume_id *id, uint64_t off)
227 cluster_count /= vs->sectors_per_cluster; 227 cluster_count /= vs->sectors_per_cluster;
228 dbg("cluster_count 0x%x", cluster_count); 228 dbg("cluster_count 0x%x", cluster_count);
229 229
230 if (cluster_count < FAT12_MAX) { 230// if (cluster_count < FAT12_MAX) {
231 strcpy(id->type_version, "FAT12"); 231// strcpy(id->type_version, "FAT12");
232 } else if (cluster_count < FAT16_MAX) { 232// } else if (cluster_count < FAT16_MAX) {
233 strcpy(id->type_version, "FAT16"); 233// strcpy(id->type_version, "FAT16");
234 } else { 234// } else {
235 strcpy(id->type_version, "FAT32"); 235// strcpy(id->type_version, "FAT32");
236// goto fat32;
237// }
238 if (cluster_count >= FAT16_MAX)
236 goto fat32; 239 goto fat32;
237 }
238 240
239 /* the label may be an attribute in the root directory */ 241 /* the label may be an attribute in the root directory */
240 root_start = (reserved + fat_size) * sector_size; 242 root_start = (reserved + fat_size) * sector_size;
@@ -256,10 +258,10 @@ int volume_id_probe_vfat(struct volume_id *id, uint64_t off)
256 return -1; 258 return -1;
257 259
258 if (label != NULL && memcmp(label, "NO NAME ", 11) != 0) { 260 if (label != NULL && memcmp(label, "NO NAME ", 11) != 0) {
259 volume_id_set_label_raw(id, label, 11); 261// volume_id_set_label_raw(id, label, 11);
260 volume_id_set_label_string(id, label, 11); 262 volume_id_set_label_string(id, label, 11);
261 } else if (memcmp(vs->type.fat.label, "NO NAME ", 11) != 0) { 263 } else if (memcmp(vs->type.fat.label, "NO NAME ", 11) != 0) {
262 volume_id_set_label_raw(id, vs->type.fat.label, 11); 264// volume_id_set_label_raw(id, vs->type.fat.label, 11);
263 volume_id_set_label_string(id, vs->type.fat.label, 11); 265 volume_id_set_label_string(id, vs->type.fat.label, 11);
264 } 266 }
265 volume_id_set_uuid(id, vs->type.fat.serno, UUID_DOS); 267 volume_id_set_uuid(id, vs->type.fat.serno, UUID_DOS);
@@ -317,17 +319,17 @@ int volume_id_probe_vfat(struct volume_id *id, uint64_t off)
317 return -1; 319 return -1;
318 320
319 if (label != NULL && memcmp(label, "NO NAME ", 11) != 0) { 321 if (label != NULL && memcmp(label, "NO NAME ", 11) != 0) {
320 volume_id_set_label_raw(id, label, 11); 322// volume_id_set_label_raw(id, label, 11);
321 volume_id_set_label_string(id, label, 11); 323 volume_id_set_label_string(id, label, 11);
322 } else if (memcmp(vs->type.fat32.label, "NO NAME ", 11) != 0) { 324 } else if (memcmp(vs->type.fat32.label, "NO NAME ", 11) != 0) {
323 volume_id_set_label_raw(id, vs->type.fat32.label, 11); 325// volume_id_set_label_raw(id, vs->type.fat32.label, 11);
324 volume_id_set_label_string(id, vs->type.fat32.label, 11); 326 volume_id_set_label_string(id, vs->type.fat32.label, 11);
325 } 327 }
326 volume_id_set_uuid(id, vs->type.fat32.serno, UUID_DOS); 328 volume_id_set_uuid(id, vs->type.fat32.serno, UUID_DOS);
327 329
328 found: 330 found:
329 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 331// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
330 id->type = "vfat"; 332// id->type = "vfat";
331 333
332 return 0; 334 return 0;
333} 335}
diff --git a/util-linux/volume_id/get_devname.c b/util-linux/volume_id/get_devname.c
index af03d07a3..bb3043cd6 100644
--- a/util-linux/volume_id/get_devname.c
+++ b/util-linux/volume_id/get_devname.c
@@ -10,22 +10,19 @@
10 10
11#include "volume_id_internal.h" 11#include "volume_id_internal.h"
12 12
13#define BLKGETSIZE64 _IOR(0x12,114,size_t) 13//#define BLKGETSIZE64 _IOR(0x12,114,size_t)
14
15#define PROC_PARTITIONS "/proc/partitions"
16#define PROC_CDROMS "/proc/sys/dev/cdrom/info"
17#define DEVLABELDIR "/dev"
18#define SYS_BLOCK "/sys/block"
19 14
20static struct uuidCache_s { 15static struct uuidCache_s {
21 struct uuidCache_s *next; 16 struct uuidCache_s *next;
22 char uuid[16]; 17// int major, minor;
23 char *device; 18 char *device;
24 char *label; 19 char *label;
25 int major, minor; 20 char *uc_uuid; /* prefix makes it easier to grep for */
26} *uuidCache; 21} *uuidCache;
27 22
28/* for now, only ext2, ext3 and xfs are supported */ 23/* Returns !0 on error.
24 * Otherwise, returns malloc'ed strings for label and uuid
25 * (and they can't be NULL, although they can be "") */
29#if !ENABLE_FEATURE_VOLUMEID_ISO9660 26#if !ENABLE_FEATURE_VOLUMEID_ISO9660
30#define get_label_uuid(device, label, uuid, iso_only) \ 27#define get_label_uuid(device, label, uuid, iso_only) \
31 get_label_uuid(device, label, uuid) 28 get_label_uuid(device, label, uuid)
@@ -38,15 +35,18 @@ get_label_uuid(const char *device, char **label, char **uuid, int iso_only)
38 struct volume_id *vid; 35 struct volume_id *vid;
39 36
40 vid = volume_id_open_node(device); 37 vid = volume_id_open_node(device);
38 if (!vid)
39 return rv;
41 40
42 if (ioctl(vid->fd, BLKGETSIZE64, &size) != 0) { 41 if (ioctl(vid->fd, BLKGETSIZE64, &size) != 0)
43 size = 0; 42 size = 0;
44 }
45 43
46#if ENABLE_FEATURE_VOLUMEID_ISO9660 44#if ENABLE_FEATURE_VOLUMEID_ISO9660
47 if (iso_only ? 45 if ((iso_only ?
48 volume_id_probe_iso9660(vid, 0) != 0 : 46 volume_id_probe_iso9660(vid, 0) :
49 volume_id_probe_all(vid, 0, size) != 0) { 47 volume_id_probe_all(vid, 0, size)
48 ) != 0
49 ) {
50 goto ret; 50 goto ret;
51 } 51 }
52#else 52#else
@@ -55,10 +55,10 @@ get_label_uuid(const char *device, char **label, char **uuid, int iso_only)
55 } 55 }
56#endif 56#endif
57 57
58 if (vid->label[0] != '\0') { 58 if (vid->label[0] != '\0' || vid->uuid[0] != '\0') {
59 *label = xstrndup(vid->label, sizeof(vid->label)); 59 *label = xstrndup(vid->label, sizeof(vid->label));
60 *uuid = xstrndup(vid->uuid, sizeof(vid->uuid)); 60 *uuid = xstrndup(vid->uuid, sizeof(vid->uuid));
61 printf("Found label %s on %s (uuid:%s)\n", *label, device, *uuid); 61 dbg("found label '%s', uuid '%s' on %s", *label, *uuid, device);
62 rv = 0; 62 rv = 0;
63 } 63 }
64 ret: 64 ret:
@@ -66,8 +66,9 @@ get_label_uuid(const char *device, char **label, char **uuid, int iso_only)
66 return rv; 66 return rv;
67} 67}
68 68
69/* NB: we take ownership of (malloc'ed) label and uuid */
69static void 70static void
70uuidcache_addentry(char * device, int major, int minor, char *label, char *uuid) 71uuidcache_addentry(char *device, /*int major, int minor,*/ char *label, char *uuid)
71{ 72{
72 struct uuidCache_s *last; 73 struct uuidCache_s *last;
73 74
@@ -80,13 +81,16 @@ uuidcache_addentry(char * device, int major, int minor, char *label, char *uuid)
80 last = last->next; 81 last = last->next;
81 } 82 }
82 /*last->next = NULL; - xzalloc did it*/ 83 /*last->next = NULL; - xzalloc did it*/
83 last->label = label; 84// last->major = major;
85// last->minor = minor;
84 last->device = device; 86 last->device = device;
85 last->major = major; 87 last->label = label;
86 last->minor = minor; 88 last->uc_uuid = uuid;
87 memcpy(last->uuid, uuid, sizeof(last->uuid));
88} 89}
89 90
91/* If get_label_uuid() on device_name returns success,
92 * add a cache entry for this device.
93 * If device node does not exist, it will be temporarily created. */
90#if !ENABLE_FEATURE_VOLUMEID_ISO9660 94#if !ENABLE_FEATURE_VOLUMEID_ISO9660
91#define uuidcache_check_device(device_name, ma, mi, iso_only) \ 95#define uuidcache_check_device(device_name, ma, mi, iso_only) \
92 uuidcache_check_device(device_name, ma, mi) 96 uuidcache_check_device(device_name, ma, mi)
@@ -94,45 +98,62 @@ uuidcache_addentry(char * device, int major, int minor, char *label, char *uuid)
94static void 98static void
95uuidcache_check_device(const char *device_name, int ma, int mi, int iso_only) 99uuidcache_check_device(const char *device_name, int ma, int mi, int iso_only)
96{ 100{
97 char device[110]; 101 char *device, *last_slash;
98 char *uuid = NULL, *label = NULL; 102 char *uuid, *label;
99 char *ptr; 103 char *ptr;
100 char *deviceDir = NULL; 104 int must_remove = 0;
101 int mustRemove = 0; 105 int added = 0;
102 int mustRemoveDir = 0; 106
103 int i; 107 last_slash = NULL;
108 device = xasprintf("/dev/%s", device_name);
109 if (access(device, F_OK) != 0) {
110 /* device does not exist, temporarily create */
111 int slash_cnt = 0;
112
113 if ((ma | mi) < 0)
114 goto ret; /* we don't know major:minor! */
104 115
105 sprintf(device, "%s/%s", DEVLABELDIR, device_name);
106 if (access(device, F_OK)) {
107 ptr = device; 116 ptr = device;
108 i = 0;
109 while (*ptr) 117 while (*ptr)
110 if (*ptr++ == '/') 118 if (*ptr++ == '/')
111 i++; 119 slash_cnt++;
112 if (i > 2) { 120 if (slash_cnt > 2) {
113 deviceDir = alloca(strlen(device) + 1); 121// BUG: handles only slash_cnt == 3 case
114 strcpy(deviceDir, device); 122 last_slash = strrchr(device, '/');
115 ptr = deviceDir + (strlen(device) - 1); 123 *last_slash = '\0';
116 while (*ptr != '/') 124 if (mkdir(device, 0644)) {
117 *ptr-- = '\0'; 125 bb_perror_msg("can't create directory %s", device);
118 if (mkdir(deviceDir, 0644)) { 126 *last_slash = '/';
119 printf("mkdir: cannot create directory %s: %d\n", deviceDir, errno); 127 last_slash = NULL; /* prevents rmdir */
120 } else { 128 } else {
121 mustRemoveDir = 1; 129 *last_slash = '/';
122 } 130 }
123 } 131 }
124
125 mknod(device, S_IFBLK | 0600, makedev(ma, mi)); 132 mknod(device, S_IFBLK | 0600, makedev(ma, mi));
126 mustRemove = 1; 133 must_remove = 1;
134 }
135
136 uuid = NULL;
137 label = NULL;
138 if (get_label_uuid(device, &label, &uuid, iso_only) == 0) {
139 uuidcache_addentry(device, /*ma, mi,*/ label, uuid);
140 /* "device" is owned by cache now, don't free */
141 added = 1;
127 } 142 }
128 if (!get_label_uuid(device, &label, &uuid, iso_only))
129 uuidcache_addentry(strdup(device), ma, mi,
130 label, uuid);
131 143
132 if (mustRemove) unlink(device); 144 if (must_remove)
133 if (mustRemoveDir) rmdir(deviceDir); 145 unlink(device);
146 if (last_slash) {
147 *last_slash = '\0';
148 rmdir(device);
149 }
150 ret:
151 if (!added)
152 free(device);
134} 153}
135 154
155/* Run uuidcache_check_device() for every device mentioned
156 * in /proc/partitions */
136static void 157static void
137uuidcache_init_partitions(void) 158uuidcache_init_partitions(void)
138{ 159{
@@ -144,7 +165,7 @@ uuidcache_init_partitions(void)
144 int handleOnFirst; 165 int handleOnFirst;
145 char *chptr; 166 char *chptr;
146 167
147 procpt = xfopen(PROC_PARTITIONS, "r"); 168 procpt = xfopen("/proc/partitions", "r");
148/* 169/*
149# cat /proc/partitions 170# cat /proc/partitions
150major minor #blocks name 171major minor #blocks name
@@ -165,7 +186,7 @@ major minor #blocks name
165 diet's sscanf is quite limited */ 186 diet's sscanf is quite limited */
166 chptr = line; 187 chptr = line;
167 if (*chptr != ' ') continue; 188 if (*chptr != ' ') continue;
168 chptr++; 189 chptr = skip_whitespace(chptr);
169 190
170 ma = bb_strtou(chptr, &chptr, 0); 191 ma = bb_strtou(chptr, &chptr, 0);
171 if (ma < 0) continue; 192 if (ma < 0) continue;
@@ -185,6 +206,8 @@ major minor #blocks name
185 206
186 *strchrnul(chptr, '\n') = '\0'; 207 *strchrnul(chptr, '\n') = '\0';
187 /* now chptr => device name */ 208 /* now chptr => device name */
209 dbg("/proc/partitions: maj:%d min:%d sz:%llu name:'%s'",
210 ma, mi, sz, chptr);
188 if (!chptr[0]) 211 if (!chptr[0])
189 continue; 212 continue;
190 213
@@ -203,36 +226,35 @@ major minor #blocks name
203 fclose(procpt); 226 fclose(procpt);
204} 227}
205 228
206static int 229static void
207dev_get_major_minor(char *device_name, int *major, int *minor) 230dev_get_major_minor(char *device_name, int *major, int *minor)
208{ 231{
209 char * dev_path; 232 char dev[16];
210 int fd; 233 char *dev_path;
211 char dev[7]; 234 char *colon;
212 char *major_ptr, *minor_ptr; 235 int sz;
213 236
214 dev_path = alloca(strlen(SYS_BLOCK) + strlen(device_name) + 6); 237 dev_path = xasprintf("/sys/block/%s/dev", device_name);
215 sprintf(dev_path, "%s/%s/dev", SYS_BLOCK, device_name); 238 sz = open_read_close(dev_path, dev, sizeof(dev) - 1);
216 239 if (sz < 0)
217 fd = open(dev_path, O_RDONLY); 240 goto ret;
218 if (fd < 0) return 1; 241 dev[sz] = '\0';
219 full_read(fd, dev, sizeof(dev));
220 close(fd);
221
222 major_ptr = dev;
223 minor_ptr = strchr(dev, ':');
224 if (!minor_ptr) return 1;
225 *minor_ptr++ = '\0';
226 242
227 *major = strtol(major_ptr, NULL, 10); 243 colon = strchr(dev, ':');
228 *minor = strtol(minor_ptr, NULL, 10); 244 if (!colon)
245 goto ret;
246 *major = strtol(dev, NULL, 10);
247 *minor = strtol(colon + 1, NULL, 10);
229 248
230 return 0; 249 ret:
250 free(dev_path);
251 return;
231} 252}
232 253
233static void 254static void
234uuidcache_init_cdroms(void) 255uuidcache_init_cdroms(void)
235{ 256{
257#define PROC_CDROMS "/proc/sys/dev/cdrom/info"
236 char line[100]; 258 char line[100];
237 int ma, mi; 259 int ma, mi;
238 FILE *proccd; 260 FILE *proccd;
@@ -250,11 +272,13 @@ uuidcache_init_cdroms(void)
250 } 272 }
251 273
252 while (fgets(line, sizeof(line), proccd)) { 274 while (fgets(line, sizeof(line), proccd)) {
253 const char *drive_name_string = "drive name:\t\t"; 275 static const char drive_name_string[] ALIGN1 = "drive name:\t\t";
254 if (!strncmp(line, drive_name_string, strlen(drive_name_string))) { 276
277 if (strncmp(line, drive_name_string, sizeof(drive_name_string) - 1) == 0) {
255 char *device_name; 278 char *device_name;
256 device_name = strtok(line + strlen(drive_name_string), "\t\n"); 279 device_name = strtok(line + sizeof(drive_name_string) - 1, "\t\n");
257 while (device_name) { 280 while (device_name) {
281 ma = mi = -1;
258 dev_get_major_minor(device_name, &ma, &mi); 282 dev_get_major_minor(device_name, &ma, &mi);
259 uuidcache_check_device(device_name, ma, mi, 1); 283 uuidcache_check_device(device_name, ma, mi, 1);
260 device_name = strtok(NULL, "\t\n"); 284 device_name = strtok(NULL, "\t\n");
@@ -281,24 +305,24 @@ uuidcache_init(void)
281 305
282#ifdef UNUSED 306#ifdef UNUSED
283static char * 307static char *
284get_spec_by_x(int n, const char *t, int * majorPtr, int * minorPtr) 308get_spec_by_x(int n, const char *t, int *majorPtr, int *minorPtr)
285{ 309{
286 struct uuidCache_s *uc; 310 struct uuidCache_s *uc;
287 311
288 uuidcache_init(); 312 uuidcache_init();
289 uc = uuidCache; 313 uc = uuidCache;
290 314
291 while(uc) { 315 while (uc) {
292 switch (n) { 316 switch (n) {
293 case UUID: 317 case UUID:
294 if (!memcmp(t, uc->uuid, sizeof(uc->uuid))) { 318 if (strcmp(t, uc->uc_uuid) == 0) {
295 *majorPtr = uc->major; 319 *majorPtr = uc->major;
296 *minorPtr = uc->minor; 320 *minorPtr = uc->minor;
297 return uc->device; 321 return uc->device;
298 } 322 }
299 break; 323 break;
300 case VOL: 324 case VOL:
301 if (!strcmp(t, uc->label)) { 325 if (strcmp(t, uc->label) == 0) {
302 *majorPtr = uc->major; 326 *majorPtr = uc->major;
303 *minorPtr = uc->minor; 327 *minorPtr = uc->minor;
304 return uc->device; 328 return uc->device;
@@ -315,26 +339,27 @@ fromhex(char c)
315{ 339{
316 if (isdigit(c)) 340 if (isdigit(c))
317 return (c - '0'); 341 return (c - '0');
318 if (islower(c)) 342 return ((c|0x20) - 'a' + 10);
319 return (c - 'a' + 10);
320 return (c - 'A' + 10);
321} 343}
322 344
323static char * 345static char *
324get_spec_by_uuid(const char *s, int * major, int * minor) 346get_spec_by_uuid(const char *s, int *major, int *minor)
325{ 347{
326 unsigned char uuid[16]; 348 unsigned char uuid[16];
327 int i; 349 int i;
328 350
329 if (strlen(s) != 36 || 351 if (strlen(s) != 36 || s[8] != '-' || s[13] != '-'
330 s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-') 352 || s[18] != '-' || s[23] != '-'
353 ) {
331 goto bad_uuid; 354 goto bad_uuid;
332 for (i=0; i<16; i++) { 355 }
333 if (*s == '-') s++; 356 for (i = 0; i < 16; i++) {
334 if (!isxdigit(s[0]) || !isxdigit(s[1])) 357 if (*s == '-')
335 goto bad_uuid; 358 s++;
336 uuid[i] = ((fromhex(s[0])<<4) | fromhex(s[1])); 359 if (!isxdigit(s[0]) || !isxdigit(s[1]))
337 s += 2; 360 goto bad_uuid;
361 uuid[i] = ((fromhex(s[0]) << 4) | fromhex(s[1]));
362 s += 2;
338 } 363 }
339 return get_spec_by_x(UUID, (char *)uuid, major, minor); 364 return get_spec_by_x(UUID, (char *)uuid, major, minor);
340 365
@@ -358,13 +383,7 @@ static int display_uuid_cache(void)
358 383
359 u = uuidCache; 384 u = uuidCache;
360 while (u) { 385 while (u) {
361 printf("%s %s ", u->device, u->label); 386 printf("%s %s %s\n", u->device, u->label, u->uc_uuid);
362 for (i = 0; i < sizeof(u->uuid); i++) {
363 if (i == 4 || i == 6 || i == 8 || i == 10)
364 printf("-");
365 printf("%x", u->uuid[i] & 0xff);
366 }
367 printf("\n");
368 u = u->next; 387 u = u->next;
369 } 388 }
370 389
@@ -383,7 +402,8 @@ char *get_devname_from_label(const char *spec)
383 uuidcache_init(); 402 uuidcache_init();
384 uc = uuidCache; 403 uc = uuidCache;
385 while (uc) { 404 while (uc) {
386 if (uc->label && !strncmp(spec, uc->label, spec_len)) { 405// FIXME: empty label ("LABEL=") matches anything??!
406 if (uc->label[0] && strncmp(spec, uc->label, spec_len) == 0) {
387 return xstrdup(uc->device); 407 return xstrdup(uc->device);
388 } 408 }
389 uc = uc->next; 409 uc = uc->next;
@@ -398,7 +418,7 @@ char *get_devname_from_uuid(const char *spec)
398 uuidcache_init(); 418 uuidcache_init();
399 uc = uuidCache; 419 uc = uuidCache;
400 while (uc) { 420 while (uc) {
401 if (!memcmp(spec, uc->uuid, sizeof(uc->uuid))) { 421 if (strcmp(spec, uc->uc_uuid) == 0) {
402 return xstrdup(uc->device); 422 return xstrdup(uc->device);
403 } 423 }
404 uc = uc->next; 424 uc = uc->next;
diff --git a/util-linux/volume_id/hfs.c b/util-linux/volume_id/hfs.c
index 71a3df0b8..a7667f725 100644
--- a/util-linux/volume_id/hfs.c
+++ b/util-linux/volume_id/hfs.c
@@ -167,7 +167,7 @@ int volume_id_probe_hfs_hfsplus(struct volume_id *id, uint64_t off)
167 goto checkplus; 167 goto checkplus;
168 168
169 /* it may be just a hfs wrapper for hfs+ */ 169 /* it may be just a hfs wrapper for hfs+ */
170 if (memcmp(hfs->embed_sig, "H+", 2) == 0) { 170 if (hfs->embed_sig[0] == 'H' && hfs->embed_sig[1] == '+') {
171 alloc_block_size = be32_to_cpu(hfs->al_blk_size); 171 alloc_block_size = be32_to_cpu(hfs->al_blk_size);
172 dbg("alloc_block_size 0x%x", alloc_block_size); 172 dbg("alloc_block_size 0x%x", alloc_block_size);
173 173
@@ -188,14 +188,13 @@ int volume_id_probe_hfs_hfsplus(struct volume_id *id, uint64_t off)
188 } 188 }
189 189
190 if (hfs->label_len > 0 && hfs->label_len < 28) { 190 if (hfs->label_len > 0 && hfs->label_len < 28) {
191 volume_id_set_label_raw(id, hfs->label, hfs->label_len); 191// volume_id_set_label_raw(id, hfs->label, hfs->label_len);
192 volume_id_set_label_string(id, hfs->label, hfs->label_len) ; 192 volume_id_set_label_string(id, hfs->label, hfs->label_len) ;
193 } 193 }
194 194
195 volume_id_set_uuid(id, hfs->finder_info.id, UUID_HFS); 195 volume_id_set_uuid(id, hfs->finder_info.id, UUID_HFS);
196 196// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
197 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 197// id->type = "hfs";
198 id->type = "hfs";
199 198
200 return 0; 199 return 0;
201 200
@@ -281,12 +280,12 @@ int volume_id_probe_hfs_hfsplus(struct volume_id *id, uint64_t off)
281 280
282 label_len = be16_to_cpu(key->unicode_len) * 2; 281 label_len = be16_to_cpu(key->unicode_len) * 2;
283 dbg("label unicode16 len %i", label_len); 282 dbg("label unicode16 len %i", label_len);
284 volume_id_set_label_raw(id, key->unicode, label_len); 283// volume_id_set_label_raw(id, key->unicode, label_len);
285 volume_id_set_label_unicode16(id, key->unicode, BE, label_len); 284 volume_id_set_label_unicode16(id, key->unicode, BE, label_len);
286 285
287 found: 286 found:
288 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 287// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
289 id->type = "hfsplus"; 288// id->type = "hfsplus";
290 289
291 return 0; 290 return 0;
292} 291}
diff --git a/util-linux/volume_id/highpoint.c b/util-linux/volume_id/highpoint.c
index de31a2a26..57c5cadc4 100644
--- a/util-linux/volume_id/highpoint.c
+++ b/util-linux/volume_id/highpoint.c
@@ -52,8 +52,8 @@ int volume_id_probe_highpoint_37x_raid(struct volume_id *id, uint64_t off)
52 if (magic != cpu_to_le32(HPT37X_MAGIC_OK) && magic != cpu_to_le32(HPT37X_MAGIC_BAD)) 52 if (magic != cpu_to_le32(HPT37X_MAGIC_OK) && magic != cpu_to_le32(HPT37X_MAGIC_BAD))
53 return -1; 53 return -1;
54 54
55 volume_id_set_usage(id, VOLUME_ID_RAID); 55// volume_id_set_usage(id, VOLUME_ID_RAID);
56 id->type = "highpoint_raid_member"; 56// id->type = "highpoint_raid_member";
57 57
58 return 0; 58 return 0;
59} 59}
@@ -79,8 +79,8 @@ int volume_id_probe_highpoint_45x_raid(struct volume_id *id, uint64_t off, uint6
79 if (magic != cpu_to_le32(HPT45X_MAGIC_OK) && magic != cpu_to_le32(HPT45X_MAGIC_BAD)) 79 if (magic != cpu_to_le32(HPT45X_MAGIC_OK) && magic != cpu_to_le32(HPT45X_MAGIC_BAD))
80 return -1; 80 return -1;
81 81
82 volume_id_set_usage(id, VOLUME_ID_RAID); 82// volume_id_set_usage(id, VOLUME_ID_RAID);
83 id->type = "highpoint_raid_member"; 83// id->type = "highpoint_raid_member";
84 84
85 return 0; 85 return 0;
86} 86}
diff --git a/util-linux/volume_id/hpfs.c b/util-linux/volume_id/hpfs.c
index b43fb79b5..8b517569d 100644
--- a/util-linux/volume_id/hpfs.c
+++ b/util-linux/volume_id/hpfs.c
@@ -39,10 +39,9 @@ int volume_id_probe_hpfs(struct volume_id *id, uint64_t off)
39 return -1; 39 return -1;
40 40
41 if (memcmp(hs->magic, "\x49\xe8\x95\xf9", 4) == 0) { 41 if (memcmp(hs->magic, "\x49\xe8\x95\xf9", 4) == 0) {
42 sprintf(id->type_version, "%u", hs->version); 42// sprintf(id->type_version, "%u", hs->version);
43 43// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
44 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 44// id->type = "hpfs";
45 id->type = "hpfs";
46 return 0; 45 return 0;
47 } 46 }
48 47
diff --git a/util-linux/volume_id/iso9660.c b/util-linux/volume_id/iso9660.c
index fa9227746..c15608ce0 100644
--- a/util-linux/volume_id/iso9660.c
+++ b/util-linux/volume_id/iso9660.c
@@ -66,7 +66,7 @@ int volume_id_probe_iso9660(struct volume_id *id, uint64_t off)
66 int i; 66 int i;
67 67
68 dbg("read label from PVD"); 68 dbg("read label from PVD");
69 volume_id_set_label_raw(id, is->volume_id, 32); 69// volume_id_set_label_raw(id, is->volume_id, 32);
70 volume_id_set_label_string(id, is->volume_id, 32); 70 volume_id_set_label_string(id, is->volume_id, 32);
71 71
72 dbg("looking for SVDs"); 72 dbg("looking for SVDs");
@@ -81,9 +81,10 @@ int volume_id_probe_iso9660(struct volume_id *id, uint64_t off)
81 continue; 81 continue;
82 82
83 dbg("found SVD at offset 0x%llx", (unsigned long long) (off + vd_offset)); 83 dbg("found SVD at offset 0x%llx", (unsigned long long) (off + vd_offset));
84 if (memcmp(is->escape_sequences, "%/@", 3) == 0|| 84 if (memcmp(is->escape_sequences, "%/@", 3) == 0
85 memcmp(is->escape_sequences, "%/C", 3) == 0|| 85 || memcmp(is->escape_sequences, "%/C", 3) == 0
86 memcmp(is->escape_sequences, "%/E", 3) == 0) { 86 || memcmp(is->escape_sequences, "%/E", 3) == 0
87 ) {
87 dbg("Joliet extension found"); 88 dbg("Joliet extension found");
88 volume_id_set_unicode16((char *)svd_label, sizeof(svd_label), is->volume_id, BE, 32); 89 volume_id_set_unicode16((char *)svd_label, sizeof(svd_label), is->volume_id, BE, 32);
89 if (memcmp(id->label, svd_label, 16) == 0) { 90 if (memcmp(id->label, svd_label, 16) == 0) {
@@ -91,9 +92,9 @@ int volume_id_probe_iso9660(struct volume_id *id, uint64_t off)
91 break; 92 break;
92 } 93 }
93 94
94 volume_id_set_label_raw(id, is->volume_id, 32); 95// volume_id_set_label_raw(id, is->volume_id, 32);
95 volume_id_set_label_string(id, svd_label, 32); 96 volume_id_set_label_string(id, svd_label, 32);
96 strcpy(id->type_version, "Joliet Extension"); 97// strcpy(id->type_version, "Joliet Extension");
97 goto found; 98 goto found;
98 } 99 }
99 vd_offset += ISO_SECTOR_SIZE; 100 vd_offset += ISO_SECTOR_SIZE;
@@ -104,15 +105,15 @@ int volume_id_probe_iso9660(struct volume_id *id, uint64_t off)
104 hs = (struct high_sierra_volume_descriptor *) buf; 105 hs = (struct high_sierra_volume_descriptor *) buf;
105 106
106 if (memcmp(hs->id, "CDROM", 5) == 0) { 107 if (memcmp(hs->id, "CDROM", 5) == 0) {
107 strcpy(id->type_version, "High Sierra"); 108// strcpy(id->type_version, "High Sierra");
108 goto found; 109 goto found;
109 } 110 }
110 111
111 return -1; 112 return -1;
112 113
113 found: 114 found:
114 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 115// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
115 id->type = "iso9660"; 116// id->type = "iso9660";
116 117
117 return 0; 118 return 0;
118} 119}
diff --git a/util-linux/volume_id/isw_raid.c b/util-linux/volume_id/isw_raid.c
index 8f55f49d9..d928245fb 100644
--- a/util-linux/volume_id/isw_raid.c
+++ b/util-linux/volume_id/isw_raid.c
@@ -50,9 +50,9 @@ int volume_id_probe_intel_software_raid(struct volume_id *id, uint64_t off, uint
50 if (memcmp(isw->sig, ISW_SIGNATURE, sizeof(ISW_SIGNATURE)-1) != 0) 50 if (memcmp(isw->sig, ISW_SIGNATURE, sizeof(ISW_SIGNATURE)-1) != 0)
51 return -1; 51 return -1;
52 52
53 volume_id_set_usage(id, VOLUME_ID_RAID); 53// volume_id_set_usage(id, VOLUME_ID_RAID);
54 memcpy(id->type_version, &isw->sig[sizeof(ISW_SIGNATURE)-1], 6); 54// memcpy(id->type_version, &isw->sig[sizeof(ISW_SIGNATURE)-1], 6);
55 id->type = "isw_raid_member"; 55// id->type = "isw_raid_member";
56 56
57 return 0; 57 return 0;
58} 58}
diff --git a/util-linux/volume_id/jfs.c b/util-linux/volume_id/jfs.c
index 28b4eb694..63692f946 100644
--- a/util-linux/volume_id/jfs.c
+++ b/util-linux/volume_id/jfs.c
@@ -48,12 +48,12 @@ int volume_id_probe_jfs(struct volume_id *id, uint64_t off)
48 if (memcmp(js->magic, "JFS1", 4) != 0) 48 if (memcmp(js->magic, "JFS1", 4) != 0)
49 return -1; 49 return -1;
50 50
51 volume_id_set_label_raw(id, js->label, 16); 51// volume_id_set_label_raw(id, js->label, 16);
52 volume_id_set_label_string(id, js->label, 16); 52 volume_id_set_label_string(id, js->label, 16);
53 volume_id_set_uuid(id, js->uuid, UUID_DCE); 53 volume_id_set_uuid(id, js->uuid, UUID_DCE);
54 54
55 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 55// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
56 id->type = "jfs"; 56// id->type = "jfs";
57 57
58 return 0; 58 return 0;
59} 59}
diff --git a/util-linux/volume_id/linux_raid.c b/util-linux/volume_id/linux_raid.c
index bb9b3c5cf..a1130606f 100644
--- a/util-linux/volume_id/linux_raid.c
+++ b/util-linux/volume_id/linux_raid.c
@@ -66,14 +66,14 @@ int volume_id_probe_linux_raid(struct volume_id *id, uint64_t off, uint64_t size
66 memcpy(&uuid[4], &mdp->set_uuid1, 12); 66 memcpy(&uuid[4], &mdp->set_uuid1, 12);
67 volume_id_set_uuid(id, uuid, UUID_DCE); 67 volume_id_set_uuid(id, uuid, UUID_DCE);
68 68
69 snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u.%u", 69// snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u.%u",
70 le32_to_cpu(mdp->major_version), 70// le32_to_cpu(mdp->major_version),
71 le32_to_cpu(mdp->minor_version), 71// le32_to_cpu(mdp->minor_version),
72 le32_to_cpu(mdp->patch_version)); 72// le32_to_cpu(mdp->patch_version));
73 73
74 dbg("found raid signature"); 74 dbg("found raid signature");
75 volume_id_set_usage(id, VOLUME_ID_RAID); 75// volume_id_set_usage(id, VOLUME_ID_RAID);
76 id->type = "linux_raid_member"; 76// id->type = "linux_raid_member";
77 77
78 return 0; 78 return 0;
79} 79}
diff --git a/util-linux/volume_id/linux_swap.c b/util-linux/volume_id/linux_swap.c
index 56b5d5085..e6084542f 100644
--- a/util-linux/volume_id/linux_swap.c
+++ b/util-linux/volume_id/linux_swap.c
@@ -46,8 +46,8 @@ int volume_id_probe_linux_swap(struct volume_id *id, uint64_t off)
46 return -1; 46 return -1;
47 47
48 if (memcmp(buf, "SWAP-SPACE", 10) == 0) { 48 if (memcmp(buf, "SWAP-SPACE", 10) == 0) {
49 id->type_version[0] = '1'; 49// id->type_version[0] = '1';
50 id->type_version[1] = '\0'; 50// id->type_version[1] = '\0';
51 goto found; 51 goto found;
52 } 52 }
53 53
@@ -55,9 +55,9 @@ int volume_id_probe_linux_swap(struct volume_id *id, uint64_t off)
55 sw = volume_id_get_buffer(id, off, sizeof(struct swap_header_v1_2)); 55 sw = volume_id_get_buffer(id, off, sizeof(struct swap_header_v1_2));
56 if (sw == NULL) 56 if (sw == NULL)
57 return -1; 57 return -1;
58 id->type_version[0] = '2'; 58// id->type_version[0] = '2';
59 id->type_version[1] = '\0'; 59// id->type_version[1] = '\0';
60 volume_id_set_label_raw(id, sw->volume_name, 16); 60// volume_id_set_label_raw(id, sw->volume_name, 16);
61 volume_id_set_label_string(id, sw->volume_name, 16); 61 volume_id_set_label_string(id, sw->volume_name, 16);
62 volume_id_set_uuid(id, sw->uuid, UUID_DCE); 62 volume_id_set_uuid(id, sw->uuid, UUID_DCE);
63 goto found; 63 goto found;
@@ -66,8 +66,8 @@ int volume_id_probe_linux_swap(struct volume_id *id, uint64_t off)
66 return -1; 66 return -1;
67 67
68found: 68found:
69 volume_id_set_usage(id, VOLUME_ID_OTHER); 69// volume_id_set_usage(id, VOLUME_ID_OTHER);
70 id->type = "swap"; 70// id->type = "swap";
71 71
72 return 0; 72 return 0;
73} 73}
diff --git a/util-linux/volume_id/lsi_raid.c b/util-linux/volume_id/lsi_raid.c
index 0eab1c709..730a3134e 100644
--- a/util-linux/volume_id/lsi_raid.c
+++ b/util-linux/volume_id/lsi_raid.c
@@ -45,8 +45,8 @@ int volume_id_probe_lsi_mega_raid(struct volume_id *id, uint64_t off, uint64_t s
45 if (memcmp(lsi->sig, LSI_SIGNATURE, sizeof(LSI_SIGNATURE)-1) != 0) 45 if (memcmp(lsi->sig, LSI_SIGNATURE, sizeof(LSI_SIGNATURE)-1) != 0)
46 return -1; 46 return -1;
47 47
48 volume_id_set_usage(id, VOLUME_ID_RAID); 48// volume_id_set_usage(id, VOLUME_ID_RAID);
49 id->type = "lsi_mega_raid_member"; 49// id->type = "lsi_mega_raid_member";
50 50
51 return 0; 51 return 0;
52} 52}
diff --git a/util-linux/volume_id/luks.c b/util-linux/volume_id/luks.c
index e73ce3a03..51dda4e79 100644
--- a/util-linux/volume_id/luks.c
+++ b/util-linux/volume_id/luks.c
@@ -67,10 +67,9 @@ int volume_id_probe_luks(struct volume_id *id, uint64_t off)
67 if (memcmp(header->magic, LUKS_MAGIC, LUKS_MAGIC_L)) 67 if (memcmp(header->magic, LUKS_MAGIC, LUKS_MAGIC_L))
68 return -1; 68 return -1;
69 69
70 volume_id_set_usage(id, VOLUME_ID_CRYPTO); 70// volume_id_set_usage(id, VOLUME_ID_CRYPTO);
71 volume_id_set_uuid(id, header->uuid, UUID_DCE_STRING); 71 volume_id_set_uuid(id, header->uuid, UUID_DCE_STRING);
72 72// id->type = "crypto_LUKS";
73 id->type = "crypto_LUKS";
74 73
75 return 0; 74 return 0;
76} 75}
diff --git a/util-linux/volume_id/lvm.c b/util-linux/volume_id/lvm.c
index baa8456db..f9f9395db 100644
--- a/util-linux/volume_id/lvm.c
+++ b/util-linux/volume_id/lvm.c
@@ -33,7 +33,6 @@ struct lvm2_super_block {
33} __attribute__((packed)); 33} __attribute__((packed));
34 34
35#define LVM1_SB_OFF 0x400 35#define LVM1_SB_OFF 0x400
36#define LVM1_MAGIC "HM"
37 36
38int volume_id_probe_lvm1(struct volume_id *id, uint64_t off) 37int volume_id_probe_lvm1(struct volume_id *id, uint64_t off)
39{ 38{
@@ -48,11 +47,11 @@ int volume_id_probe_lvm1(struct volume_id *id, uint64_t off)
48 47
49 lvm = (struct lvm1_super_block *) buf; 48 lvm = (struct lvm1_super_block *) buf;
50 49
51 if (memcmp(lvm->id, LVM1_MAGIC, 2) != 0) 50 if (lvm->id[0] != 'H' || lvm->id[1] != 'M')
52 return -1; 51 return -1;
53 52
54 volume_id_set_usage(id, VOLUME_ID_RAID); 53// volume_id_set_usage(id, VOLUME_ID_RAID);
55 id->type = "LVM1_member"; 54// id->type = "LVM1_member";
56 55
57 return 0; 56 return 0;
58} 57}
@@ -83,9 +82,9 @@ int volume_id_probe_lvm2(struct volume_id *id, uint64_t off)
83 return -1; 82 return -1;
84 83
85 found: 84 found:
86 memcpy(id->type_version, lvm->type, 8); 85// memcpy(id->type_version, lvm->type, 8);
87 volume_id_set_usage(id, VOLUME_ID_RAID); 86// volume_id_set_usage(id, VOLUME_ID_RAID);
88 id->type = "LVM2_member"; 87// id->type = "LVM2_member";
89 88
90 return 0; 89 return 0;
91} 90}
diff --git a/util-linux/volume_id/minix.c b/util-linux/volume_id/minix.c
index ede23cb24..2f5209333 100644
--- a/util-linux/volume_id/minix.c
+++ b/util-linux/volume_id/minix.c
@@ -20,8 +20,7 @@
20 20
21#include "volume_id_internal.h" 21#include "volume_id_internal.h"
22 22
23struct minix_super_block 23struct minix_super_block {
24{
25 uint16_t s_ninodes; 24 uint16_t s_ninodes;
26 uint16_t s_nzones; 25 uint16_t s_nzones;
27 uint16_t s_imap_blocks; 26 uint16_t s_imap_blocks;
@@ -46,31 +45,31 @@ int volume_id_probe_minix(struct volume_id *id, uint64_t off)
46 if (ms == NULL) 45 if (ms == NULL)
47 return -1; 46 return -1;
48 47
49 if (le16_to_cpu(ms->s_magic) == 0x137f) { 48 if (ms->s_magic == cpu_to_le16(0x137f)) {
50 id->type_version[0] = '1'; 49// id->type_version[0] = '1';
51 goto found; 50 goto found;
52 } 51 }
53 52
54 if (le16_to_cpu(ms->s_magic) == 0x1387) { 53 if (ms->s_magic == cpu_to_le16(0x1387)) {
55 id->type_version[0] = '1'; 54// id->type_version[0] = '1';
56 goto found; 55 goto found;
57 } 56 }
58 57
59 if (le16_to_cpu(ms->s_magic) == 0x2468) { 58 if (ms->s_magic == cpu_to_le16(0x2468)) {
60 id->type_version[0] = '2'; 59// id->type_version[0] = '2';
61 goto found; 60 goto found;
62 } 61 }
63 62
64 if (le16_to_cpu(ms->s_magic) == 0x2478) { 63 if (ms->s_magic == cpu_to_le16(0x2478)) {
65 id->type_version[0] = '2'; 64// id->type_version[0] = '2';
66 goto found; 65 goto found;
67 } 66 }
68 67
69 return -1; 68 return -1;
70 69
71 found: 70 found:
72 id->type_version[1] = '\0'; 71// id->type_version[1] = '\0';
73 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 72// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
74 id->type = "minix"; 73// id->type = "minix";
75 return 0; 74 return 0;
76} 75}
diff --git a/util-linux/volume_id/ntfs.c b/util-linux/volume_id/ntfs.c
index cbd5d5bba..7488a41a3 100644
--- a/util-linux/volume_id/ntfs.c
+++ b/util-linux/volume_id/ntfs.c
@@ -166,13 +166,13 @@ int volume_id_probe_ntfs(struct volume_id *id, uint64_t off)
166 dbg("found attribute type 0x%x, len %i, at offset %i", 166 dbg("found attribute type 0x%x, len %i, at offset %i",
167 attr_type, attr_len, attr_off); 167 attr_type, attr_len, attr_off);
168 168
169 if (attr_type == MFT_RECORD_ATTR_VOLUME_INFO) { 169// if (attr_type == MFT_RECORD_ATTR_VOLUME_INFO) {
170 struct volume_info *info; 170// struct volume_info *info;
171 dbg("found info, len %i", val_len); 171// dbg("found info, len %i", val_len);
172 info = (struct volume_info*) (((uint8_t *) attr) + val_off); 172// info = (struct volume_info*) (((uint8_t *) attr) + val_off);
173 snprintf(id->type_version, sizeof(id->type_version)-1, 173// snprintf(id->type_version, sizeof(id->type_version)-1,
174 "%u.%u", info->major_ver, info->minor_ver); 174// "%u.%u", info->major_ver, info->minor_ver);
175 } 175// }
176 176
177 if (attr_type == MFT_RECORD_ATTR_VOLUME_NAME) { 177 if (attr_type == MFT_RECORD_ATTR_VOLUME_NAME) {
178 dbg("found label, len %i", val_len); 178 dbg("found label, len %i", val_len);
@@ -180,14 +180,14 @@ int volume_id_probe_ntfs(struct volume_id *id, uint64_t off)
180 val_len = VOLUME_ID_LABEL_SIZE; 180 val_len = VOLUME_ID_LABEL_SIZE;
181 181
182 val = ((uint8_t *) attr) + val_off; 182 val = ((uint8_t *) attr) + val_off;
183 volume_id_set_label_raw(id, val, val_len); 183// volume_id_set_label_raw(id, val, val_len);
184 volume_id_set_label_unicode16(id, val, LE, val_len); 184 volume_id_set_label_unicode16(id, val, LE, val_len);
185 } 185 }
186 } 186 }
187 187
188 found: 188 found:
189 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 189// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
190 id->type = "ntfs"; 190// id->type = "ntfs";
191 191
192 return 0; 192 return 0;
193} 193}
diff --git a/util-linux/volume_id/nvidia_raid.c b/util-linux/volume_id/nvidia_raid.c
index 8619565c9..692aad111 100644
--- a/util-linux/volume_id/nvidia_raid.c
+++ b/util-linux/volume_id/nvidia_raid.c
@@ -48,9 +48,9 @@ int volume_id_probe_nvidia_raid(struct volume_id *id, uint64_t off, uint64_t siz
48 if (memcmp(nv->vendor, NVIDIA_SIGNATURE, sizeof(NVIDIA_SIGNATURE)-1) != 0) 48 if (memcmp(nv->vendor, NVIDIA_SIGNATURE, sizeof(NVIDIA_SIGNATURE)-1) != 0)
49 return -1; 49 return -1;
50 50
51 volume_id_set_usage(id, VOLUME_ID_RAID); 51// volume_id_set_usage(id, VOLUME_ID_RAID);
52 snprintf(id->type_version, sizeof(id->type_version)-1, "%u", le16_to_cpu(nv->version)); 52// snprintf(id->type_version, sizeof(id->type_version)-1, "%u", le16_to_cpu(nv->version));
53 id->type = "nvidia_raid_member"; 53// id->type = "nvidia_raid_member";
54 54
55 return 0; 55 return 0;
56} 56}
diff --git a/util-linux/volume_id/ocfs2.c b/util-linux/volume_id/ocfs2.c
index bc490df57..9fd456597 100644
--- a/util-linux/volume_id/ocfs2.c
+++ b/util-linux/volume_id/ocfs2.c
@@ -94,12 +94,12 @@ int volume_id_probe_ocfs2(struct volume_id *id, uint64_t off)
94 return -1; 94 return -1;
95 } 95 }
96 96
97 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 97// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
98 volume_id_set_label_raw(id, os->s_label, OCFS2_MAX_VOL_LABEL_LEN < VOLUME_ID_LABEL_SIZE ? 98// volume_id_set_label_raw(id, os->s_label, OCFS2_MAX_VOL_LABEL_LEN < VOLUME_ID_LABEL_SIZE ?
99 OCFS2_MAX_VOL_LABEL_LEN : VOLUME_ID_LABEL_SIZE); 99// OCFS2_MAX_VOL_LABEL_LEN : VOLUME_ID_LABEL_SIZE);
100 volume_id_set_label_string(id, os->s_label, OCFS2_MAX_VOL_LABEL_LEN < VOLUME_ID_LABEL_SIZE ? 100 volume_id_set_label_string(id, os->s_label, OCFS2_MAX_VOL_LABEL_LEN < VOLUME_ID_LABEL_SIZE ?
101 OCFS2_MAX_VOL_LABEL_LEN : VOLUME_ID_LABEL_SIZE); 101 OCFS2_MAX_VOL_LABEL_LEN : VOLUME_ID_LABEL_SIZE);
102 volume_id_set_uuid(id, os->s_uuid, UUID_DCE); 102 volume_id_set_uuid(id, os->s_uuid, UUID_DCE);
103 id->type = "ocfs2"; 103// id->type = "ocfs2";
104 return 0; 104 return 0;
105} 105}
diff --git a/util-linux/volume_id/promise_raid.c b/util-linux/volume_id/promise_raid.c
index 9195c637b..75c6f89d4 100644
--- a/util-linux/volume_id/promise_raid.c
+++ b/util-linux/volume_id/promise_raid.c
@@ -56,8 +56,8 @@ int volume_id_probe_promise_fasttrack_raid(struct volume_id *id, uint64_t off, u
56 return -1; 56 return -1;
57 57
58 found: 58 found:
59 volume_id_set_usage(id, VOLUME_ID_RAID); 59// volume_id_set_usage(id, VOLUME_ID_RAID);
60 id->type = "promise_fasttrack_raid_member"; 60// id->type = "promise_fasttrack_raid_member";
61 61
62 return 0; 62 return 0;
63} 63}
diff --git a/util-linux/volume_id/reiserfs.c b/util-linux/volume_id/reiserfs.c
index 98ecec23a..d9a37457b 100644
--- a/util-linux/volume_id/reiserfs.c
+++ b/util-linux/volume_id/reiserfs.c
@@ -53,31 +53,35 @@ int volume_id_probe_reiserfs(struct volume_id *id, uint64_t off)
53 struct reiserfs_super_block *rs; 53 struct reiserfs_super_block *rs;
54 struct reiser4_super_block *rs4; 54 struct reiser4_super_block *rs4;
55 55
56 dbg("probing at offset 0x%llx", (unsigned long long) off); 56 dbg("reiserfs: probing at offset 0x%llx", (unsigned long long) off);
57 57
58 rs = volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200); 58 rs = volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200);
59 if (rs == NULL) 59 if (rs == NULL)
60 return -1; 60 return -1;
61 61
62 if (memcmp(rs->magic, "ReIsErFs", 8) == 0) { 62 if (memcmp(rs->magic, "ReIsErFs", 8) == 0) {
63 strcpy(id->type_version, "3.5"); 63 dbg("reiserfs: ReIsErFs, no label");
64// strcpy(id->type_version, "3.5");
64 goto found; 65 goto found;
65 } 66 }
66 if (memcmp(rs->magic, "ReIsEr2Fs", 9) == 0) { 67 if (memcmp(rs->magic, "ReIsEr2Fs", 9) == 0) {
67 strcpy(id->type_version, "3.6"); 68 dbg("reiserfs: ReIsEr2Fs");
69// strcpy(id->type_version, "3.6");
68 goto found_label; 70 goto found_label;
69 } 71 }
70 if (memcmp(rs->magic, "ReIsEr3Fs", 9) == 0) { 72 if (memcmp(rs->magic, "ReIsEr3Fs", 9) == 0) {
71 strcpy(id->type_version, "JR"); 73 dbg("reiserfs: ReIsEr3Fs");
74// strcpy(id->type_version, "JR");
72 goto found_label; 75 goto found_label;
73 } 76 }
74 77
75 rs4 = (struct reiser4_super_block *) rs; 78 rs4 = (struct reiser4_super_block *) rs;
76 if (memcmp(rs4->magic, "ReIsEr4", 7) == 0) { 79 if (memcmp(rs4->magic, "ReIsEr4", 7) == 0) {
77 strcpy(id->type_version, "4"); 80// strcpy(id->type_version, "4");
78 volume_id_set_label_raw(id, rs4->label, 16); 81// volume_id_set_label_raw(id, rs4->label, 16);
79 volume_id_set_label_string(id, rs4->label, 16); 82 volume_id_set_label_string(id, rs4->label, 16);
80 volume_id_set_uuid(id, rs4->uuid, UUID_DCE); 83 volume_id_set_uuid(id, rs4->uuid, UUID_DCE);
84 dbg("reiserfs: ReIsEr4, label '%s' uuid '%s'", id->label, id->uuid);
81 goto found; 85 goto found;
82 } 86 }
83 87
@@ -86,20 +90,23 @@ int volume_id_probe_reiserfs(struct volume_id *id, uint64_t off)
86 return -1; 90 return -1;
87 91
88 if (memcmp(rs->magic, "ReIsErFs", 8) == 0) { 92 if (memcmp(rs->magic, "ReIsErFs", 8) == 0) {
89 strcpy(id->type_version, "3.5"); 93 dbg("reiserfs: ReIsErFs, no label");
94// strcpy(id->type_version, "3.5");
90 goto found; 95 goto found;
91 } 96 }
92 97
98 dbg("reiserfs: no signature found");
93 return -1; 99 return -1;
94 100
95 found_label: 101 found_label:
96 volume_id_set_label_raw(id, rs->label, 16); 102// volume_id_set_label_raw(id, rs->label, 16);
97 volume_id_set_label_string(id, rs->label, 16); 103 volume_id_set_label_string(id, rs->label, 16);
98 volume_id_set_uuid(id, rs->uuid, UUID_DCE); 104 volume_id_set_uuid(id, rs->uuid, UUID_DCE);
105 dbg("reiserfs: label '%s' uuid '%s'", id->label, id->uuid);
99 106
100 found: 107 found:
101 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 108// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
102 id->type = "reiserfs"; 109// id->type = "reiserfs";
103 110
104 return 0; 111 return 0;
105} 112}
diff --git a/util-linux/volume_id/romfs.c b/util-linux/volume_id/romfs.c
index 7c4fc0f70..400bdce2c 100644
--- a/util-linux/volume_id/romfs.c
+++ b/util-linux/volume_id/romfs.c
@@ -41,12 +41,12 @@ int volume_id_probe_romfs(struct volume_id *id, uint64_t off)
41 size_t len = strlen((char *)rfs->name); 41 size_t len = strlen((char *)rfs->name);
42 42
43 if (len) { 43 if (len) {
44 volume_id_set_label_raw(id, rfs->name, len); 44// volume_id_set_label_raw(id, rfs->name, len);
45 volume_id_set_label_string(id, rfs->name, len); 45 volume_id_set_label_string(id, rfs->name, len);
46 } 46 }
47 47
48 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 48// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
49 id->type = "romfs"; 49// id->type = "romfs";
50 return 0; 50 return 0;
51 } 51 }
52 52
diff --git a/util-linux/volume_id/silicon_raid.c b/util-linux/volume_id/silicon_raid.c
index ea001745f..51431124b 100644
--- a/util-linux/volume_id/silicon_raid.c
+++ b/util-linux/volume_id/silicon_raid.c
@@ -60,10 +60,10 @@ int volume_id_probe_silicon_medley_raid(struct volume_id *id, uint64_t off, uint
60 if (sil->magic != cpu_to_le32(SILICON_MAGIC)) 60 if (sil->magic != cpu_to_le32(SILICON_MAGIC))
61 return -1; 61 return -1;
62 62
63 volume_id_set_usage(id, VOLUME_ID_RAID); 63// volume_id_set_usage(id, VOLUME_ID_RAID);
64 snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u", 64// snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u",
65 le16_to_cpu(sil->major_ver), le16_to_cpu(sil->minor_ver)); 65// le16_to_cpu(sil->major_ver), le16_to_cpu(sil->minor_ver));
66 id->type = "silicon_medley_raid_member"; 66// id->type = "silicon_medley_raid_member";
67 67
68 return 0; 68 return 0;
69} 69}
diff --git a/util-linux/volume_id/sysv.c b/util-linux/volume_id/sysv.c
index 71c0fd496..76719623b 100644
--- a/util-linux/volume_id/sysv.c
+++ b/util-linux/volume_id/sysv.c
@@ -97,9 +97,9 @@ int volume_id_probe_sysv(struct volume_id *id, uint64_t off)
97 return -1; 97 return -1;
98 98
99 if (vs->s_magic == cpu_to_le32(SYSV_MAGIC) || vs->s_magic == cpu_to_be32(SYSV_MAGIC)) { 99 if (vs->s_magic == cpu_to_le32(SYSV_MAGIC) || vs->s_magic == cpu_to_be32(SYSV_MAGIC)) {
100 volume_id_set_label_raw(id, vs->s_fname, 6); 100// volume_id_set_label_raw(id, vs->s_fname, 6);
101 volume_id_set_label_string(id, vs->s_fname, 6); 101 volume_id_set_label_string(id, vs->s_fname, 6);
102 id->type = "sysv"; 102// id->type = "sysv";
103 goto found; 103 goto found;
104 } 104 }
105 } 105 }
@@ -110,9 +110,9 @@ int volume_id_probe_sysv(struct volume_id *id, uint64_t off)
110 return -1; 110 return -1;
111 111
112 if (xs->s_magic == cpu_to_le32(XENIX_MAGIC) || xs->s_magic == cpu_to_be32(XENIX_MAGIC)) { 112 if (xs->s_magic == cpu_to_le32(XENIX_MAGIC) || xs->s_magic == cpu_to_be32(XENIX_MAGIC)) {
113 volume_id_set_label_raw(id, xs->s_fname, 6); 113// volume_id_set_label_raw(id, xs->s_fname, 6);
114 volume_id_set_label_string(id, xs->s_fname, 6); 114 volume_id_set_label_string(id, xs->s_fname, 6);
115 id->type = "xenix"; 115// id->type = "xenix";
116 goto found; 116 goto found;
117 } 117 }
118 } 118 }
@@ -120,6 +120,6 @@ int volume_id_probe_sysv(struct volume_id *id, uint64_t off)
120 return -1; 120 return -1;
121 121
122 found: 122 found:
123 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 123// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
124 return 0; 124 return 0;
125} 125}
diff --git a/util-linux/volume_id/udf.c b/util-linux/volume_id/udf.c
index 5cdb49c31..55e97a7e5 100644
--- a/util-linux/volume_id/udf.c
+++ b/util-linux/volume_id/udf.c
@@ -155,7 +155,7 @@ anchor:
155 goto found; 155 goto found;
156 156
157 pvd: 157 pvd:
158 volume_id_set_label_raw(id, &(vd->type.primary.ident.clen), 32); 158// volume_id_set_label_raw(id, &(vd->type.primary.ident.clen), 32);
159 159
160 clen = vd->type.primary.ident.clen; 160 clen = vd->type.primary.ident.clen;
161 dbg("label string charsize=%i bit", clen); 161 dbg("label string charsize=%i bit", clen);
@@ -165,8 +165,8 @@ anchor:
165 volume_id_set_label_unicode16(id, vd->type.primary.ident.c, BE, 31); 165 volume_id_set_label_unicode16(id, vd->type.primary.ident.c, BE, 31);
166 166
167 found: 167 found:
168 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 168// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
169 id->type = "udf"; 169// id->type = "udf";
170 170
171 return 0; 171 return 0;
172} 172}
diff --git a/util-linux/volume_id/ufs.c b/util-linux/volume_id/ufs.c
index 768670e9d..ba76876b5 100644
--- a/util-linux/volume_id/ufs.c
+++ b/util-linux/volume_id/ufs.c
@@ -199,8 +199,8 @@ int volume_id_probe_ufs(struct volume_id *id, uint64_t off)
199 return -1; 199 return -1;
200 200
201 found: 201 found:
202 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 202// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
203 id->type = "ufs"; 203// id->type = "ufs";
204 204
205 return 0; 205 return 0;
206} 206}
diff --git a/util-linux/volume_id/util.c b/util-linux/volume_id/util.c
index d2265c249..ce7de23fb 100644
--- a/util-linux/volume_id/util.c
+++ b/util-linux/volume_id/util.c
@@ -23,7 +23,7 @@
23void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count) 23void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count)
24{ 24{
25 unsigned i, j; 25 unsigned i, j;
26 uint16_t c; 26 unsigned c;
27 27
28 j = 0; 28 j = 0;
29 for (i = 0; i + 2 <= count; i += 2) { 29 for (i = 0; i + 2 <= count; i += 2) {
@@ -54,6 +54,7 @@ void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum end
54 str[j] = '\0'; 54 str[j] = '\0';
55} 55}
56 56
57#ifdef UNUSED
57static const char *usage_to_string(enum volume_id_usage usage_id) 58static const char *usage_to_string(enum volume_id_usage usage_id)
58{ 59{
59 switch (usage_id) { 60 switch (usage_id) {
@@ -94,6 +95,7 @@ void volume_id_set_label_raw(struct volume_id *id, const uint8_t *buf, size_t co
94 memcpy(id->label_raw, buf, count); 95 memcpy(id->label_raw, buf, count);
95 id->label_raw_len = count; 96 id->label_raw_len = count;
96} 97}
98#endif
97 99
98#ifdef NOT_NEEDED 100#ifdef NOT_NEEDED
99static size_t strnlen(const char *s, size_t maxlen) 101static size_t strnlen(const char *s, size_t maxlen)
@@ -131,7 +133,7 @@ void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_form
131 unsigned i; 133 unsigned i;
132 unsigned count = 0; 134 unsigned count = 0;
133 135
134 switch(format) { 136 switch (format) {
135 case UUID_DOS: 137 case UUID_DOS:
136 count = 4; 138 count = 4;
137 break; 139 break;
@@ -143,20 +145,21 @@ void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_form
143 count = 16; 145 count = 16;
144 break; 146 break;
145 case UUID_DCE_STRING: 147 case UUID_DCE_STRING:
146 count = 36; 148 /* 36 is ok, id->uuid has one extra byte for NUL */
149 count = VOLUME_ID_UUID_SIZE;
147 break; 150 break;
148 } 151 }
149 memcpy(id->uuid_raw, buf, count); 152// memcpy(id->uuid_raw, buf, count);
150 id->uuid_raw_len = count; 153// id->uuid_raw_len = count;
151 154
152 /* if set, create string in the same format, the native platform uses */ 155 /* if set, create string in the same format, the native platform uses */
153 for (i = 0; i < count; i++) 156 for (i = 0; i < count; i++)
154 if (buf[i] != 0) 157 if (buf[i] != 0)
155 goto set; 158 goto set;
156 return; 159 return; /* all bytes are zero, leave it empty ("") */
157 160
158set: 161set:
159 switch(format) { 162 switch (format) {
160 case UUID_DOS: 163 case UUID_DOS:
161 sprintf(id->uuid, "%02X%02X-%02X%02X", 164 sprintf(id->uuid, "%02X%02X-%02X%02X",
162 buf[3], buf[2], buf[1], buf[0]); 165 buf[3], buf[2], buf[1], buf[0]);
diff --git a/util-linux/volume_id/via_raid.c b/util-linux/volume_id/via_raid.c
index a9bd5b7b9..a3e94e085 100644
--- a/util-linux/volume_id/via_raid.c
+++ b/util-linux/volume_id/via_raid.c
@@ -59,10 +59,10 @@ int volume_id_probe_via_raid(struct volume_id *id, uint64_t off, uint64_t size)
59 if (via->version_number > 1) 59 if (via->version_number > 1)
60 return -1; 60 return -1;
61 61
62 volume_id_set_usage(id, VOLUME_ID_RAID); 62// volume_id_set_usage(id, VOLUME_ID_RAID);
63 id->type_version[0] = '0' + via->version_number; 63// id->type_version[0] = '0' + via->version_number;
64 id->type_version[1] = '\0'; 64// id->type_version[1] = '\0';
65 id->type = "via_raid_member"; 65// id->type = "via_raid_member";
66 66
67 return 0; 67 return 0;
68} 68}
diff --git a/util-linux/volume_id/volume_id.c b/util-linux/volume_id/volume_id.c
index 809884a41..a26e2bcf0 100644
--- a/util-linux/volume_id/volume_id.c
+++ b/util-linux/volume_id/volume_id.c
@@ -68,9 +68,10 @@ static const probe_fptr fs1[] = {
68#if ENABLE_FEATURE_VOLUMEID_FAT 68#if ENABLE_FEATURE_VOLUMEID_FAT
69 volume_id_probe_vfat, 69 volume_id_probe_vfat,
70#endif 70#endif
71#if ENABLE_FEATURE_VOLUMEID_MAC 71// This one only looks for partitions, we don't use it
72 volume_id_probe_mac_partition_map, 72//#if ENABLE_FEATURE_VOLUMEID_MAC
73#endif 73// volume_id_probe_mac_partition_map,
74//#endif
74#if ENABLE_FEATURE_VOLUMEID_XFS 75#if ENABLE_FEATURE_VOLUMEID_XFS
75 volume_id_probe_xfs, 76 volume_id_probe_xfs,
76#endif 77#endif
@@ -170,7 +171,9 @@ struct volume_id *volume_id_open_node(const char *path)
170 struct volume_id *id; 171 struct volume_id *id;
171 int fd; 172 int fd;
172 173
173 fd = xopen(path, O_RDONLY); 174 fd = open(path, O_RDONLY);
175 if (fd < 0)
176 return NULL;
174 id = xzalloc(sizeof(struct volume_id)); 177 id = xzalloc(sizeof(struct volume_id));
175 id->fd = fd; 178 id->fd = fd;
176 ///* close fd on device close */ 179 ///* close fd on device close */
@@ -209,6 +212,8 @@ void free_volume_id(struct volume_id *id)
209 //if (id->fd_close != 0) - always true 212 //if (id->fd_close != 0) - always true
210 close(id->fd); 213 close(id->fd);
211 volume_id_free_buffer(id); 214 volume_id_free_buffer(id);
215#ifdef UNUSED_PARTITION_CODE
212 free(id->partitions); 216 free(id->partitions);
217#endif
213 free(id); 218 free(id);
214} 219}
diff --git a/util-linux/volume_id/volume_id_internal.h b/util-linux/volume_id/volume_id_internal.h
index 5a38562f4..8c7ca035a 100644
--- a/util-linux/volume_id/volume_id_internal.h
+++ b/util-linux/volume_id/volume_id_internal.h
@@ -23,6 +23,7 @@
23 23
24 24
25#define dbg(...) ((void)0) 25#define dbg(...) ((void)0)
26/* #define dbg(...) bb_error_msg(__VA_ARGS__) */
26 27
27 28
28/* volume_id.h */ 29/* volume_id.h */
@@ -45,29 +46,34 @@ enum volume_id_usage {
45 VOLUME_ID_CRYPTO, 46 VOLUME_ID_CRYPTO,
46}; 47};
47 48
49#ifdef UNUSED_PARTITION_CODE
48struct volume_id_partition { 50struct volume_id_partition {
49 enum volume_id_usage usage_id; 51// const char *type;
50 const char *usage; 52// const char *usage;
51 const char *type; 53// smallint usage_id;
52 uint64_t off; 54// uint8_t pt_type_raw;
53 uint64_t len; 55// uint64_t pt_off;
54 uint8_t partition_type_raw; 56// uint64_t pt_len;
55}; 57};
58#endif
56 59
57struct volume_id { 60struct volume_id {
58 uint8_t label_raw[VOLUME_ID_LABEL_SIZE]; 61// uint8_t label_raw[VOLUME_ID_LABEL_SIZE];
59 size_t label_raw_len; 62// size_t label_raw_len;
60 char label[VOLUME_ID_LABEL_SIZE+1]; 63 char label[VOLUME_ID_LABEL_SIZE+1];
61 uint8_t uuid_raw[VOLUME_ID_UUID_SIZE]; 64// uint8_t uuid_raw[VOLUME_ID_UUID_SIZE];
62 size_t uuid_raw_len; 65// size_t uuid_raw_len;
66 /* uuid is stored in ASCII (not binary) form here: */
63 char uuid[VOLUME_ID_UUID_SIZE+1]; 67 char uuid[VOLUME_ID_UUID_SIZE+1];
64 enum volume_id_usage usage_id; 68// char type_version[VOLUME_ID_FORMAT_SIZE];
65 const char *usage; 69// smallint usage_id;
66 const char *type; 70// const char *usage;
67 char type_version[VOLUME_ID_FORMAT_SIZE]; 71// const char *type;
68 72
73#ifdef UNUSED_PARTITION_CODE
69 struct volume_id_partition *partitions; 74 struct volume_id_partition *partitions;
70 size_t partition_count; 75 size_t partition_count;
76#endif
71 77
72 int fd; 78 int fd;
73 uint8_t *sbbuf; 79 uint8_t *sbbuf;
@@ -143,9 +149,9 @@ enum endian {
143}; 149};
144 150
145void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count); 151void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count);
146void volume_id_set_usage(struct volume_id *id, enum volume_id_usage usage_id); 152//void volume_id_set_usage(struct volume_id *id, enum volume_id_usage usage_id);
147void volume_id_set_usage_part(struct volume_id_partition *part, enum volume_id_usage usage_id); 153//void volume_id_set_usage_part(struct volume_id_partition *part, enum volume_id_usage usage_id);
148void volume_id_set_label_raw(struct volume_id *id, const uint8_t *buf, size_t count); 154//void volume_id_set_label_raw(struct volume_id *id, const uint8_t *buf, size_t count);
149void volume_id_set_label_string(struct volume_id *id, const uint8_t *buf, size_t count); 155void volume_id_set_label_string(struct volume_id *id, const uint8_t *buf, size_t count);
150void volume_id_set_label_unicode16(struct volume_id *id, const uint8_t *buf, enum endian endianess, size_t count); 156void volume_id_set_label_unicode16(struct volume_id *id, const uint8_t *buf, enum endian endianess, size_t count);
151void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_format format); 157void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_format format);
@@ -197,11 +203,11 @@ int volume_id_probe_linux_swap(struct volume_id *id, uint64_t off);
197 203
198int volume_id_probe_luks(struct volume_id *id, uint64_t off); 204int volume_id_probe_luks(struct volume_id *id, uint64_t off);
199 205
200int volume_id_probe_mac_partition_map(struct volume_id *id, uint64_t off); 206//int volume_id_probe_mac_partition_map(struct volume_id *id, uint64_t off);
201 207
202int volume_id_probe_minix(struct volume_id *id, uint64_t off); 208int volume_id_probe_minix(struct volume_id *id, uint64_t off);
203 209
204int volume_id_probe_msdos_part_table(struct volume_id *id, uint64_t off); 210//int volume_id_probe_msdos_part_table(struct volume_id *id, uint64_t off);
205 211
206int volume_id_probe_ntfs(struct volume_id *id, uint64_t off); 212int volume_id_probe_ntfs(struct volume_id *id, uint64_t off);
207 213
diff --git a/util-linux/volume_id/xfs.c b/util-linux/volume_id/xfs.c
index 343ac7015..0d904370d 100644
--- a/util-linux/volume_id/xfs.c
+++ b/util-linux/volume_id/xfs.c
@@ -48,12 +48,12 @@ int volume_id_probe_xfs(struct volume_id *id, uint64_t off)
48 if (memcmp(xs->magic, "XFSB", 4) != 0) 48 if (memcmp(xs->magic, "XFSB", 4) != 0)
49 return -1; 49 return -1;
50 50
51 volume_id_set_label_raw(id, xs->fname, 12); 51// volume_id_set_label_raw(id, xs->fname, 12);
52 volume_id_set_label_string(id, xs->fname, 12); 52 volume_id_set_label_string(id, xs->fname, 12);
53 volume_id_set_uuid(id, xs->uuid, UUID_DCE); 53 volume_id_set_uuid(id, xs->uuid, UUID_DCE);
54 54
55 volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 55// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
56 id->type = "xfs"; 56// id->type = "xfs";
57 57
58 return 0; 58 return 0;
59} 59}