mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] busybox: add patch for blkid
@ 2012-05-28 12:42 Bart vdr. Meulen
  0 siblings, 0 replies; only message in thread
From: Bart vdr. Meulen @ 2012-05-28 12:42 UTC (permalink / raw)
  To: ptxdist

From: "Bart vdr. Meulen" <bartvdrmeulen@gmail.com>

Add mainline patch for busybox to allow blkid to
print filesystem types

Signed-off-by: Bart vdr. Meulen <bartvdrmeulen@gmail.com>
---
 config/busybox/util-linux/Config.in                |    7 +
 ...03-blkid_optional_support_for_type=fstype.patch |  427 ++++++++++++++++++++
 patches/busybox-1.18.5/series                      |    1 +
 3 files changed, 435 insertions(+)
 create mode 100644 patches/busybox-1.18.5/0003-blkid_optional_support_for_type=fstype.patch

diff --git a/config/busybox/util-linux/Config.in b/config/busybox/util-linux/Config.in
index 99dbca5..9b20411 100644
--- a/config/busybox/util-linux/Config.in
+++ b/config/busybox/util-linux/Config.in
@@ -50,6 +50,13 @@ config BUSYBOX_BLKID
 	  WARNING:
 	  With all submodules selected, it will add ~8k to busybox.
 
+config BUSYBOX_FEATURE_BLKID_TYPE
+	bool "Print filesystem type"
+	default n
+	depends on BUSYBOX_BLKID
+	help
+	  Show TYPE="filesystem type"
+
 config BUSYBOX_DMESG
 	bool "dmesg"
 	default y
diff --git a/patches/busybox-1.18.5/0003-blkid_optional_support_for_type=fstype.patch b/patches/busybox-1.18.5/0003-blkid_optional_support_for_type=fstype.patch
new file mode 100644
index 0000000..cd22957
--- /dev/null
+++ b/patches/busybox-1.18.5/0003-blkid_optional_support_for_type=fstype.patch
@@ -0,0 +1,427 @@
+From 90615a0c5c326fa3cf78fc719f7b16207f47395a Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux@googlemail.com>
+Date: Wed, 29 Dec 2010 23:40:11 +0000
+Subject: blkid: optional support for TYPE="fstype"
+
+Adapted from patch created by T4ndeta <t4ndeta@gmail.com>
+
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+diff --git a/include/volume_id.h b/include/volume_id.h
+index 77e874d..4a78cd1 100644
+--- a/include/volume_id.h
++++ b/include/volume_id.h
+@@ -28,3 +28,4 @@ void display_uuid_cache(void);
+  *    *fsname is replaced if device with such UUID or LABEL is found
+  */
+ int resolve_mount_spec(char **fsname);
++int add_to_uuid_cache(const char *device);
+diff --git a/util-linux/Config.src b/util-linux/Config.src
+index c71b4de..dbf2b0d 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 53f13a9..fe88fb3 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 b84a6f0..28e9970 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 80c217f..b5194a7 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 b0f427c..904fbb2 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 bf32e6a..7c99305 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 cf75851..f3f19db 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 1519de4..1d7693a 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 eb7a448..5333af2 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 e1c8636..761e54f 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 0aa43f3..62d5885 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 8ab09e3..f9b3766 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 17b1fe8..547f141 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 e6c4559..fcdb151 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 3120b29..67b4a18 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 228e77a..15653be 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 e0fa20a..6eb9646 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 dd25731..cd63c8d 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 9b808ff..1c64046 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 1017d07..8474602 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;
+ }
+
diff --git a/patches/busybox-1.18.5/series b/patches/busybox-1.18.5/series
index c6543ea..4c2a7ae 100644
--- a/patches/busybox-1.18.5/series
+++ b/patches/busybox-1.18.5/series
@@ -2,3 +2,4 @@
 0001-reactivate-check-for-tty.patch
 0002-make-constant-unsigned-to-avoid-integer-overflow.patch
 # e028d583e9f6b6fec5ad3deb8a550489  - git-ptx-patches magic
+0003-blkid_optional_support_for_type=fstype.patch
-- 
1.7.9.5


-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-05-28 12:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-28 12:42 [ptxdist] [PATCH] busybox: add patch for blkid Bart vdr. Meulen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox