OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

444 lines
14 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../busybox/busybox-feature-blkid-type.patch
  5. # Copyright (C) 2011 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From 90615a0c5c326fa3cf78fc719f7b16207f47395a Mon Sep 17 00:00:00 2001
  17. From: Denys Vlasenko <vda.linux@googlemail.com>
  18. Date: Wed, 29 Dec 2010 23:40:11 +0000
  19. Subject: blkid: optional support for TYPE="fstype"
  20. Adapted from patch created by T4ndeta <t4ndeta@gmail.com>
  21. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
  22. ---
  23. diff --git a/include/volume_id.h b/include/volume_id.h
  24. index 77e874d..4a78cd1 100644
  25. --- a/include/volume_id.h
  26. +++ b/include/volume_id.h
  27. @@ -28,3 +28,4 @@ void display_uuid_cache(void);
  28. * *fsname is replaced if device with such UUID or LABEL is found
  29. */
  30. int resolve_mount_spec(char **fsname);
  31. +int add_to_uuid_cache(const char *device);
  32. diff --git a/util-linux/Config.src b/util-linux/Config.src
  33. index c71b4de..dbf2b0d 100644
  34. --- a/util-linux/Config.src
  35. +++ b/util-linux/Config.src
  36. @@ -40,6 +40,13 @@ config BLKID
  37. WARNING:
  38. With all submodules selected, it will add ~8k to busybox.
  39. +config FEATURE_BLKID_TYPE
  40. + bool "Print filesystem type"
  41. + default n
  42. + depends on BLKID
  43. + help
  44. + Show TYPE="filesystem type"
  45. +
  46. config DMESG
  47. bool "dmesg"
  48. default y
  49. diff --git a/util-linux/blkid.c b/util-linux/blkid.c
  50. index 53f13a9..fe88fb3 100644
  51. --- a/util-linux/blkid.c
  52. +++ b/util-linux/blkid.c
  53. @@ -13,8 +13,13 @@
  54. //TODO: extend to take BLOCKDEV args, and show TYPE="fstype"
  55. int blkid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  56. -int blkid_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
  57. +int blkid_main(int argc UNUSED_PARAM, char **argv)
  58. {
  59. + while (*++argv) {
  60. + /* Note: bogus device names don't cause any error messages */
  61. + add_to_uuid_cache(*argv);
  62. + }
  63. +
  64. display_uuid_cache();
  65. return 0;
  66. }
  67. diff --git a/util-linux/volume_id/cramfs.c b/util-linux/volume_id/cramfs.c
  68. index b84a6f0..28e9970 100644
  69. --- a/util-linux/volume_id/cramfs.c
  70. +++ b/util-linux/volume_id/cramfs.c
  71. @@ -51,7 +51,7 @@ int FAST_FUNC volume_id_probe_cramfs(struct volume_id *id /*,uint64_t off*/)
  72. volume_id_set_label_string(id, cs->name, 16);
  73. // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
  74. -// id->type = "cramfs";
  75. + IF_FEATURE_BLKID_TYPE(id->type = "cramfs";)
  76. return 0;
  77. }
  78. diff --git a/util-linux/volume_id/ext.c b/util-linux/volume_id/ext.c
  79. index 80c217f..b5194a7 100644
  80. --- a/util-linux/volume_id/ext.c
  81. +++ b/util-linux/volume_id/ext.c
  82. @@ -65,10 +65,12 @@ int FAST_FUNC volume_id_probe_ext(struct volume_id *id /*,uint64_t off*/)
  83. volume_id_set_uuid(id, es->uuid, UUID_DCE);
  84. dbg("ext: label '%s' uuid '%s'", id->label, id->uuid);
  85. -// if ((le32_to_cpu(es->feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0)
  86. -// id->type = "ext3";
  87. -// else
  88. -// id->type = "ext2";
  89. +#if ENABLE_FEATURE_BLKID_TYPE
  90. + if ((le32_to_cpu(es->feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0)
  91. + id->type = "ext3";
  92. + else
  93. + id->type = "ext2";
  94. +#endif
  95. return 0;
  96. }
  97. diff --git a/util-linux/volume_id/fat.c b/util-linux/volume_id/fat.c
  98. index b0f427c..904fbb2 100644
  99. --- a/util-linux/volume_id/fat.c
  100. +++ b/util-linux/volume_id/fat.c
  101. @@ -332,7 +332,7 @@ int FAST_FUNC volume_id_probe_vfat(struct volume_id *id /*,uint64_t fat_partitio
  102. ret:
  103. // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
  104. -// id->type = "vfat";
  105. + IF_FEATURE_BLKID_TYPE(id->type = "vfat";)
  106. return 0;
  107. }
  108. diff --git a/util-linux/volume_id/get_devname.c b/util-linux/volume_id/get_devname.c
  109. index bf32e6a..7c99305 100644
  110. --- a/util-linux/volume_id/get_devname.c
  111. +++ b/util-linux/volume_id/get_devname.c
  112. @@ -19,14 +19,22 @@ static struct uuidCache_s {
  113. char *device;
  114. char *label;
  115. char *uc_uuid; /* prefix makes it easier to grep for */
  116. + IF_FEATURE_BLKID_TYPE(const char *type;)
  117. } *uuidCache;
  118. +#if !ENABLE_FEATURE_BLKID_TYPE
  119. +#define get_label_uuid(fd, label, uuid, type) \
  120. + get_label_uuid(fd, label, uuid)
  121. +#define uuidcache_addentry(device, label, uuid, type) \
  122. + uuidcache_addentry(device, label, uuid)
  123. +#endif
  124. +
  125. /* Returns !0 on error.
  126. * Otherwise, returns malloc'ed strings for label and uuid
  127. * (and they can't be NULL, although they can be "").
  128. * NB: closes fd. */
  129. static int
  130. -get_label_uuid(int fd, char **label, char **uuid)
  131. +get_label_uuid(int fd, char **label, char **uuid, const char **type)
  132. {
  133. int rv = 1;
  134. uint64_t size;
  135. @@ -44,7 +52,12 @@ get_label_uuid(int fd, char **label, char **uuid)
  136. if (vid->label[0] != '\0' || vid->uuid[0] != '\0') {
  137. *label = xstrndup(vid->label, sizeof(vid->label));
  138. *uuid = xstrndup(vid->uuid, sizeof(vid->uuid));
  139. +#if ENABLE_FEATURE_BLKID_TYPE
  140. + *type = vid->type;
  141. + dbg("found label '%s', uuid '%s', type '%s'", *label, *uuid, *type);
  142. +#else
  143. dbg("found label '%s', uuid '%s'", *label, *uuid);
  144. +#endif
  145. rv = 0;
  146. }
  147. ret:
  148. @@ -54,7 +67,7 @@ get_label_uuid(int fd, char **label, char **uuid)
  149. /* NB: we take ownership of (malloc'ed) label and uuid */
  150. static void
  151. -uuidcache_addentry(char *device, /*int major, int minor,*/ char *label, char *uuid)
  152. +uuidcache_addentry(char *device, /*int major, int minor,*/ char *label, char *uuid, const char *type)
  153. {
  154. struct uuidCache_s *last;
  155. @@ -72,6 +85,7 @@ uuidcache_addentry(char *device, /*int major, int minor,*/ char *label, char *uu
  156. last->device = device;
  157. last->label = label;
  158. last->uc_uuid = uuid;
  159. + IF_FEATURE_BLKID_TYPE(last->type = type;)
  160. }
  161. /* If get_label_uuid() on device_name returns success,
  162. @@ -83,10 +97,6 @@ uuidcache_check_device(const char *device,
  163. void *userData UNUSED_PARAM,
  164. int depth UNUSED_PARAM)
  165. {
  166. - char *uuid = uuid; /* for compiler */
  167. - char *label = label;
  168. - int fd;
  169. -
  170. /* note: this check rejects links to devices, among other nodes */
  171. if (!S_ISBLK(statbuf->st_mode))
  172. return TRUE;
  173. @@ -99,21 +109,15 @@ uuidcache_check_device(const char *device,
  174. if (major(statbuf->st_rdev) == 2)
  175. return TRUE;
  176. - fd = open(device, O_RDONLY);
  177. - if (fd < 0)
  178. - return TRUE;
  179. + add_to_uuid_cache(device);
  180. - /* get_label_uuid() closes fd in all cases (success & failure) */
  181. - if (get_label_uuid(fd, &label, &uuid) == 0) {
  182. - /* uuidcache_addentry() takes ownership of all three params */
  183. - uuidcache_addentry(xstrdup(device), /*ma, mi,*/ label, uuid);
  184. - }
  185. return TRUE;
  186. }
  187. static void
  188. uuidcache_init(void)
  189. {
  190. + dbg("DBG: uuidCache=%x, uuidCache");
  191. if (uuidCache)
  192. return;
  193. @@ -223,11 +227,38 @@ void display_uuid_cache(void)
  194. printf(" LABEL=\"%s\"", u->label);
  195. if (u->uc_uuid[0])
  196. printf(" UUID=\"%s\"", u->uc_uuid);
  197. +#if ENABLE_FEATURE_BLKID_TYPE
  198. + if (u->type)
  199. + printf(" TYPE=\"%s\"", u->type);
  200. +#endif
  201. bb_putchar('\n');
  202. u = u->next;
  203. }
  204. }
  205. +int add_to_uuid_cache(const char *device)
  206. +{
  207. + char *uuid = uuid; /* for compiler */
  208. + char *label = label;
  209. +#if ENABLE_FEATURE_BLKID_TYPE
  210. + const char *type = type;
  211. +#endif
  212. + int fd;
  213. +
  214. + fd = open(device, O_RDONLY);
  215. + if (fd < 0)
  216. + return 0;
  217. +
  218. + /* get_label_uuid() closes fd in all cases (success & failure) */
  219. + if (get_label_uuid(fd, &label, &uuid, &type) == 0) {
  220. + /* uuidcache_addentry() takes ownership of all four params */
  221. + uuidcache_addentry(xstrdup(device), /*ma, mi,*/ label, uuid, type);
  222. + return 1;
  223. + }
  224. + return 0;
  225. +}
  226. +
  227. +
  228. /* Used by mount and findfs */
  229. char *get_devname_from_label(const char *spec)
  230. diff --git a/util-linux/volume_id/hfs.c b/util-linux/volume_id/hfs.c
  231. index cf75851..f3f19db 100644
  232. --- a/util-linux/volume_id/hfs.c
  233. +++ b/util-linux/volume_id/hfs.c
  234. @@ -195,7 +195,7 @@ int FAST_FUNC volume_id_probe_hfs_hfsplus(struct volume_id *id /*,uint64_t off*/
  235. volume_id_set_uuid(id, hfs->finder_info.id, UUID_HFS);
  236. // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
  237. -// id->type = "hfs";
  238. + IF_FEATURE_BLKID_TYPE(id->type = "hfs";)
  239. return 0;
  240. diff --git a/util-linux/volume_id/iso9660.c b/util-linux/volume_id/iso9660.c
  241. index 1519de4..1d7693a 100644
  242. --- a/util-linux/volume_id/iso9660.c
  243. +++ b/util-linux/volume_id/iso9660.c
  244. @@ -114,7 +114,7 @@ int FAST_FUNC volume_id_probe_iso9660(struct volume_id *id /*,uint64_t off*/)
  245. found:
  246. // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
  247. -// id->type = "iso9660";
  248. + IF_FEATURE_BLKID_TYPE(id->type = "iso9660";)
  249. return 0;
  250. }
  251. diff --git a/util-linux/volume_id/jfs.c b/util-linux/volume_id/jfs.c
  252. index eb7a448..5333af2 100644
  253. --- a/util-linux/volume_id/jfs.c
  254. +++ b/util-linux/volume_id/jfs.c
  255. @@ -54,7 +54,7 @@ int FAST_FUNC volume_id_probe_jfs(struct volume_id *id /*,uint64_t off*/)
  256. volume_id_set_uuid(id, js->uuid, UUID_DCE);
  257. // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
  258. -// id->type = "jfs";
  259. + IF_FEATURE_BLKID_TYPE(id->type = "jfs";)
  260. return 0;
  261. }
  262. diff --git a/util-linux/volume_id/linux_raid.c b/util-linux/volume_id/linux_raid.c
  263. index e1c8636..761e54f 100644
  264. --- a/util-linux/volume_id/linux_raid.c
  265. +++ b/util-linux/volume_id/linux_raid.c
  266. @@ -75,7 +75,7 @@ int FAST_FUNC volume_id_probe_linux_raid(struct volume_id *id /*,uint64_t off*/,
  267. dbg("found raid signature");
  268. // volume_id_set_usage(id, VOLUME_ID_RAID);
  269. -// id->type = "linux_raid_member";
  270. + IF_FEATURE_BLKID_TYPE(id->type = "linux_raid_member";)
  271. return 0;
  272. }
  273. diff --git a/util-linux/volume_id/linux_swap.c b/util-linux/volume_id/linux_swap.c
  274. index 0aa43f3..62d5885 100644
  275. --- a/util-linux/volume_id/linux_swap.c
  276. +++ b/util-linux/volume_id/linux_swap.c
  277. @@ -73,7 +73,7 @@ int FAST_FUNC volume_id_probe_linux_swap(struct volume_id *id /*,uint64_t off*/)
  278. found:
  279. // volume_id_set_usage(id, VOLUME_ID_OTHER);
  280. -// id->type = "swap";
  281. + IF_FEATURE_BLKID_TYPE(id->type = "swap";)
  282. return 0;
  283. }
  284. diff --git a/util-linux/volume_id/luks.c b/util-linux/volume_id/luks.c
  285. index 8ab09e3..f9b3766 100644
  286. --- a/util-linux/volume_id/luks.c
  287. +++ b/util-linux/volume_id/luks.c
  288. @@ -94,7 +94,7 @@ int FAST_FUNC volume_id_probe_luks(struct volume_id *id /*,uint64_t off*/)
  289. // volume_id_set_usage(id, VOLUME_ID_CRYPTO);
  290. volume_id_set_uuid(id, header->uuid, UUID_DCE_STRING);
  291. -// id->type = "crypto_LUKS";
  292. + IF_FEATURE_BLKID_TYPE(id->type = "crypto_LUKS";)
  293. return 0;
  294. }
  295. diff --git a/util-linux/volume_id/ntfs.c b/util-linux/volume_id/ntfs.c
  296. index 17b1fe8..547f141 100644
  297. --- a/util-linux/volume_id/ntfs.c
  298. +++ b/util-linux/volume_id/ntfs.c
  299. @@ -188,7 +188,7 @@ int FAST_FUNC volume_id_probe_ntfs(struct volume_id *id /*,uint64_t off*/)
  300. found:
  301. // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
  302. -// id->type = "ntfs";
  303. + IF_FEATURE_BLKID_TYPE(id->type = "ntfs";)
  304. return 0;
  305. }
  306. diff --git a/util-linux/volume_id/ocfs2.c b/util-linux/volume_id/ocfs2.c
  307. index e6c4559..fcdb151 100644
  308. --- a/util-linux/volume_id/ocfs2.c
  309. +++ b/util-linux/volume_id/ocfs2.c
  310. @@ -101,6 +101,6 @@ int FAST_FUNC volume_id_probe_ocfs2(struct volume_id *id /*,uint64_t off*/)
  311. volume_id_set_label_string(id, os->s_label, OCFS2_MAX_VOL_LABEL_LEN < VOLUME_ID_LABEL_SIZE ?
  312. OCFS2_MAX_VOL_LABEL_LEN : VOLUME_ID_LABEL_SIZE);
  313. volume_id_set_uuid(id, os->s_uuid, UUID_DCE);
  314. -// id->type = "ocfs2";
  315. + IF_FEATURE_BLKID_TYPE(id->type = "ocfs2";)
  316. return 0;
  317. }
  318. diff --git a/util-linux/volume_id/reiserfs.c b/util-linux/volume_id/reiserfs.c
  319. index 3120b29..67b4a18 100644
  320. --- a/util-linux/volume_id/reiserfs.c
  321. +++ b/util-linux/volume_id/reiserfs.c
  322. @@ -107,7 +107,7 @@ int FAST_FUNC volume_id_probe_reiserfs(struct volume_id *id /*,uint64_t off*/)
  323. found:
  324. // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
  325. -// id->type = "reiserfs";
  326. + IF_FEATURE_BLKID_TYPE(id->type = "reiserfs";)
  327. return 0;
  328. }
  329. diff --git a/util-linux/volume_id/romfs.c b/util-linux/volume_id/romfs.c
  330. index 228e77a..15653be 100644
  331. --- a/util-linux/volume_id/romfs.c
  332. +++ b/util-linux/volume_id/romfs.c
  333. @@ -47,7 +47,7 @@ int FAST_FUNC volume_id_probe_romfs(struct volume_id *id /*,uint64_t off*/)
  334. }
  335. // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
  336. -// id->type = "romfs";
  337. + IF_FEATURE_BLKID_TYPE(id->type = "romfs";)
  338. return 0;
  339. }
  340. diff --git a/util-linux/volume_id/sysv.c b/util-linux/volume_id/sysv.c
  341. index e0fa20a..6eb9646 100644
  342. --- a/util-linux/volume_id/sysv.c
  343. +++ b/util-linux/volume_id/sysv.c
  344. @@ -99,7 +99,7 @@ int FAST_FUNC volume_id_probe_sysv(struct volume_id *id /*,uint64_t off*/)
  345. if (vs->s_magic == cpu_to_le32(SYSV_MAGIC) || vs->s_magic == cpu_to_be32(SYSV_MAGIC)) {
  346. // volume_id_set_label_raw(id, vs->s_fname, 6);
  347. volume_id_set_label_string(id, vs->s_fname, 6);
  348. -// id->type = "sysv";
  349. + IF_FEATURE_BLKID_TYPE(id->type = "sysv");
  350. goto found;
  351. }
  352. }
  353. @@ -112,7 +112,7 @@ int FAST_FUNC volume_id_probe_sysv(struct volume_id *id /*,uint64_t off*/)
  354. if (xs->s_magic == cpu_to_le32(XENIX_MAGIC) || xs->s_magic == cpu_to_be32(XENIX_MAGIC)) {
  355. // volume_id_set_label_raw(id, xs->s_fname, 6);
  356. volume_id_set_label_string(id, xs->s_fname, 6);
  357. -// id->type = "xenix";
  358. + IF_FEATURE_BLKID_TYPE(id->type = "xenix";)
  359. goto found;
  360. }
  361. }
  362. diff --git a/util-linux/volume_id/udf.c b/util-linux/volume_id/udf.c
  363. index dd25731..cd63c8d 100644
  364. --- a/util-linux/volume_id/udf.c
  365. +++ b/util-linux/volume_id/udf.c
  366. @@ -167,7 +167,6 @@ anchor:
  367. found:
  368. // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
  369. -// id->type = "udf";
  370. -
  371. + IF_FEATURE_BLKID_TYPE(id->type = "udf";)
  372. return 0;
  373. }
  374. diff --git a/util-linux/volume_id/volume_id_internal.h b/util-linux/volume_id/volume_id_internal.h
  375. index 9b808ff..1c64046 100644
  376. --- a/util-linux/volume_id/volume_id_internal.h
  377. +++ b/util-linux/volume_id/volume_id_internal.h
  378. @@ -80,7 +80,9 @@ struct volume_id {
  379. // char type_version[VOLUME_ID_FORMAT_SIZE];
  380. // smallint usage_id;
  381. // const char *usage;
  382. -// const char *type;
  383. +#if ENABLE_FEATURE_BLKID_TYPE
  384. + const char *type;
  385. +#endif
  386. };
  387. struct volume_id* FAST_FUNC volume_id_open_node(int fd);
  388. diff --git a/util-linux/volume_id/xfs.c b/util-linux/volume_id/xfs.c
  389. index 1017d07..8474602 100644
  390. --- a/util-linux/volume_id/xfs.c
  391. +++ b/util-linux/volume_id/xfs.c
  392. @@ -54,7 +54,7 @@ int FAST_FUNC volume_id_probe_xfs(struct volume_id *id /*,uint64_t off*/)
  393. volume_id_set_uuid(id, xs->uuid, UUID_DCE);
  394. // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
  395. -// id->type = "xfs";
  396. + IF_FEATURE_BLKID_TYPE(id->type = "xfs";)
  397. return 0;
  398. }
  399. --
  400. cgit v0.8.2.1