aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/Config.src7
-rw-r--r--util-linux/blkid.c7
-rw-r--r--util-linux/volume_id/cramfs.c2
-rw-r--r--util-linux/volume_id/ext.c10
-rw-r--r--util-linux/volume_id/fat.c2
-rw-r--r--util-linux/volume_id/get_devname.c59
-rw-r--r--util-linux/volume_id/hfs.c2
-rw-r--r--util-linux/volume_id/iso9660.c2
-rw-r--r--util-linux/volume_id/jfs.c2
-rw-r--r--util-linux/volume_id/linux_raid.c2
-rw-r--r--util-linux/volume_id/linux_swap.c2
-rw-r--r--util-linux/volume_id/luks.c2
-rw-r--r--util-linux/volume_id/ntfs.c2
-rw-r--r--util-linux/volume_id/ocfs2.c2
-rw-r--r--util-linux/volume_id/reiserfs.c2
-rw-r--r--util-linux/volume_id/romfs.c2
-rw-r--r--util-linux/volume_id/sysv.c4
-rw-r--r--util-linux/volume_id/udf.c3
-rw-r--r--util-linux/volume_id/volume_id_internal.h4
-rw-r--r--util-linux/volume_id/xfs.c2
20 files changed, 83 insertions, 37 deletions
diff --git a/util-linux/Config.src b/util-linux/Config.src
index c71b4de38..dbf2b0d85 100644
--- a/util-linux/Config.src
+++ b/util-linux/Config.src
@@ -40,6 +40,13 @@ config BLKID
WARNING:
With all submodules selected, it will add ~8k to busybox.
+config FEATURE_BLKID_TYPE
+ bool "Print filesystem type"
+ default n
+ depends on BLKID
+ help
+ Show TYPE="filesystem type"
+
config DMESG
bool "dmesg"
default y
diff --git a/util-linux/blkid.c b/util-linux/blkid.c
index 53f13a99c..fe88fb31d 100644
--- a/util-linux/blkid.c
+++ b/util-linux/blkid.c
@@ -13,8 +13,13 @@
//TODO: extend to take BLOCKDEV args, and show TYPE="fstype"
int blkid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int blkid_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
+int blkid_main(int argc UNUSED_PARAM, char **argv)
{
+ while (*++argv) {
+ /* Note: bogus device names don't cause any error messages */
+ add_to_uuid_cache(*argv);
+ }
+
display_uuid_cache();
return 0;
}
diff --git a/util-linux/volume_id/cramfs.c b/util-linux/volume_id/cramfs.c
index b84a6f0b2..28e997043 100644
--- a/util-linux/volume_id/cramfs.c
+++ b/util-linux/volume_id/cramfs.c
@@ -51,7 +51,7 @@ int FAST_FUNC volume_id_probe_cramfs(struct volume_id *id /*,uint64_t off*/)
volume_id_set_label_string(id, cs->name, 16);
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
-// id->type = "cramfs";
+ IF_FEATURE_BLKID_TYPE(id->type = "cramfs";)
return 0;
}
diff --git a/util-linux/volume_id/ext.c b/util-linux/volume_id/ext.c
index 80c217f98..b5194a7b5 100644
--- a/util-linux/volume_id/ext.c
+++ b/util-linux/volume_id/ext.c
@@ -65,10 +65,12 @@ int FAST_FUNC volume_id_probe_ext(struct volume_id *id /*,uint64_t off*/)
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)
-// id->type = "ext3";
-// else
-// id->type = "ext2";
+#if ENABLE_FEATURE_BLKID_TYPE
+ if ((le32_to_cpu(es->feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0)
+ id->type = "ext3";
+ else
+ id->type = "ext2";
+#endif
return 0;
}
diff --git a/util-linux/volume_id/fat.c b/util-linux/volume_id/fat.c
index b0f427c74..904fbb201 100644
--- a/util-linux/volume_id/fat.c
+++ b/util-linux/volume_id/fat.c
@@ -332,7 +332,7 @@ int FAST_FUNC volume_id_probe_vfat(struct volume_id *id /*,uint64_t fat_partitio
ret:
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
-// id->type = "vfat";
+ IF_FEATURE_BLKID_TYPE(id->type = "vfat";)
return 0;
}
diff --git a/util-linux/volume_id/get_devname.c b/util-linux/volume_id/get_devname.c
index bf32e6a8c..7c9930543 100644
--- a/util-linux/volume_id/get_devname.c
+++ b/util-linux/volume_id/get_devname.c
@@ -19,14 +19,22 @@ static struct uuidCache_s {
char *device;
char *label;
char *uc_uuid; /* prefix makes it easier to grep for */
+ IF_FEATURE_BLKID_TYPE(const char *type;)
} *uuidCache;
+#if !ENABLE_FEATURE_BLKID_TYPE
+#define get_label_uuid(fd, label, uuid, type) \
+ get_label_uuid(fd, label, uuid)
+#define uuidcache_addentry(device, label, uuid, type) \
+ uuidcache_addentry(device, label, uuid)
+#endif
+
/* Returns !0 on error.
* Otherwise, returns malloc'ed strings for label and uuid
* (and they can't be NULL, although they can be "").
* NB: closes fd. */
static int
-get_label_uuid(int fd, char **label, char **uuid)
+get_label_uuid(int fd, char **label, char **uuid, const char **type)
{
int rv = 1;
uint64_t size;
@@ -44,7 +52,12 @@ get_label_uuid(int fd, char **label, char **uuid)
if (vid->label[0] != '\0' || vid->uuid[0] != '\0') {
*label = xstrndup(vid->label, sizeof(vid->label));
*uuid = xstrndup(vid->uuid, sizeof(vid->uuid));
+#if ENABLE_FEATURE_BLKID_TYPE
+ *type = vid->type;
+ dbg("found label '%s', uuid '%s', type '%s'", *label, *uuid, *type);
+#else
dbg("found label '%s', uuid '%s'", *label, *uuid);
+#endif
rv = 0;
}
ret:
@@ -54,7 +67,7 @@ get_label_uuid(int fd, char **label, char **uuid)
/* NB: we take ownership of (malloc'ed) label and uuid */
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, const char *type)
{
struct uuidCache_s *last;
@@ -72,6 +85,7 @@ uuidcache_addentry(char *device, /*int major, int minor,*/ char *label, char *uu
last->device = device;
last->label = label;
last->uc_uuid = uuid;
+ IF_FEATURE_BLKID_TYPE(last->type = type;)
}
/* If get_label_uuid() on device_name returns success,
@@ -83,10 +97,6 @@ uuidcache_check_device(const char *device,
void *userData UNUSED_PARAM,
int depth UNUSED_PARAM)
{
- char *uuid = uuid; /* for compiler */
- char *label = label;
- int fd;
-
/* note: this check rejects links to devices, among other nodes */
if (!S_ISBLK(statbuf->st_mode))
return TRUE;
@@ -99,21 +109,15 @@ uuidcache_check_device(const char *device,
if (major(statbuf->st_rdev) == 2)
return TRUE;
- fd = open(device, O_RDONLY);
- if (fd < 0)
- return TRUE;
+ add_to_uuid_cache(device);
- /* get_label_uuid() closes fd in all cases (success & failure) */
- if (get_label_uuid(fd, &label, &uuid) == 0) {
- /* uuidcache_addentry() takes ownership of all three params */
- uuidcache_addentry(xstrdup(device), /*ma, mi,*/ label, uuid);
- }
return TRUE;
}
static void
uuidcache_init(void)
{
+ dbg("DBG: uuidCache=%x, uuidCache");
if (uuidCache)
return;
@@ -223,11 +227,38 @@ void display_uuid_cache(void)
printf(" LABEL=\"%s\"", u->label);
if (u->uc_uuid[0])
printf(" UUID=\"%s\"", u->uc_uuid);
+#if ENABLE_FEATURE_BLKID_TYPE
+ if (u->type)
+ printf(" TYPE=\"%s\"", u->type);
+#endif
bb_putchar('\n');
u = u->next;
}
}
+int add_to_uuid_cache(const char *device)
+{
+ char *uuid = uuid; /* for compiler */
+ char *label = label;
+#if ENABLE_FEATURE_BLKID_TYPE
+ const char *type = type;
+#endif
+ int fd;
+
+ fd = open(device, O_RDONLY);
+ if (fd < 0)
+ return 0;
+
+ /* get_label_uuid() closes fd in all cases (success & failure) */
+ if (get_label_uuid(fd, &label, &uuid, &type) == 0) {
+ /* uuidcache_addentry() takes ownership of all four params */
+ uuidcache_addentry(xstrdup(device), /*ma, mi,*/ label, uuid, type);
+ return 1;
+ }
+ return 0;
+}
+
+
/* Used by mount and findfs */
char *get_devname_from_label(const char *spec)
diff --git a/util-linux/volume_id/hfs.c b/util-linux/volume_id/hfs.c
index cf7585138..f3f19dba7 100644
--- a/util-linux/volume_id/hfs.c
+++ b/util-linux/volume_id/hfs.c
@@ -195,7 +195,7 @@ int FAST_FUNC volume_id_probe_hfs_hfsplus(struct volume_id *id /*,uint64_t off*/
volume_id_set_uuid(id, hfs->finder_info.id, UUID_HFS);
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
-// id->type = "hfs";
+ IF_FEATURE_BLKID_TYPE(id->type = "hfs";)
return 0;
diff --git a/util-linux/volume_id/iso9660.c b/util-linux/volume_id/iso9660.c
index 1519de496..1d7693a9c 100644
--- a/util-linux/volume_id/iso9660.c
+++ b/util-linux/volume_id/iso9660.c
@@ -114,7 +114,7 @@ int FAST_FUNC volume_id_probe_iso9660(struct volume_id *id /*,uint64_t off*/)
found:
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
-// id->type = "iso9660";
+ IF_FEATURE_BLKID_TYPE(id->type = "iso9660";)
return 0;
}
diff --git a/util-linux/volume_id/jfs.c b/util-linux/volume_id/jfs.c
index eb7a44872..5333af2c3 100644
--- a/util-linux/volume_id/jfs.c
+++ b/util-linux/volume_id/jfs.c
@@ -54,7 +54,7 @@ int FAST_FUNC volume_id_probe_jfs(struct volume_id *id /*,uint64_t off*/)
volume_id_set_uuid(id, js->uuid, UUID_DCE);
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
-// id->type = "jfs";
+ IF_FEATURE_BLKID_TYPE(id->type = "jfs";)
return 0;
}
diff --git a/util-linux/volume_id/linux_raid.c b/util-linux/volume_id/linux_raid.c
index e1c86369d..761e54f9f 100644
--- a/util-linux/volume_id/linux_raid.c
+++ b/util-linux/volume_id/linux_raid.c
@@ -75,7 +75,7 @@ int FAST_FUNC volume_id_probe_linux_raid(struct volume_id *id /*,uint64_t off*/,
dbg("found raid signature");
// volume_id_set_usage(id, VOLUME_ID_RAID);
-// id->type = "linux_raid_member";
+ IF_FEATURE_BLKID_TYPE(id->type = "linux_raid_member";)
return 0;
}
diff --git a/util-linux/volume_id/linux_swap.c b/util-linux/volume_id/linux_swap.c
index 0aa43f3de..62d588522 100644
--- a/util-linux/volume_id/linux_swap.c
+++ b/util-linux/volume_id/linux_swap.c
@@ -73,7 +73,7 @@ int FAST_FUNC volume_id_probe_linux_swap(struct volume_id *id /*,uint64_t off*/)
found:
// volume_id_set_usage(id, VOLUME_ID_OTHER);
-// id->type = "swap";
+ IF_FEATURE_BLKID_TYPE(id->type = "swap";)
return 0;
}
diff --git a/util-linux/volume_id/luks.c b/util-linux/volume_id/luks.c
index 8ab09e381..f9b376672 100644
--- a/util-linux/volume_id/luks.c
+++ b/util-linux/volume_id/luks.c
@@ -94,7 +94,7 @@ int FAST_FUNC volume_id_probe_luks(struct volume_id *id /*,uint64_t off*/)
// volume_id_set_usage(id, VOLUME_ID_CRYPTO);
volume_id_set_uuid(id, header->uuid, UUID_DCE_STRING);
-// id->type = "crypto_LUKS";
+ IF_FEATURE_BLKID_TYPE(id->type = "crypto_LUKS";)
return 0;
}
diff --git a/util-linux/volume_id/ntfs.c b/util-linux/volume_id/ntfs.c
index 17b1fe8b3..547f141c9 100644
--- a/util-linux/volume_id/ntfs.c
+++ b/util-linux/volume_id/ntfs.c
@@ -188,7 +188,7 @@ int FAST_FUNC volume_id_probe_ntfs(struct volume_id *id /*,uint64_t off*/)
found:
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
-// id->type = "ntfs";
+ IF_FEATURE_BLKID_TYPE(id->type = "ntfs";)
return 0;
}
diff --git a/util-linux/volume_id/ocfs2.c b/util-linux/volume_id/ocfs2.c
index e6c455965..fcdb15192 100644
--- a/util-linux/volume_id/ocfs2.c
+++ b/util-linux/volume_id/ocfs2.c
@@ -101,6 +101,6 @@ int FAST_FUNC volume_id_probe_ocfs2(struct volume_id *id /*,uint64_t off*/)
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);
volume_id_set_uuid(id, os->s_uuid, UUID_DCE);
-// id->type = "ocfs2";
+ IF_FEATURE_BLKID_TYPE(id->type = "ocfs2";)
return 0;
}
diff --git a/util-linux/volume_id/reiserfs.c b/util-linux/volume_id/reiserfs.c
index 3120b29a0..67b4a1877 100644
--- a/util-linux/volume_id/reiserfs.c
+++ b/util-linux/volume_id/reiserfs.c
@@ -107,7 +107,7 @@ int FAST_FUNC volume_id_probe_reiserfs(struct volume_id *id /*,uint64_t off*/)
found:
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
-// id->type = "reiserfs";
+ IF_FEATURE_BLKID_TYPE(id->type = "reiserfs";)
return 0;
}
diff --git a/util-linux/volume_id/romfs.c b/util-linux/volume_id/romfs.c
index 228e77a41..15653bedf 100644
--- a/util-linux/volume_id/romfs.c
+++ b/util-linux/volume_id/romfs.c
@@ -47,7 +47,7 @@ int FAST_FUNC volume_id_probe_romfs(struct volume_id *id /*,uint64_t off*/)
}
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
-// id->type = "romfs";
+ IF_FEATURE_BLKID_TYPE(id->type = "romfs";)
return 0;
}
diff --git a/util-linux/volume_id/sysv.c b/util-linux/volume_id/sysv.c
index e0fa20a8c..6eb96464d 100644
--- a/util-linux/volume_id/sysv.c
+++ b/util-linux/volume_id/sysv.c
@@ -99,7 +99,7 @@ int FAST_FUNC volume_id_probe_sysv(struct volume_id *id /*,uint64_t off*/)
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_string(id, vs->s_fname, 6);
-// id->type = "sysv";
+ IF_FEATURE_BLKID_TYPE(id->type = "sysv");
goto found;
}
}
@@ -112,7 +112,7 @@ int FAST_FUNC volume_id_probe_sysv(struct volume_id *id /*,uint64_t off*/)
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_string(id, xs->s_fname, 6);
-// id->type = "xenix";
+ IF_FEATURE_BLKID_TYPE(id->type = "xenix";)
goto found;
}
}
diff --git a/util-linux/volume_id/udf.c b/util-linux/volume_id/udf.c
index dd2573171..cd63c8d8a 100644
--- a/util-linux/volume_id/udf.c
+++ b/util-linux/volume_id/udf.c
@@ -167,7 +167,6 @@ anchor:
found:
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
-// id->type = "udf";
-
+ IF_FEATURE_BLKID_TYPE(id->type = "udf";)
return 0;
}
diff --git a/util-linux/volume_id/volume_id_internal.h b/util-linux/volume_id/volume_id_internal.h
index 9b808ff6b..1c64046e5 100644
--- a/util-linux/volume_id/volume_id_internal.h
+++ b/util-linux/volume_id/volume_id_internal.h
@@ -80,7 +80,9 @@ struct volume_id {
// char type_version[VOLUME_ID_FORMAT_SIZE];
// smallint usage_id;
// const char *usage;
-// const char *type;
+#if ENABLE_FEATURE_BLKID_TYPE
+ const char *type;
+#endif
};
struct volume_id* FAST_FUNC volume_id_open_node(int fd);
diff --git a/util-linux/volume_id/xfs.c b/util-linux/volume_id/xfs.c
index 1017d077b..84746020e 100644
--- a/util-linux/volume_id/xfs.c
+++ b/util-linux/volume_id/xfs.c
@@ -54,7 +54,7 @@ int FAST_FUNC volume_id_probe_xfs(struct volume_id *id /*,uint64_t off*/)
volume_id_set_uuid(id, xs->uuid, UUID_DCE);
// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
-// id->type = "xfs";
+ IF_FEATURE_BLKID_TYPE(id->type = "xfs";)
return 0;
}