• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 68f7ce71106d083f8e7828a77264224930cc059e Mon Sep 17 00:00:00 2001
2From: lvyongzhao <lvyongzhao1@huawei.com>
3Date: Thu, 22 May 2025 18:40:35 +0800
4Subject: [PATCH] blkid support skip specified filesystem
5
6Signed-off-by: lvyongzhao <lvyongzhao1@huawei.com>
7---
8 lib/blkid/blkidP.h | 2 ++
9 lib/blkid/probe.c  | 8 +++++---
10 misc/blkid.c       | 6 +++++-
11 3 files changed, 12 insertions(+), 4 deletions(-)
12
13diff --git a/lib/blkid/blkidP.h b/lib/blkid/blkidP.h
14index b3fe4a6..e300f27 100644
15--- a/lib/blkid/blkidP.h
16+++ b/lib/blkid/blkidP.h
17@@ -167,6 +167,8 @@ static inline int blkidP_is_disk_device(mode_t mode)
18 #endif
19 }
20
21+extern const char *g_no_check_fs;
22+
23 /* devno.c */
24 struct dir_list {
25 	char	*name;
26diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
27index b8b6558..a4ea41e 100644
28--- a/lib/blkid/probe.c
29+++ b/lib/blkid/probe.c
30@@ -38,6 +38,8 @@
31 #include "uuid/uuid.h"
32 #include "probe.h"
33
34+const char *g_no_check_fs = "unknown";
35+
36 static int figure_label_len(const unsigned char *label, int len)
37 {
38 	const unsigned char *end = label + len - 1;
39@@ -1730,15 +1732,15 @@ try_again:
40 	if (!dev->bid_type || !strcmp(dev->bid_type, "mdraid")) {
41 		uuid_t	uuid;
42
43-		if (check_mdraid(probe.fd, uuid) == 0) {
44+		if (strcmp(g_no_check_fs, "mdraid") && check_mdraid(probe.fd, uuid) == 0) {
45 			set_uuid(dev, uuid, 0);
46 			type = "mdraid";
47 			goto found_type;
48 		}
49 	}
50 	for (id = type_array; id->bim_type; id++) {
51-		if (dev->bid_type &&
52-		    strcmp(id->bim_type, dev->bid_type))
53+		if ((dev->bid_type && strcmp(id->bim_type, dev->bid_type)) ||
54+			!strcmp(g_no_check_fs, id->bim_type))
55 			continue;
56
57 		idx = id->bim_kboff + (id->bim_sboff >> 10);
58diff --git a/misc/blkid.c b/misc/blkid.c
59index 472f017..368f3f5 100644
60--- a/misc/blkid.c
61+++ b/misc/blkid.c
62@@ -57,6 +57,7 @@ static void usage(int error)
63 		"\t-h\tprint this usage message and exit\n"
64 		"\t-g\tgarbage collect the blkid cache\n"
65 		"\t-s\tshow specified tag(s) (default show all tags)\n"
66+		"\t-n\tskip specified filesystem check\n"
67 		"\t-t\tfind device with a specific token (NAME=value pair)\n"
68 		"\t-l\tlookup the the first device with arguments specified by -t\n"
69 		"\t-v\tprint version and exit\n"
70@@ -292,7 +293,7 @@ int main(int argc, char **argv)
71 	int lookup = 0, gc = 0;
72 	int c;
73
74-	while ((c = getopt (argc, argv, "c:f:ghlLo:s:t:w:v")) != EOF)
75+	while ((c = getopt (argc, argv, "c:f:ghlLo:s:t:w:v:n:")) != EOF)
76 		switch (c) {
77 		case 'c':
78 			read = optarg;
79@@ -350,6 +351,9 @@ int main(int argc, char **argv)
80 		case 'w':
81 			write = optarg;
82 			break;
83+		case 'n':
84+			g_no_check_fs = optarg;
85+			break;
86 		case 'h':
87 			err = 0;
88 			/* fallthrough */
89--
902.34.1
91
92