Mercurial > hg > toybox
comparison toys/other/blkid.c @ 1614:21867cda5e41 draft
Give fstype its own config symbol (separate from blkid), and fix blkid not using more accurate ext3/ext4 filesystem sub-type.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 18 Dec 2014 11:05:06 -0600 |
parents | fc1bb49e58a9 |
children |
comparison
equal
deleted
inserted
replaced
1613:96aa7ec74936 | 1614:21867cda5e41 |
---|---|
3 * Copyright 2013 Brad Conroy <bconroy@uis.edu> | 3 * Copyright 2013 Brad Conroy <bconroy@uis.edu> |
4 * | 4 * |
5 * See ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.24/libblkid-docs/api-index-full.html | 5 * See ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.24/libblkid-docs/api-index-full.html |
6 | 6 |
7 USE_BLKID(NEWTOY(blkid, "<1", TOYFLAG_BIN)) | 7 USE_BLKID(NEWTOY(blkid, "<1", TOYFLAG_BIN)) |
8 USE_BLKID(OLDTOY(fstype, blkid, "<1", TOYFLAG_BIN)) | 8 USE_FSTYPE(NEWTOY(fstype, "<1", TOYFLAG_BIN)) |
9 | 9 |
10 config BLKID | 10 config BLKID |
11 bool "blkid" | 11 bool "blkid" |
12 default y | 12 default y |
13 help | 13 help |
14 usage: blkid [block device...] | 14 usage: blkid DEV... |
15 | 15 |
16 Prints type, label and UUID of filesystem. | 16 Prints type, label and UUID of filesystem on a block device or image. |
17 | |
18 config FSTYPE | |
19 bool "fstype" | |
20 default y | |
21 help | |
22 usage: fstype DEV... | |
23 | |
24 Prints type of filesystem on a block device or image. | |
17 */ | 25 */ |
18 | 26 |
19 #define FOR_blkid | 27 #define FOR_blkid |
20 #include "toys.h" | 28 #include "toys.h" |
21 | 29 |
24 uint64_t magic; | 32 uint64_t magic; |
25 int magic_len, magic_offset, uuid_off, label_len, label_off; | 33 int magic_len, magic_offset, uuid_off, label_len, label_off; |
26 }; | 34 }; |
27 | 35 |
28 static const struct fstype fstypes[] = { | 36 static const struct fstype fstypes[] = { |
29 // ext3 = buf[1116]&4 ext4 = buf[1120]&64 | 37 {"ext2", 0xEF53, 2, 1080, 1128, 16, 1144}, // keep this first for ext3/4 check |
30 {"ext2", 0xEF53, 2, 1080, 1128, 16, 1144}, | 38 // NTFS label actually 8/16 0x4d80 but horrible: 16 bit wide characters via |
31 // label actually 8/16 0x4d80 but horrible: 16 bit wide characters via | |
32 // codepage, something called a uuid that's only 8 bytes long... | 39 // codepage, something called a uuid that's only 8 bytes long... |
33 {"ntfs", 0x5346544e, 4, 3, 0x48+(8<<24), 0, 0}, | 40 {"ntfs", 0x5346544e, 4, 3, 0x48+(8<<24), 0, 0}, |
34 | 41 |
35 {"adfs", 0xadf5, 2, 0xc00, 0,0,0}, | 42 {"adfs", 0xadf5, 2, 0xc00, 0,0,0}, |
36 {"bfs", 0x1badface, 4, 0, 0,0,0}, | 43 {"bfs", 0x1badface, 4, 0, 0,0,0}, |
122 printf(" UUID=\""); | 129 printf(" UUID=\""); |
123 for (j = 0; j < size; j++) printf("-%02x"+!(bits & (1<<j)), toybuf[uoff+j]); | 130 for (j = 0; j < size; j++) printf("-%02x"+!(bits & (1<<j)), toybuf[uoff+j]); |
124 printf("\""); | 131 printf("\""); |
125 } | 132 } |
126 | 133 |
127 printf(" TYPE=\"%s\"\n", fstypes[i].name); | 134 printf(" TYPE=\"%s\"\n", type); |
128 } | 135 } |
129 | 136 |
130 void blkid_main(void) | 137 void blkid_main(void) |
131 { | 138 { |
132 loopfiles(toys.optargs, do_blkid); | 139 loopfiles(toys.optargs, do_blkid); |
133 } | 140 } |
141 | |
142 void fstype_main(void) | |
143 { | |
144 blkid_main(); | |
145 } |