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
This commit is contained in:
Denis Vlasenko 2008-03-17 09:21:26 +00:00
parent 592d4fe772
commit c5b737231d
37 changed files with 364 additions and 326 deletions

View File

@ -510,8 +510,6 @@ CONFIG_FEATURE_VOLUMEID_HPFS=y
CONFIG_FEATURE_VOLUMEID_ROMFS=y CONFIG_FEATURE_VOLUMEID_ROMFS=y
CONFIG_FEATURE_VOLUMEID_SYSV=y CONFIG_FEATURE_VOLUMEID_SYSV=y
CONFIG_FEATURE_VOLUMEID_MINIX=y CONFIG_FEATURE_VOLUMEID_MINIX=y
CONFIG_FEATURE_VOLUMEID_MAC=y
CONFIG_FEATURE_VOLUMEID_MSDOS=y
CONFIG_FEATURE_VOLUMEID_OCFS2=y CONFIG_FEATURE_VOLUMEID_OCFS2=y
CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID=y CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID=y
CONFIG_FEATURE_VOLUMEID_ISWRAID=y CONFIG_FEATURE_VOLUMEID_ISWRAID=y

View File

@ -155,7 +155,7 @@ USE_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_FETCHMAIL(APPLET_ODDNAME(fetchmail, sendgetmail, _BB_DIR_USR_BIN, _BB_SUID_NEVER, fetchmail)) USE_FETCHMAIL(APPLET_ODDNAME(fetchmail, sendgetmail, _BB_DIR_USR_BIN, _BB_SUID_NEVER, fetchmail))
USE_FEATURE_GREP_FGREP_ALIAS(APPLET_NOUSAGE(fgrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_FEATURE_GREP_FGREP_ALIAS(APPLET_NOUSAGE(fgrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_NEVER, find)) USE_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_NEVER, find))
//USE_FINDFS(APPLET_NOUSAGE(findfs, tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_FINDFS(APPLET(findfs, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_FOLD(APPLET(fold, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_FOLD(APPLET(fold, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_FREE(APPLET(free, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_FREE(APPLET(free, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_FREERAMDISK(APPLET(freeramdisk, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_FREERAMDISK(APPLET(freeramdisk, _BB_DIR_SBIN, _BB_SUID_NEVER))

View File

@ -506,8 +506,6 @@ CONFIG_FEATURE_USE_TERMIOS=y
# CONFIG_FEATURE_VOLUMEID_ROMFS is not set # CONFIG_FEATURE_VOLUMEID_ROMFS is not set
# CONFIG_FEATURE_VOLUMEID_SYSV is not set # CONFIG_FEATURE_VOLUMEID_SYSV is not set
# CONFIG_FEATURE_VOLUMEID_MINIX is not set # CONFIG_FEATURE_VOLUMEID_MINIX is not set
# CONFIG_FEATURE_VOLUMEID_MAC is not set
# CONFIG_FEATURE_VOLUMEID_MSDOS is not set
# CONFIG_FEATURE_VOLUMEID_OCFS2 is not set # CONFIG_FEATURE_VOLUMEID_OCFS2 is not set
# CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID is not set # CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID is not set
# CONFIG_FEATURE_VOLUMEID_ISWRAID is not set # CONFIG_FEATURE_VOLUMEID_ISWRAID is not set

View File

@ -159,7 +159,7 @@ config FINDFS
package. However, the e2fsprogs version only support ext2/3. This package. However, the e2fsprogs version only support ext2/3. This
version supports those in addition to FAT, swap, and ReiserFS. version supports those in addition to FAT, swap, and ReiserFS.
WARNING: WARNING:
With all submodules selected, it will add ~11k to busybox. With all submodules selected, it will add ~9k to busybox.
config FREERAMDISK config FREERAMDISK
bool "freeramdisk" bool "freeramdisk"
@ -518,19 +518,20 @@ config FEATURE_VOLUMEID_MINIX
help help
TODO TODO
config FEATURE_VOLUMEID_MAC ### These only detect partition tables - not used (yet?)
bool "mac filesystem" ### config FEATURE_VOLUMEID_MAC
default n ### bool "mac filesystem"
depends on VOLUMEID ### default n
help ### depends on VOLUMEID
TODO ### help
### TODO
config FEATURE_VOLUMEID_MSDOS ###
bool "msdos filesystem" ### config FEATURE_VOLUMEID_MSDOS
default n ### bool "msdos filesystem"
depends on VOLUMEID ### default n
help ### depends on VOLUMEID
TODO ### help
### TODO
config FEATURE_VOLUMEID_OCFS2 config FEATURE_VOLUMEID_OCFS2
bool "ocfs2 filesystem" bool "ocfs2 filesystem"
@ -638,7 +639,6 @@ config FEATURE_MOUNT_LABEL
bool "Support specifiying devices by label or UUID" bool "Support specifiying devices by label or UUID"
default n default n
depends on MOUNT depends on MOUNT
select FINDFS
help help
This allows for specifying a device by label or uuid, rather than by This allows for specifying a device by label or uuid, rather than by
name. This feature utilizes the same functionality as findfs. name. This feature utilizes the same functionality as findfs.

View File

@ -5,31 +5,31 @@
# Licensed under the GPL v2, see the file LICENSE in this tarball. # Licensed under the GPL v2, see the file LICENSE in this tarball.
lib-y:= lib-y:=
lib-$(CONFIG_DMESG) +=dmesg.o lib-$(CONFIG_DMESG) += dmesg.o
lib-$(CONFIG_FBSET) +=fbset.o lib-$(CONFIG_FBSET) += fbset.o
lib-$(CONFIG_FDFLUSH) +=freeramdisk.o lib-$(CONFIG_FDFLUSH) += freeramdisk.o
lib-$(CONFIG_FDFORMAT) +=fdformat.o lib-$(CONFIG_FDFORMAT) += fdformat.o
lib-$(CONFIG_FDISK) +=fdisk.o lib-$(CONFIG_FDISK) += fdisk.o
lib-$(CONFIG_FINDFS) +=findfs.o lib-$(CONFIG_FINDFS) += findfs.o
lib-$(CONFIG_FREERAMDISK) +=freeramdisk.o lib-$(CONFIG_FREERAMDISK) += freeramdisk.o
lib-$(CONFIG_FSCK_MINIX) +=fsck_minix.o lib-$(CONFIG_FSCK_MINIX) += fsck_minix.o
lib-$(CONFIG_GETOPT) +=getopt.o lib-$(CONFIG_GETOPT) += getopt.o
lib-$(CONFIG_HEXDUMP) +=hexdump.o lib-$(CONFIG_HEXDUMP) += hexdump.o
lib-$(CONFIG_HWCLOCK) +=hwclock.o lib-$(CONFIG_HWCLOCK) += hwclock.o
lib-$(CONFIG_IPCRM) +=ipcrm.o lib-$(CONFIG_IPCRM) += ipcrm.o
lib-$(CONFIG_IPCS) +=ipcs.o lib-$(CONFIG_IPCS) += ipcs.o
lib-$(CONFIG_LOSETUP) +=losetup.o lib-$(CONFIG_LOSETUP) += losetup.o
lib-$(CONFIG_MDEV) +=mdev.o lib-$(CONFIG_MDEV) += mdev.o
lib-$(CONFIG_MKFS_MINIX) +=mkfs_minix.o lib-$(CONFIG_MKFS_MINIX) += mkfs_minix.o
lib-$(CONFIG_MKSWAP) +=mkswap.o lib-$(CONFIG_MKSWAP) += mkswap.o
lib-$(CONFIG_MORE) +=more.o lib-$(CONFIG_MORE) += more.o
lib-$(CONFIG_MOUNT) +=mount.o lib-$(CONFIG_MOUNT) += mount.o
lib-$(CONFIG_PIVOT_ROOT) +=pivot_root.o lib-$(CONFIG_PIVOT_ROOT) += pivot_root.o
lib-$(CONFIG_RDATE) +=rdate.o lib-$(CONFIG_RDATE) += rdate.o
lib-$(CONFIG_READPROFILE) +=readprofile.o lib-$(CONFIG_READPROFILE) += readprofile.o
lib-$(CONFIG_RTCWAKE) +=rtcwake.o lib-$(CONFIG_RTCWAKE) += rtcwake.o
lib-$(CONFIG_SCRIPT) +=script.o lib-$(CONFIG_SCRIPT) += script.o
lib-$(CONFIG_SETARCH) +=setarch.o lib-$(CONFIG_SETARCH) += setarch.o
lib-$(CONFIG_SWAPONOFF) +=swaponoff.o lib-$(CONFIG_SWAPONOFF) += swaponoff.o
lib-$(CONFIG_SWITCH_ROOT) +=switch_root.o lib-$(CONFIG_SWITCH_ROOT) += switch_root.o
lib-$(CONFIG_UMOUNT) +=umount.o lib-$(CONFIG_UMOUNT) += umount.o

View File

@ -25,8 +25,9 @@ lib-$(CONFIG_FEATURE_VOLUMEID_JFS) += jfs.o
lib-$(CONFIG_FEATURE_VOLUMEID_LINUXRAID) += linux_raid.o lib-$(CONFIG_FEATURE_VOLUMEID_LINUXRAID) += linux_raid.o
lib-$(CONFIG_FEATURE_VOLUMEID_LINUXSWAP) += linux_swap.o lib-$(CONFIG_FEATURE_VOLUMEID_LINUXSWAP) += linux_swap.o
lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o
lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o ### unused
lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o ### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o
### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o
lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o
lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o
lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o

View File

@ -21,7 +21,7 @@
#include "volume_id_internal.h" #include "volume_id_internal.h"
struct cramfs_super { struct cramfs_super {
uint8_t magic[4]; uint32_t magic;
uint32_t size; uint32_t size;
uint32_t flags; uint32_t flags;
uint32_t future; uint32_t future;
@ -45,12 +45,12 @@ int volume_id_probe_cramfs(struct volume_id *id, uint64_t off)
if (cs == NULL) if (cs == NULL)
return -1; return -1;
if (memcmp(cs->magic, "\x45\x3d\xcd\x28", 4) == 0) { if (cs->magic == cpu_to_be32(0x453dcd28)) {
volume_id_set_label_raw(id, cs->name, 16); // volume_id_set_label_raw(id, cs->name, 16);
volume_id_set_label_string(id, cs->name, 16); volume_id_set_label_string(id, cs->name, 16);
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "cramfs"; // id->type = "cramfs";
return 0; return 0;
} }

View File

@ -47,25 +47,27 @@ int volume_id_probe_ext(struct volume_id *id, uint64_t off)
{ {
struct ext2_super_block *es; struct ext2_super_block *es;
dbg("probing at offset 0x%llx", (unsigned long long) off); dbg("ext: probing at offset 0x%llx", (unsigned long long) off);
es = volume_id_get_buffer(id, off + EXT_SUPERBLOCK_OFFSET, 0x200); es = volume_id_get_buffer(id, off + EXT_SUPERBLOCK_OFFSET, 0x200);
if (es == NULL) if (es == NULL)
return -1; return -1;
if (es->magic[0] != 0123 || if (es->magic[0] != 0123 || es->magic[1] != 0357) {
es->magic[1] != 0357) dbg("ext: no magic found");
return -1; return -1;
}
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
volume_id_set_label_raw(id, es->volume_name, 16); // volume_id_set_label_raw(id, es->volume_name, 16);
volume_id_set_label_string(id, es->volume_name, 16); volume_id_set_label_string(id, es->volume_name, 16);
volume_id_set_uuid(id, es->uuid, UUID_DCE); volume_id_set_uuid(id, es->uuid, UUID_DCE);
dbg("ext: label '%s' uuid '%s'", id->label, id->uuid);
if ((le32_to_cpu(es->feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0) // if ((le32_to_cpu(es->feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0)
id->type = "ext3"; // id->type = "ext3";
else // else
id->type = "ext2"; // id->type = "ext2";
return 0; return 0;
} }

View File

@ -227,14 +227,16 @@ int volume_id_probe_vfat(struct volume_id *id, uint64_t off)
cluster_count /= vs->sectors_per_cluster; cluster_count /= vs->sectors_per_cluster;
dbg("cluster_count 0x%x", cluster_count); dbg("cluster_count 0x%x", cluster_count);
if (cluster_count < FAT12_MAX) { // if (cluster_count < FAT12_MAX) {
strcpy(id->type_version, "FAT12"); // strcpy(id->type_version, "FAT12");
} else if (cluster_count < FAT16_MAX) { // } else if (cluster_count < FAT16_MAX) {
strcpy(id->type_version, "FAT16"); // strcpy(id->type_version, "FAT16");
} else { // } else {
strcpy(id->type_version, "FAT32"); // strcpy(id->type_version, "FAT32");
// goto fat32;
// }
if (cluster_count >= FAT16_MAX)
goto fat32; goto fat32;
}
/* the label may be an attribute in the root directory */ /* the label may be an attribute in the root directory */
root_start = (reserved + fat_size) * sector_size; root_start = (reserved + fat_size) * sector_size;
@ -256,10 +258,10 @@ int volume_id_probe_vfat(struct volume_id *id, uint64_t off)
return -1; return -1;
if (label != NULL && memcmp(label, "NO NAME ", 11) != 0) { if (label != NULL && memcmp(label, "NO NAME ", 11) != 0) {
volume_id_set_label_raw(id, label, 11); // volume_id_set_label_raw(id, label, 11);
volume_id_set_label_string(id, label, 11); volume_id_set_label_string(id, label, 11);
} else if (memcmp(vs->type.fat.label, "NO NAME ", 11) != 0) { } else if (memcmp(vs->type.fat.label, "NO NAME ", 11) != 0) {
volume_id_set_label_raw(id, vs->type.fat.label, 11); // volume_id_set_label_raw(id, vs->type.fat.label, 11);
volume_id_set_label_string(id, vs->type.fat.label, 11); volume_id_set_label_string(id, vs->type.fat.label, 11);
} }
volume_id_set_uuid(id, vs->type.fat.serno, UUID_DOS); 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)
return -1; return -1;
if (label != NULL && memcmp(label, "NO NAME ", 11) != 0) { if (label != NULL && memcmp(label, "NO NAME ", 11) != 0) {
volume_id_set_label_raw(id, label, 11); // volume_id_set_label_raw(id, label, 11);
volume_id_set_label_string(id, label, 11); volume_id_set_label_string(id, label, 11);
} else if (memcmp(vs->type.fat32.label, "NO NAME ", 11) != 0) { } else if (memcmp(vs->type.fat32.label, "NO NAME ", 11) != 0) {
volume_id_set_label_raw(id, vs->type.fat32.label, 11); // volume_id_set_label_raw(id, vs->type.fat32.label, 11);
volume_id_set_label_string(id, vs->type.fat32.label, 11); volume_id_set_label_string(id, vs->type.fat32.label, 11);
} }
volume_id_set_uuid(id, vs->type.fat32.serno, UUID_DOS); volume_id_set_uuid(id, vs->type.fat32.serno, UUID_DOS);
found: found:
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "vfat"; // id->type = "vfat";
return 0; return 0;
} }

View File

@ -10,22 +10,19 @@
#include "volume_id_internal.h" #include "volume_id_internal.h"
#define BLKGETSIZE64 _IOR(0x12,114,size_t) //#define BLKGETSIZE64 _IOR(0x12,114,size_t)
#define PROC_PARTITIONS "/proc/partitions"
#define PROC_CDROMS "/proc/sys/dev/cdrom/info"
#define DEVLABELDIR "/dev"
#define SYS_BLOCK "/sys/block"
static struct uuidCache_s { static struct uuidCache_s {
struct uuidCache_s *next; struct uuidCache_s *next;
char uuid[16]; // int major, minor;
char *device; char *device;
char *label; char *label;
int major, minor; char *uc_uuid; /* prefix makes it easier to grep for */
} *uuidCache; } *uuidCache;
/* for now, only ext2, ext3 and xfs are supported */ /* Returns !0 on error.
* Otherwise, returns malloc'ed strings for label and uuid
* (and they can't be NULL, although they can be "") */
#if !ENABLE_FEATURE_VOLUMEID_ISO9660 #if !ENABLE_FEATURE_VOLUMEID_ISO9660
#define get_label_uuid(device, label, uuid, iso_only) \ #define get_label_uuid(device, label, uuid, iso_only) \
get_label_uuid(device, label, uuid) get_label_uuid(device, label, uuid)
@ -38,15 +35,18 @@ get_label_uuid(const char *device, char **label, char **uuid, int iso_only)
struct volume_id *vid; struct volume_id *vid;
vid = volume_id_open_node(device); vid = volume_id_open_node(device);
if (!vid)
return rv;
if (ioctl(vid->fd, BLKGETSIZE64, &size) != 0) { if (ioctl(vid->fd, BLKGETSIZE64, &size) != 0)
size = 0; size = 0;
}
#if ENABLE_FEATURE_VOLUMEID_ISO9660 #if ENABLE_FEATURE_VOLUMEID_ISO9660
if (iso_only ? if ((iso_only ?
volume_id_probe_iso9660(vid, 0) != 0 : volume_id_probe_iso9660(vid, 0) :
volume_id_probe_all(vid, 0, size) != 0) { volume_id_probe_all(vid, 0, size)
) != 0
) {
goto ret; goto ret;
} }
#else #else
@ -55,10 +55,10 @@ get_label_uuid(const char *device, char **label, char **uuid, int iso_only)
} }
#endif #endif
if (vid->label[0] != '\0') { if (vid->label[0] != '\0' || vid->uuid[0] != '\0') {
*label = xstrndup(vid->label, sizeof(vid->label)); *label = xstrndup(vid->label, sizeof(vid->label));
*uuid = xstrndup(vid->uuid, sizeof(vid->uuid)); *uuid = xstrndup(vid->uuid, sizeof(vid->uuid));
printf("Found label %s on %s (uuid:%s)\n", *label, device, *uuid); dbg("found label '%s', uuid '%s' on %s", *label, *uuid, device);
rv = 0; rv = 0;
} }
ret: ret:
@ -66,8 +66,9 @@ get_label_uuid(const char *device, char **label, char **uuid, int iso_only)
return rv; return rv;
} }
/* NB: we take ownership of (malloc'ed) label and uuid */
static void static void
uuidcache_addentry(char * device, int major, int minor, char *label, char *uuid) uuidcache_addentry(char *device, /*int major, int minor,*/ char *label, char *uuid)
{ {
struct uuidCache_s *last; struct uuidCache_s *last;
@ -80,13 +81,16 @@ uuidcache_addentry(char * device, int major, int minor, char *label, char *uuid)
last = last->next; last = last->next;
} }
/*last->next = NULL; - xzalloc did it*/ /*last->next = NULL; - xzalloc did it*/
last->label = label; // last->major = major;
// last->minor = minor;
last->device = device; last->device = device;
last->major = major; last->label = label;
last->minor = minor; last->uc_uuid = uuid;
memcpy(last->uuid, uuid, sizeof(last->uuid));
} }
/* If get_label_uuid() on device_name returns success,
* add a cache entry for this device.
* If device node does not exist, it will be temporarily created. */
#if !ENABLE_FEATURE_VOLUMEID_ISO9660 #if !ENABLE_FEATURE_VOLUMEID_ISO9660
#define uuidcache_check_device(device_name, ma, mi, iso_only) \ #define uuidcache_check_device(device_name, ma, mi, iso_only) \
uuidcache_check_device(device_name, ma, mi) uuidcache_check_device(device_name, ma, mi)
@ -94,45 +98,62 @@ uuidcache_addentry(char * device, int major, int minor, char *label, char *uuid)
static void static void
uuidcache_check_device(const char *device_name, int ma, int mi, int iso_only) uuidcache_check_device(const char *device_name, int ma, int mi, int iso_only)
{ {
char device[110]; char *device, *last_slash;
char *uuid = NULL, *label = NULL; char *uuid, *label;
char *ptr; char *ptr;
char *deviceDir = NULL; int must_remove = 0;
int mustRemove = 0; int added = 0;
int mustRemoveDir = 0;
int i; last_slash = NULL;
device = xasprintf("/dev/%s", device_name);
if (access(device, F_OK) != 0) {
/* device does not exist, temporarily create */
int slash_cnt = 0;
if ((ma | mi) < 0)
goto ret; /* we don't know major:minor! */
sprintf(device, "%s/%s", DEVLABELDIR, device_name);
if (access(device, F_OK)) {
ptr = device; ptr = device;
i = 0;
while (*ptr) while (*ptr)
if (*ptr++ == '/') if (*ptr++ == '/')
i++; slash_cnt++;
if (i > 2) { if (slash_cnt > 2) {
deviceDir = alloca(strlen(device) + 1); // BUG: handles only slash_cnt == 3 case
strcpy(deviceDir, device); last_slash = strrchr(device, '/');
ptr = deviceDir + (strlen(device) - 1); *last_slash = '\0';
while (*ptr != '/') if (mkdir(device, 0644)) {
*ptr-- = '\0'; bb_perror_msg("can't create directory %s", device);
if (mkdir(deviceDir, 0644)) { *last_slash = '/';
printf("mkdir: cannot create directory %s: %d\n", deviceDir, errno); last_slash = NULL; /* prevents rmdir */
} else { } else {
mustRemoveDir = 1; *last_slash = '/';
} }
} }
mknod(device, S_IFBLK | 0600, makedev(ma, mi)); mknod(device, S_IFBLK | 0600, makedev(ma, mi));
mustRemove = 1; must_remove = 1;
} }
if (!get_label_uuid(device, &label, &uuid, iso_only))
uuidcache_addentry(strdup(device), ma, mi,
label, uuid);
if (mustRemove) unlink(device); uuid = NULL;
if (mustRemoveDir) rmdir(deviceDir); label = NULL;
if (get_label_uuid(device, &label, &uuid, iso_only) == 0) {
uuidcache_addentry(device, /*ma, mi,*/ label, uuid);
/* "device" is owned by cache now, don't free */
added = 1;
}
if (must_remove)
unlink(device);
if (last_slash) {
*last_slash = '\0';
rmdir(device);
}
ret:
if (!added)
free(device);
} }
/* Run uuidcache_check_device() for every device mentioned
* in /proc/partitions */
static void static void
uuidcache_init_partitions(void) uuidcache_init_partitions(void)
{ {
@ -144,7 +165,7 @@ uuidcache_init_partitions(void)
int handleOnFirst; int handleOnFirst;
char *chptr; char *chptr;
procpt = xfopen(PROC_PARTITIONS, "r"); procpt = xfopen("/proc/partitions", "r");
/* /*
# cat /proc/partitions # cat /proc/partitions
major minor #blocks name major minor #blocks name
@ -165,7 +186,7 @@ major minor #blocks name
diet's sscanf is quite limited */ diet's sscanf is quite limited */
chptr = line; chptr = line;
if (*chptr != ' ') continue; if (*chptr != ' ') continue;
chptr++; chptr = skip_whitespace(chptr);
ma = bb_strtou(chptr, &chptr, 0); ma = bb_strtou(chptr, &chptr, 0);
if (ma < 0) continue; if (ma < 0) continue;
@ -185,6 +206,8 @@ major minor #blocks name
*strchrnul(chptr, '\n') = '\0'; *strchrnul(chptr, '\n') = '\0';
/* now chptr => device name */ /* now chptr => device name */
dbg("/proc/partitions: maj:%d min:%d sz:%llu name:'%s'",
ma, mi, sz, chptr);
if (!chptr[0]) if (!chptr[0])
continue; continue;
@ -203,36 +226,35 @@ major minor #blocks name
fclose(procpt); fclose(procpt);
} }
static int static void
dev_get_major_minor(char *device_name, int *major, int *minor) dev_get_major_minor(char *device_name, int *major, int *minor)
{ {
char * dev_path; char dev[16];
int fd; char *dev_path;
char dev[7]; char *colon;
char *major_ptr, *minor_ptr; int sz;
dev_path = alloca(strlen(SYS_BLOCK) + strlen(device_name) + 6); dev_path = xasprintf("/sys/block/%s/dev", device_name);
sprintf(dev_path, "%s/%s/dev", SYS_BLOCK, device_name); sz = open_read_close(dev_path, dev, sizeof(dev) - 1);
if (sz < 0)
goto ret;
dev[sz] = '\0';
fd = open(dev_path, O_RDONLY); colon = strchr(dev, ':');
if (fd < 0) return 1; if (!colon)
full_read(fd, dev, sizeof(dev)); goto ret;
close(fd); *major = strtol(dev, NULL, 10);
*minor = strtol(colon + 1, NULL, 10);
major_ptr = dev; ret:
minor_ptr = strchr(dev, ':'); free(dev_path);
if (!minor_ptr) return 1; return;
*minor_ptr++ = '\0';
*major = strtol(major_ptr, NULL, 10);
*minor = strtol(minor_ptr, NULL, 10);
return 0;
} }
static void static void
uuidcache_init_cdroms(void) uuidcache_init_cdroms(void)
{ {
#define PROC_CDROMS "/proc/sys/dev/cdrom/info"
char line[100]; char line[100];
int ma, mi; int ma, mi;
FILE *proccd; FILE *proccd;
@ -250,11 +272,13 @@ uuidcache_init_cdroms(void)
} }
while (fgets(line, sizeof(line), proccd)) { while (fgets(line, sizeof(line), proccd)) {
const char *drive_name_string = "drive name:\t\t"; static const char drive_name_string[] ALIGN1 = "drive name:\t\t";
if (!strncmp(line, drive_name_string, strlen(drive_name_string))) {
if (strncmp(line, drive_name_string, sizeof(drive_name_string) - 1) == 0) {
char *device_name; char *device_name;
device_name = strtok(line + strlen(drive_name_string), "\t\n"); device_name = strtok(line + sizeof(drive_name_string) - 1, "\t\n");
while (device_name) { while (device_name) {
ma = mi = -1;
dev_get_major_minor(device_name, &ma, &mi); dev_get_major_minor(device_name, &ma, &mi);
uuidcache_check_device(device_name, ma, mi, 1); uuidcache_check_device(device_name, ma, mi, 1);
device_name = strtok(NULL, "\t\n"); device_name = strtok(NULL, "\t\n");
@ -281,24 +305,24 @@ uuidcache_init(void)
#ifdef UNUSED #ifdef UNUSED
static char * static char *
get_spec_by_x(int n, const char *t, int * majorPtr, int * minorPtr) get_spec_by_x(int n, const char *t, int *majorPtr, int *minorPtr)
{ {
struct uuidCache_s *uc; struct uuidCache_s *uc;
uuidcache_init(); uuidcache_init();
uc = uuidCache; uc = uuidCache;
while(uc) { while (uc) {
switch (n) { switch (n) {
case UUID: case UUID:
if (!memcmp(t, uc->uuid, sizeof(uc->uuid))) { if (strcmp(t, uc->uc_uuid) == 0) {
*majorPtr = uc->major; *majorPtr = uc->major;
*minorPtr = uc->minor; *minorPtr = uc->minor;
return uc->device; return uc->device;
} }
break; break;
case VOL: case VOL:
if (!strcmp(t, uc->label)) { if (strcmp(t, uc->label) == 0) {
*majorPtr = uc->major; *majorPtr = uc->major;
*minorPtr = uc->minor; *minorPtr = uc->minor;
return uc->device; return uc->device;
@ -315,26 +339,27 @@ fromhex(char c)
{ {
if (isdigit(c)) if (isdigit(c))
return (c - '0'); return (c - '0');
if (islower(c)) return ((c|0x20) - 'a' + 10);
return (c - 'a' + 10);
return (c - 'A' + 10);
} }
static char * static char *
get_spec_by_uuid(const char *s, int * major, int * minor) get_spec_by_uuid(const char *s, int *major, int *minor)
{ {
unsigned char uuid[16]; unsigned char uuid[16];
int i; int i;
if (strlen(s) != 36 || if (strlen(s) != 36 || s[8] != '-' || s[13] != '-'
s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-') || s[18] != '-' || s[23] != '-'
) {
goto bad_uuid; goto bad_uuid;
for (i=0; i<16; i++) { }
if (*s == '-') s++; for (i = 0; i < 16; i++) {
if (!isxdigit(s[0]) || !isxdigit(s[1])) if (*s == '-')
goto bad_uuid; s++;
uuid[i] = ((fromhex(s[0])<<4) | fromhex(s[1])); if (!isxdigit(s[0]) || !isxdigit(s[1]))
s += 2; goto bad_uuid;
uuid[i] = ((fromhex(s[0]) << 4) | fromhex(s[1]));
s += 2;
} }
return get_spec_by_x(UUID, (char *)uuid, major, minor); return get_spec_by_x(UUID, (char *)uuid, major, minor);
@ -358,13 +383,7 @@ static int display_uuid_cache(void)
u = uuidCache; u = uuidCache;
while (u) { while (u) {
printf("%s %s ", u->device, u->label); printf("%s %s %s\n", u->device, u->label, u->uc_uuid);
for (i = 0; i < sizeof(u->uuid); i++) {
if (i == 4 || i == 6 || i == 8 || i == 10)
printf("-");
printf("%x", u->uuid[i] & 0xff);
}
printf("\n");
u = u->next; u = u->next;
} }
@ -383,7 +402,8 @@ char *get_devname_from_label(const char *spec)
uuidcache_init(); uuidcache_init();
uc = uuidCache; uc = uuidCache;
while (uc) { while (uc) {
if (uc->label && !strncmp(spec, uc->label, spec_len)) { // FIXME: empty label ("LABEL=") matches anything??!
if (uc->label[0] && strncmp(spec, uc->label, spec_len) == 0) {
return xstrdup(uc->device); return xstrdup(uc->device);
} }
uc = uc->next; uc = uc->next;
@ -398,7 +418,7 @@ char *get_devname_from_uuid(const char *spec)
uuidcache_init(); uuidcache_init();
uc = uuidCache; uc = uuidCache;
while (uc) { while (uc) {
if (!memcmp(spec, uc->uuid, sizeof(uc->uuid))) { if (strcmp(spec, uc->uc_uuid) == 0) {
return xstrdup(uc->device); return xstrdup(uc->device);
} }
uc = uc->next; uc = uc->next;

View File

@ -167,7 +167,7 @@ int volume_id_probe_hfs_hfsplus(struct volume_id *id, uint64_t off)
goto checkplus; goto checkplus;
/* it may be just a hfs wrapper for hfs+ */ /* it may be just a hfs wrapper for hfs+ */
if (memcmp(hfs->embed_sig, "H+", 2) == 0) { if (hfs->embed_sig[0] == 'H' && hfs->embed_sig[1] == '+') {
alloc_block_size = be32_to_cpu(hfs->al_blk_size); alloc_block_size = be32_to_cpu(hfs->al_blk_size);
dbg("alloc_block_size 0x%x", alloc_block_size); dbg("alloc_block_size 0x%x", alloc_block_size);
@ -188,14 +188,13 @@ int volume_id_probe_hfs_hfsplus(struct volume_id *id, uint64_t off)
} }
if (hfs->label_len > 0 && hfs->label_len < 28) { if (hfs->label_len > 0 && hfs->label_len < 28) {
volume_id_set_label_raw(id, hfs->label, hfs->label_len); // volume_id_set_label_raw(id, hfs->label, hfs->label_len);
volume_id_set_label_string(id, hfs->label, hfs->label_len) ; volume_id_set_label_string(id, hfs->label, hfs->label_len) ;
} }
volume_id_set_uuid(id, hfs->finder_info.id, UUID_HFS); volume_id_set_uuid(id, hfs->finder_info.id, UUID_HFS);
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // id->type = "hfs";
id->type = "hfs";
return 0; return 0;
@ -281,12 +280,12 @@ int volume_id_probe_hfs_hfsplus(struct volume_id *id, uint64_t off)
label_len = be16_to_cpu(key->unicode_len) * 2; label_len = be16_to_cpu(key->unicode_len) * 2;
dbg("label unicode16 len %i", label_len); dbg("label unicode16 len %i", label_len);
volume_id_set_label_raw(id, key->unicode, label_len); // volume_id_set_label_raw(id, key->unicode, label_len);
volume_id_set_label_unicode16(id, key->unicode, BE, label_len); volume_id_set_label_unicode16(id, key->unicode, BE, label_len);
found: found:
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "hfsplus"; // id->type = "hfsplus";
return 0; return 0;
} }

View File

@ -52,8 +52,8 @@ int volume_id_probe_highpoint_37x_raid(struct volume_id *id, uint64_t off)
if (magic != cpu_to_le32(HPT37X_MAGIC_OK) && magic != cpu_to_le32(HPT37X_MAGIC_BAD)) if (magic != cpu_to_le32(HPT37X_MAGIC_OK) && magic != cpu_to_le32(HPT37X_MAGIC_BAD))
return -1; return -1;
volume_id_set_usage(id, VOLUME_ID_RAID); // volume_id_set_usage(id, VOLUME_ID_RAID);
id->type = "highpoint_raid_member"; // id->type = "highpoint_raid_member";
return 0; return 0;
} }
@ -79,8 +79,8 @@ int volume_id_probe_highpoint_45x_raid(struct volume_id *id, uint64_t off, uint6
if (magic != cpu_to_le32(HPT45X_MAGIC_OK) && magic != cpu_to_le32(HPT45X_MAGIC_BAD)) if (magic != cpu_to_le32(HPT45X_MAGIC_OK) && magic != cpu_to_le32(HPT45X_MAGIC_BAD))
return -1; return -1;
volume_id_set_usage(id, VOLUME_ID_RAID); // volume_id_set_usage(id, VOLUME_ID_RAID);
id->type = "highpoint_raid_member"; // id->type = "highpoint_raid_member";
return 0; return 0;
} }

View File

@ -39,10 +39,9 @@ int volume_id_probe_hpfs(struct volume_id *id, uint64_t off)
return -1; return -1;
if (memcmp(hs->magic, "\x49\xe8\x95\xf9", 4) == 0) { if (memcmp(hs->magic, "\x49\xe8\x95\xf9", 4) == 0) {
sprintf(id->type_version, "%u", hs->version); // sprintf(id->type_version, "%u", hs->version);
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // id->type = "hpfs";
id->type = "hpfs";
return 0; return 0;
} }

View File

@ -66,7 +66,7 @@ int volume_id_probe_iso9660(struct volume_id *id, uint64_t off)
int i; int i;
dbg("read label from PVD"); dbg("read label from PVD");
volume_id_set_label_raw(id, is->volume_id, 32); // volume_id_set_label_raw(id, is->volume_id, 32);
volume_id_set_label_string(id, is->volume_id, 32); volume_id_set_label_string(id, is->volume_id, 32);
dbg("looking for SVDs"); dbg("looking for SVDs");
@ -81,9 +81,10 @@ int volume_id_probe_iso9660(struct volume_id *id, uint64_t off)
continue; continue;
dbg("found SVD at offset 0x%llx", (unsigned long long) (off + vd_offset)); dbg("found SVD at offset 0x%llx", (unsigned long long) (off + vd_offset));
if (memcmp(is->escape_sequences, "%/@", 3) == 0|| if (memcmp(is->escape_sequences, "%/@", 3) == 0
memcmp(is->escape_sequences, "%/C", 3) == 0|| || memcmp(is->escape_sequences, "%/C", 3) == 0
memcmp(is->escape_sequences, "%/E", 3) == 0) { || memcmp(is->escape_sequences, "%/E", 3) == 0
) {
dbg("Joliet extension found"); dbg("Joliet extension found");
volume_id_set_unicode16((char *)svd_label, sizeof(svd_label), is->volume_id, BE, 32); volume_id_set_unicode16((char *)svd_label, sizeof(svd_label), is->volume_id, BE, 32);
if (memcmp(id->label, svd_label, 16) == 0) { if (memcmp(id->label, svd_label, 16) == 0) {
@ -91,9 +92,9 @@ int volume_id_probe_iso9660(struct volume_id *id, uint64_t off)
break; break;
} }
volume_id_set_label_raw(id, is->volume_id, 32); // volume_id_set_label_raw(id, is->volume_id, 32);
volume_id_set_label_string(id, svd_label, 32); volume_id_set_label_string(id, svd_label, 32);
strcpy(id->type_version, "Joliet Extension"); // strcpy(id->type_version, "Joliet Extension");
goto found; goto found;
} }
vd_offset += ISO_SECTOR_SIZE; vd_offset += ISO_SECTOR_SIZE;
@ -104,15 +105,15 @@ int volume_id_probe_iso9660(struct volume_id *id, uint64_t off)
hs = (struct high_sierra_volume_descriptor *) buf; hs = (struct high_sierra_volume_descriptor *) buf;
if (memcmp(hs->id, "CDROM", 5) == 0) { if (memcmp(hs->id, "CDROM", 5) == 0) {
strcpy(id->type_version, "High Sierra"); // strcpy(id->type_version, "High Sierra");
goto found; goto found;
} }
return -1; return -1;
found: found:
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "iso9660"; // id->type = "iso9660";
return 0; return 0;
} }

View File

@ -50,9 +50,9 @@ int volume_id_probe_intel_software_raid(struct volume_id *id, uint64_t off, uint
if (memcmp(isw->sig, ISW_SIGNATURE, sizeof(ISW_SIGNATURE)-1) != 0) if (memcmp(isw->sig, ISW_SIGNATURE, sizeof(ISW_SIGNATURE)-1) != 0)
return -1; return -1;
volume_id_set_usage(id, VOLUME_ID_RAID); // volume_id_set_usage(id, VOLUME_ID_RAID);
memcpy(id->type_version, &isw->sig[sizeof(ISW_SIGNATURE)-1], 6); // memcpy(id->type_version, &isw->sig[sizeof(ISW_SIGNATURE)-1], 6);
id->type = "isw_raid_member"; // id->type = "isw_raid_member";
return 0; return 0;
} }

View File

@ -48,12 +48,12 @@ int volume_id_probe_jfs(struct volume_id *id, uint64_t off)
if (memcmp(js->magic, "JFS1", 4) != 0) if (memcmp(js->magic, "JFS1", 4) != 0)
return -1; return -1;
volume_id_set_label_raw(id, js->label, 16); // volume_id_set_label_raw(id, js->label, 16);
volume_id_set_label_string(id, js->label, 16); volume_id_set_label_string(id, js->label, 16);
volume_id_set_uuid(id, js->uuid, UUID_DCE); volume_id_set_uuid(id, js->uuid, UUID_DCE);
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "jfs"; // id->type = "jfs";
return 0; return 0;
} }

View File

@ -66,14 +66,14 @@ int volume_id_probe_linux_raid(struct volume_id *id, uint64_t off, uint64_t size
memcpy(&uuid[4], &mdp->set_uuid1, 12); memcpy(&uuid[4], &mdp->set_uuid1, 12);
volume_id_set_uuid(id, uuid, UUID_DCE); volume_id_set_uuid(id, uuid, UUID_DCE);
snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u.%u", // snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u.%u",
le32_to_cpu(mdp->major_version), // le32_to_cpu(mdp->major_version),
le32_to_cpu(mdp->minor_version), // le32_to_cpu(mdp->minor_version),
le32_to_cpu(mdp->patch_version)); // le32_to_cpu(mdp->patch_version));
dbg("found raid signature"); dbg("found raid signature");
volume_id_set_usage(id, VOLUME_ID_RAID); // volume_id_set_usage(id, VOLUME_ID_RAID);
id->type = "linux_raid_member"; // id->type = "linux_raid_member";
return 0; return 0;
} }

View File

@ -46,8 +46,8 @@ int volume_id_probe_linux_swap(struct volume_id *id, uint64_t off)
return -1; return -1;
if (memcmp(buf, "SWAP-SPACE", 10) == 0) { if (memcmp(buf, "SWAP-SPACE", 10) == 0) {
id->type_version[0] = '1'; // id->type_version[0] = '1';
id->type_version[1] = '\0'; // id->type_version[1] = '\0';
goto found; goto found;
} }
@ -55,9 +55,9 @@ int volume_id_probe_linux_swap(struct volume_id *id, uint64_t off)
sw = volume_id_get_buffer(id, off, sizeof(struct swap_header_v1_2)); sw = volume_id_get_buffer(id, off, sizeof(struct swap_header_v1_2));
if (sw == NULL) if (sw == NULL)
return -1; return -1;
id->type_version[0] = '2'; // id->type_version[0] = '2';
id->type_version[1] = '\0'; // id->type_version[1] = '\0';
volume_id_set_label_raw(id, sw->volume_name, 16); // volume_id_set_label_raw(id, sw->volume_name, 16);
volume_id_set_label_string(id, sw->volume_name, 16); volume_id_set_label_string(id, sw->volume_name, 16);
volume_id_set_uuid(id, sw->uuid, UUID_DCE); volume_id_set_uuid(id, sw->uuid, UUID_DCE);
goto found; goto found;
@ -66,8 +66,8 @@ int volume_id_probe_linux_swap(struct volume_id *id, uint64_t off)
return -1; return -1;
found: found:
volume_id_set_usage(id, VOLUME_ID_OTHER); // volume_id_set_usage(id, VOLUME_ID_OTHER);
id->type = "swap"; // id->type = "swap";
return 0; return 0;
} }

View File

@ -45,8 +45,8 @@ int volume_id_probe_lsi_mega_raid(struct volume_id *id, uint64_t off, uint64_t s
if (memcmp(lsi->sig, LSI_SIGNATURE, sizeof(LSI_SIGNATURE)-1) != 0) if (memcmp(lsi->sig, LSI_SIGNATURE, sizeof(LSI_SIGNATURE)-1) != 0)
return -1; return -1;
volume_id_set_usage(id, VOLUME_ID_RAID); // volume_id_set_usage(id, VOLUME_ID_RAID);
id->type = "lsi_mega_raid_member"; // id->type = "lsi_mega_raid_member";
return 0; return 0;
} }

View File

@ -67,10 +67,9 @@ int volume_id_probe_luks(struct volume_id *id, uint64_t off)
if (memcmp(header->magic, LUKS_MAGIC, LUKS_MAGIC_L)) if (memcmp(header->magic, LUKS_MAGIC, LUKS_MAGIC_L))
return -1; return -1;
volume_id_set_usage(id, VOLUME_ID_CRYPTO); // volume_id_set_usage(id, VOLUME_ID_CRYPTO);
volume_id_set_uuid(id, header->uuid, UUID_DCE_STRING); volume_id_set_uuid(id, header->uuid, UUID_DCE_STRING);
// id->type = "crypto_LUKS";
id->type = "crypto_LUKS";
return 0; return 0;
} }

View File

@ -33,7 +33,6 @@ struct lvm2_super_block {
} __attribute__((packed)); } __attribute__((packed));
#define LVM1_SB_OFF 0x400 #define LVM1_SB_OFF 0x400
#define LVM1_MAGIC "HM"
int volume_id_probe_lvm1(struct volume_id *id, uint64_t off) int volume_id_probe_lvm1(struct volume_id *id, uint64_t off)
{ {
@ -48,11 +47,11 @@ int volume_id_probe_lvm1(struct volume_id *id, uint64_t off)
lvm = (struct lvm1_super_block *) buf; lvm = (struct lvm1_super_block *) buf;
if (memcmp(lvm->id, LVM1_MAGIC, 2) != 0) if (lvm->id[0] != 'H' || lvm->id[1] != 'M')
return -1; return -1;
volume_id_set_usage(id, VOLUME_ID_RAID); // volume_id_set_usage(id, VOLUME_ID_RAID);
id->type = "LVM1_member"; // id->type = "LVM1_member";
return 0; return 0;
} }
@ -83,9 +82,9 @@ int volume_id_probe_lvm2(struct volume_id *id, uint64_t off)
return -1; return -1;
found: found:
memcpy(id->type_version, lvm->type, 8); // memcpy(id->type_version, lvm->type, 8);
volume_id_set_usage(id, VOLUME_ID_RAID); // volume_id_set_usage(id, VOLUME_ID_RAID);
id->type = "LVM2_member"; // id->type = "LVM2_member";
return 0; return 0;
} }

View File

@ -20,8 +20,7 @@
#include "volume_id_internal.h" #include "volume_id_internal.h"
struct minix_super_block struct minix_super_block {
{
uint16_t s_ninodes; uint16_t s_ninodes;
uint16_t s_nzones; uint16_t s_nzones;
uint16_t s_imap_blocks; uint16_t s_imap_blocks;
@ -46,31 +45,31 @@ int volume_id_probe_minix(struct volume_id *id, uint64_t off)
if (ms == NULL) if (ms == NULL)
return -1; return -1;
if (le16_to_cpu(ms->s_magic) == 0x137f) { if (ms->s_magic == cpu_to_le16(0x137f)) {
id->type_version[0] = '1'; // id->type_version[0] = '1';
goto found; goto found;
} }
if (le16_to_cpu(ms->s_magic) == 0x1387) { if (ms->s_magic == cpu_to_le16(0x1387)) {
id->type_version[0] = '1'; // id->type_version[0] = '1';
goto found; goto found;
} }
if (le16_to_cpu(ms->s_magic) == 0x2468) { if (ms->s_magic == cpu_to_le16(0x2468)) {
id->type_version[0] = '2'; // id->type_version[0] = '2';
goto found; goto found;
} }
if (le16_to_cpu(ms->s_magic) == 0x2478) { if (ms->s_magic == cpu_to_le16(0x2478)) {
id->type_version[0] = '2'; // id->type_version[0] = '2';
goto found; goto found;
} }
return -1; return -1;
found: found:
id->type_version[1] = '\0'; // id->type_version[1] = '\0';
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "minix"; // id->type = "minix";
return 0; return 0;
} }

View File

@ -166,13 +166,13 @@ int volume_id_probe_ntfs(struct volume_id *id, uint64_t off)
dbg("found attribute type 0x%x, len %i, at offset %i", dbg("found attribute type 0x%x, len %i, at offset %i",
attr_type, attr_len, attr_off); attr_type, attr_len, attr_off);
if (attr_type == MFT_RECORD_ATTR_VOLUME_INFO) { // if (attr_type == MFT_RECORD_ATTR_VOLUME_INFO) {
struct volume_info *info; // struct volume_info *info;
dbg("found info, len %i", val_len); // dbg("found info, len %i", val_len);
info = (struct volume_info*) (((uint8_t *) attr) + val_off); // info = (struct volume_info*) (((uint8_t *) attr) + val_off);
snprintf(id->type_version, sizeof(id->type_version)-1, // snprintf(id->type_version, sizeof(id->type_version)-1,
"%u.%u", info->major_ver, info->minor_ver); // "%u.%u", info->major_ver, info->minor_ver);
} // }
if (attr_type == MFT_RECORD_ATTR_VOLUME_NAME) { if (attr_type == MFT_RECORD_ATTR_VOLUME_NAME) {
dbg("found label, len %i", val_len); dbg("found label, len %i", val_len);
@ -180,14 +180,14 @@ int volume_id_probe_ntfs(struct volume_id *id, uint64_t off)
val_len = VOLUME_ID_LABEL_SIZE; val_len = VOLUME_ID_LABEL_SIZE;
val = ((uint8_t *) attr) + val_off; val = ((uint8_t *) attr) + val_off;
volume_id_set_label_raw(id, val, val_len); // volume_id_set_label_raw(id, val, val_len);
volume_id_set_label_unicode16(id, val, LE, val_len); volume_id_set_label_unicode16(id, val, LE, val_len);
} }
} }
found: found:
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "ntfs"; // id->type = "ntfs";
return 0; return 0;
} }

View File

@ -48,9 +48,9 @@ int volume_id_probe_nvidia_raid(struct volume_id *id, uint64_t off, uint64_t siz
if (memcmp(nv->vendor, NVIDIA_SIGNATURE, sizeof(NVIDIA_SIGNATURE)-1) != 0) if (memcmp(nv->vendor, NVIDIA_SIGNATURE, sizeof(NVIDIA_SIGNATURE)-1) != 0)
return -1; return -1;
volume_id_set_usage(id, VOLUME_ID_RAID); // volume_id_set_usage(id, VOLUME_ID_RAID);
snprintf(id->type_version, sizeof(id->type_version)-1, "%u", le16_to_cpu(nv->version)); // snprintf(id->type_version, sizeof(id->type_version)-1, "%u", le16_to_cpu(nv->version));
id->type = "nvidia_raid_member"; // id->type = "nvidia_raid_member";
return 0; return 0;
} }

View File

@ -94,12 +94,12 @@ int volume_id_probe_ocfs2(struct volume_id *id, uint64_t off)
return -1; return -1;
} }
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
volume_id_set_label_raw(id, os->s_label, OCFS2_MAX_VOL_LABEL_LEN < VOLUME_ID_LABEL_SIZE ? // volume_id_set_label_raw(id, os->s_label, OCFS2_MAX_VOL_LABEL_LEN < VOLUME_ID_LABEL_SIZE ?
OCFS2_MAX_VOL_LABEL_LEN : VOLUME_ID_LABEL_SIZE); // OCFS2_MAX_VOL_LABEL_LEN : VOLUME_ID_LABEL_SIZE);
volume_id_set_label_string(id, os->s_label, OCFS2_MAX_VOL_LABEL_LEN < VOLUME_ID_LABEL_SIZE ? volume_id_set_label_string(id, os->s_label, OCFS2_MAX_VOL_LABEL_LEN < VOLUME_ID_LABEL_SIZE ?
OCFS2_MAX_VOL_LABEL_LEN : VOLUME_ID_LABEL_SIZE); OCFS2_MAX_VOL_LABEL_LEN : VOLUME_ID_LABEL_SIZE);
volume_id_set_uuid(id, os->s_uuid, UUID_DCE); volume_id_set_uuid(id, os->s_uuid, UUID_DCE);
id->type = "ocfs2"; // id->type = "ocfs2";
return 0; return 0;
} }

View File

@ -56,8 +56,8 @@ int volume_id_probe_promise_fasttrack_raid(struct volume_id *id, uint64_t off, u
return -1; return -1;
found: found:
volume_id_set_usage(id, VOLUME_ID_RAID); // volume_id_set_usage(id, VOLUME_ID_RAID);
id->type = "promise_fasttrack_raid_member"; // id->type = "promise_fasttrack_raid_member";
return 0; return 0;
} }

View File

@ -53,31 +53,35 @@ int volume_id_probe_reiserfs(struct volume_id *id, uint64_t off)
struct reiserfs_super_block *rs; struct reiserfs_super_block *rs;
struct reiser4_super_block *rs4; struct reiser4_super_block *rs4;
dbg("probing at offset 0x%llx", (unsigned long long) off); dbg("reiserfs: probing at offset 0x%llx", (unsigned long long) off);
rs = volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200); rs = volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200);
if (rs == NULL) if (rs == NULL)
return -1; return -1;
if (memcmp(rs->magic, "ReIsErFs", 8) == 0) { if (memcmp(rs->magic, "ReIsErFs", 8) == 0) {
strcpy(id->type_version, "3.5"); dbg("reiserfs: ReIsErFs, no label");
// strcpy(id->type_version, "3.5");
goto found; goto found;
} }
if (memcmp(rs->magic, "ReIsEr2Fs", 9) == 0) { if (memcmp(rs->magic, "ReIsEr2Fs", 9) == 0) {
strcpy(id->type_version, "3.6"); dbg("reiserfs: ReIsEr2Fs");
// strcpy(id->type_version, "3.6");
goto found_label; goto found_label;
} }
if (memcmp(rs->magic, "ReIsEr3Fs", 9) == 0) { if (memcmp(rs->magic, "ReIsEr3Fs", 9) == 0) {
strcpy(id->type_version, "JR"); dbg("reiserfs: ReIsEr3Fs");
// strcpy(id->type_version, "JR");
goto found_label; goto found_label;
} }
rs4 = (struct reiser4_super_block *) rs; rs4 = (struct reiser4_super_block *) rs;
if (memcmp(rs4->magic, "ReIsEr4", 7) == 0) { if (memcmp(rs4->magic, "ReIsEr4", 7) == 0) {
strcpy(id->type_version, "4"); // strcpy(id->type_version, "4");
volume_id_set_label_raw(id, rs4->label, 16); // volume_id_set_label_raw(id, rs4->label, 16);
volume_id_set_label_string(id, rs4->label, 16); volume_id_set_label_string(id, rs4->label, 16);
volume_id_set_uuid(id, rs4->uuid, UUID_DCE); volume_id_set_uuid(id, rs4->uuid, UUID_DCE);
dbg("reiserfs: ReIsEr4, label '%s' uuid '%s'", id->label, id->uuid);
goto found; goto found;
} }
@ -86,20 +90,23 @@ int volume_id_probe_reiserfs(struct volume_id *id, uint64_t off)
return -1; return -1;
if (memcmp(rs->magic, "ReIsErFs", 8) == 0) { if (memcmp(rs->magic, "ReIsErFs", 8) == 0) {
strcpy(id->type_version, "3.5"); dbg("reiserfs: ReIsErFs, no label");
// strcpy(id->type_version, "3.5");
goto found; goto found;
} }
dbg("reiserfs: no signature found");
return -1; return -1;
found_label: found_label:
volume_id_set_label_raw(id, rs->label, 16); // volume_id_set_label_raw(id, rs->label, 16);
volume_id_set_label_string(id, rs->label, 16); volume_id_set_label_string(id, rs->label, 16);
volume_id_set_uuid(id, rs->uuid, UUID_DCE); volume_id_set_uuid(id, rs->uuid, UUID_DCE);
dbg("reiserfs: label '%s' uuid '%s'", id->label, id->uuid);
found: found:
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "reiserfs"; // id->type = "reiserfs";
return 0; return 0;
} }

View File

@ -41,12 +41,12 @@ int volume_id_probe_romfs(struct volume_id *id, uint64_t off)
size_t len = strlen((char *)rfs->name); size_t len = strlen((char *)rfs->name);
if (len) { if (len) {
volume_id_set_label_raw(id, rfs->name, len); // volume_id_set_label_raw(id, rfs->name, len);
volume_id_set_label_string(id, rfs->name, len); volume_id_set_label_string(id, rfs->name, len);
} }
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "romfs"; // id->type = "romfs";
return 0; return 0;
} }

View File

@ -60,10 +60,10 @@ int volume_id_probe_silicon_medley_raid(struct volume_id *id, uint64_t off, uint
if (sil->magic != cpu_to_le32(SILICON_MAGIC)) if (sil->magic != cpu_to_le32(SILICON_MAGIC))
return -1; return -1;
volume_id_set_usage(id, VOLUME_ID_RAID); // volume_id_set_usage(id, VOLUME_ID_RAID);
snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u", // snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u",
le16_to_cpu(sil->major_ver), le16_to_cpu(sil->minor_ver)); // le16_to_cpu(sil->major_ver), le16_to_cpu(sil->minor_ver));
id->type = "silicon_medley_raid_member"; // id->type = "silicon_medley_raid_member";
return 0; return 0;
} }

View File

@ -97,9 +97,9 @@ int volume_id_probe_sysv(struct volume_id *id, uint64_t off)
return -1; return -1;
if (vs->s_magic == cpu_to_le32(SYSV_MAGIC) || vs->s_magic == cpu_to_be32(SYSV_MAGIC)) { if (vs->s_magic == cpu_to_le32(SYSV_MAGIC) || vs->s_magic == cpu_to_be32(SYSV_MAGIC)) {
volume_id_set_label_raw(id, vs->s_fname, 6); // volume_id_set_label_raw(id, vs->s_fname, 6);
volume_id_set_label_string(id, vs->s_fname, 6); volume_id_set_label_string(id, vs->s_fname, 6);
id->type = "sysv"; // id->type = "sysv";
goto found; goto found;
} }
} }
@ -110,9 +110,9 @@ int volume_id_probe_sysv(struct volume_id *id, uint64_t off)
return -1; return -1;
if (xs->s_magic == cpu_to_le32(XENIX_MAGIC) || xs->s_magic == cpu_to_be32(XENIX_MAGIC)) { if (xs->s_magic == cpu_to_le32(XENIX_MAGIC) || xs->s_magic == cpu_to_be32(XENIX_MAGIC)) {
volume_id_set_label_raw(id, xs->s_fname, 6); // volume_id_set_label_raw(id, xs->s_fname, 6);
volume_id_set_label_string(id, xs->s_fname, 6); volume_id_set_label_string(id, xs->s_fname, 6);
id->type = "xenix"; // id->type = "xenix";
goto found; goto found;
} }
} }
@ -120,6 +120,6 @@ int volume_id_probe_sysv(struct volume_id *id, uint64_t off)
return -1; return -1;
found: found:
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
return 0; return 0;
} }

View File

@ -155,7 +155,7 @@ anchor:
goto found; goto found;
pvd: pvd:
volume_id_set_label_raw(id, &(vd->type.primary.ident.clen), 32); // volume_id_set_label_raw(id, &(vd->type.primary.ident.clen), 32);
clen = vd->type.primary.ident.clen; clen = vd->type.primary.ident.clen;
dbg("label string charsize=%i bit", clen); dbg("label string charsize=%i bit", clen);
@ -165,8 +165,8 @@ anchor:
volume_id_set_label_unicode16(id, vd->type.primary.ident.c, BE, 31); volume_id_set_label_unicode16(id, vd->type.primary.ident.c, BE, 31);
found: found:
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "udf"; // id->type = "udf";
return 0; return 0;
} }

View File

@ -199,8 +199,8 @@ int volume_id_probe_ufs(struct volume_id *id, uint64_t off)
return -1; return -1;
found: found:
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "ufs"; // id->type = "ufs";
return 0; return 0;
} }

View File

@ -23,7 +23,7 @@
void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count) void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count)
{ {
unsigned i, j; unsigned i, j;
uint16_t c; unsigned c;
j = 0; j = 0;
for (i = 0; i + 2 <= count; i += 2) { 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
str[j] = '\0'; str[j] = '\0';
} }
#ifdef UNUSED
static const char *usage_to_string(enum volume_id_usage usage_id) static const char *usage_to_string(enum volume_id_usage usage_id)
{ {
switch (usage_id) { switch (usage_id) {
@ -94,6 +95,7 @@ void volume_id_set_label_raw(struct volume_id *id, const uint8_t *buf, size_t co
memcpy(id->label_raw, buf, count); memcpy(id->label_raw, buf, count);
id->label_raw_len = count; id->label_raw_len = count;
} }
#endif
#ifdef NOT_NEEDED #ifdef NOT_NEEDED
static size_t strnlen(const char *s, size_t maxlen) static 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
unsigned i; unsigned i;
unsigned count = 0; unsigned count = 0;
switch(format) { switch (format) {
case UUID_DOS: case UUID_DOS:
count = 4; count = 4;
break; break;
@ -143,20 +145,21 @@ void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_form
count = 16; count = 16;
break; break;
case UUID_DCE_STRING: case UUID_DCE_STRING:
count = 36; /* 36 is ok, id->uuid has one extra byte for NUL */
count = VOLUME_ID_UUID_SIZE;
break; break;
} }
memcpy(id->uuid_raw, buf, count); // memcpy(id->uuid_raw, buf, count);
id->uuid_raw_len = count; // id->uuid_raw_len = count;
/* if set, create string in the same format, the native platform uses */ /* if set, create string in the same format, the native platform uses */
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
if (buf[i] != 0) if (buf[i] != 0)
goto set; goto set;
return; return; /* all bytes are zero, leave it empty ("") */
set: set:
switch(format) { switch (format) {
case UUID_DOS: case UUID_DOS:
sprintf(id->uuid, "%02X%02X-%02X%02X", sprintf(id->uuid, "%02X%02X-%02X%02X",
buf[3], buf[2], buf[1], buf[0]); buf[3], buf[2], buf[1], buf[0]);

View File

@ -59,10 +59,10 @@ int volume_id_probe_via_raid(struct volume_id *id, uint64_t off, uint64_t size)
if (via->version_number > 1) if (via->version_number > 1)
return -1; return -1;
volume_id_set_usage(id, VOLUME_ID_RAID); // volume_id_set_usage(id, VOLUME_ID_RAID);
id->type_version[0] = '0' + via->version_number; // id->type_version[0] = '0' + via->version_number;
id->type_version[1] = '\0'; // id->type_version[1] = '\0';
id->type = "via_raid_member"; // id->type = "via_raid_member";
return 0; return 0;
} }

View File

@ -68,9 +68,10 @@ static const probe_fptr fs1[] = {
#if ENABLE_FEATURE_VOLUMEID_FAT #if ENABLE_FEATURE_VOLUMEID_FAT
volume_id_probe_vfat, volume_id_probe_vfat,
#endif #endif
#if ENABLE_FEATURE_VOLUMEID_MAC // This one only looks for partitions, we don't use it
volume_id_probe_mac_partition_map, //#if ENABLE_FEATURE_VOLUMEID_MAC
#endif // volume_id_probe_mac_partition_map,
//#endif
#if ENABLE_FEATURE_VOLUMEID_XFS #if ENABLE_FEATURE_VOLUMEID_XFS
volume_id_probe_xfs, volume_id_probe_xfs,
#endif #endif
@ -170,7 +171,9 @@ struct volume_id *volume_id_open_node(const char *path)
struct volume_id *id; struct volume_id *id;
int fd; int fd;
fd = xopen(path, O_RDONLY); fd = open(path, O_RDONLY);
if (fd < 0)
return NULL;
id = xzalloc(sizeof(struct volume_id)); id = xzalloc(sizeof(struct volume_id));
id->fd = fd; id->fd = fd;
///* close fd on device close */ ///* close fd on device close */
@ -209,6 +212,8 @@ void free_volume_id(struct volume_id *id)
//if (id->fd_close != 0) - always true //if (id->fd_close != 0) - always true
close(id->fd); close(id->fd);
volume_id_free_buffer(id); volume_id_free_buffer(id);
#ifdef UNUSED_PARTITION_CODE
free(id->partitions); free(id->partitions);
#endif
free(id); free(id);
} }

View File

@ -23,6 +23,7 @@
#define dbg(...) ((void)0) #define dbg(...) ((void)0)
/* #define dbg(...) bb_error_msg(__VA_ARGS__) */
/* volume_id.h */ /* volume_id.h */
@ -45,29 +46,34 @@ enum volume_id_usage {
VOLUME_ID_CRYPTO, VOLUME_ID_CRYPTO,
}; };
#ifdef UNUSED_PARTITION_CODE
struct volume_id_partition { struct volume_id_partition {
enum volume_id_usage usage_id; // const char *type;
const char *usage; // const char *usage;
const char *type; // smallint usage_id;
uint64_t off; // uint8_t pt_type_raw;
uint64_t len; // uint64_t pt_off;
uint8_t partition_type_raw; // uint64_t pt_len;
}; };
#endif
struct volume_id { struct volume_id {
uint8_t label_raw[VOLUME_ID_LABEL_SIZE]; // uint8_t label_raw[VOLUME_ID_LABEL_SIZE];
size_t label_raw_len; // size_t label_raw_len;
char label[VOLUME_ID_LABEL_SIZE+1]; char label[VOLUME_ID_LABEL_SIZE+1];
uint8_t uuid_raw[VOLUME_ID_UUID_SIZE]; // uint8_t uuid_raw[VOLUME_ID_UUID_SIZE];
size_t uuid_raw_len; // size_t uuid_raw_len;
/* uuid is stored in ASCII (not binary) form here: */
char uuid[VOLUME_ID_UUID_SIZE+1]; char uuid[VOLUME_ID_UUID_SIZE+1];
enum volume_id_usage usage_id; // char type_version[VOLUME_ID_FORMAT_SIZE];
const char *usage; // smallint usage_id;
const char *type; // const char *usage;
char type_version[VOLUME_ID_FORMAT_SIZE]; // const char *type;
#ifdef UNUSED_PARTITION_CODE
struct volume_id_partition *partitions; struct volume_id_partition *partitions;
size_t partition_count; size_t partition_count;
#endif
int fd; int fd;
uint8_t *sbbuf; uint8_t *sbbuf;
@ -143,9 +149,9 @@ enum endian {
}; };
void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count); void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count);
void volume_id_set_usage(struct volume_id *id, enum volume_id_usage usage_id); //void volume_id_set_usage(struct volume_id *id, enum volume_id_usage usage_id);
void volume_id_set_usage_part(struct volume_id_partition *part, enum volume_id_usage usage_id); //void volume_id_set_usage_part(struct volume_id_partition *part, enum volume_id_usage usage_id);
void volume_id_set_label_raw(struct volume_id *id, const uint8_t *buf, size_t count); //void volume_id_set_label_raw(struct volume_id *id, const uint8_t *buf, size_t count);
void volume_id_set_label_string(struct volume_id *id, const uint8_t *buf, size_t count); void volume_id_set_label_string(struct volume_id *id, const uint8_t *buf, size_t count);
void volume_id_set_label_unicode16(struct volume_id *id, const uint8_t *buf, enum endian endianess, size_t count); void volume_id_set_label_unicode16(struct volume_id *id, const uint8_t *buf, enum endian endianess, size_t count);
void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_format format); void 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);
int volume_id_probe_luks(struct volume_id *id, uint64_t off); int volume_id_probe_luks(struct volume_id *id, uint64_t off);
int volume_id_probe_mac_partition_map(struct volume_id *id, uint64_t off); //int volume_id_probe_mac_partition_map(struct volume_id *id, uint64_t off);
int volume_id_probe_minix(struct volume_id *id, uint64_t off); int volume_id_probe_minix(struct volume_id *id, uint64_t off);
int volume_id_probe_msdos_part_table(struct volume_id *id, uint64_t off); //int volume_id_probe_msdos_part_table(struct volume_id *id, uint64_t off);
int volume_id_probe_ntfs(struct volume_id *id, uint64_t off); int volume_id_probe_ntfs(struct volume_id *id, uint64_t off);

View File

@ -48,12 +48,12 @@ int volume_id_probe_xfs(struct volume_id *id, uint64_t off)
if (memcmp(xs->magic, "XFSB", 4) != 0) if (memcmp(xs->magic, "XFSB", 4) != 0)
return -1; return -1;
volume_id_set_label_raw(id, xs->fname, 12); // volume_id_set_label_raw(id, xs->fname, 12);
volume_id_set_label_string(id, xs->fname, 12); volume_id_set_label_string(id, xs->fname, 12);
volume_id_set_uuid(id, xs->uuid, UUID_DCE); volume_id_set_uuid(id, xs->uuid, UUID_DCE);
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "xfs"; // id->type = "xfs";
return 0; return 0;
} }