diff options
Diffstat (limited to 'e2fsprogs/blkid/probe.c')
-rw-r--r-- | e2fsprogs/blkid/probe.c | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/e2fsprogs/blkid/probe.c b/e2fsprogs/blkid/probe.c index cb21c1070..2aaa50885 100644 --- a/e2fsprogs/blkid/probe.c +++ b/e2fsprogs/blkid/probe.c | |||
@@ -41,7 +41,7 @@ static int check_mdraid(int fd, unsigned char *ret_uuid) | |||
41 | struct mdp_superblock_s *md; | 41 | struct mdp_superblock_s *md; |
42 | blkid_loff_t offset; | 42 | blkid_loff_t offset; |
43 | char buf[4096]; | 43 | char buf[4096]; |
44 | 44 | ||
45 | if (fd < 0) | 45 | if (fd < 0) |
46 | return -BLKID_ERR_PARAM; | 46 | return -BLKID_ERR_PARAM; |
47 | 47 | ||
@@ -83,7 +83,7 @@ static void get_ext2_info(blkid_dev dev, unsigned char *buf) | |||
83 | struct ext2_super_block *es = (struct ext2_super_block *) buf; | 83 | struct ext2_super_block *es = (struct ext2_super_block *) buf; |
84 | const char *label = 0; | 84 | const char *label = 0; |
85 | 85 | ||
86 | DBG(DEBUG_PROBE, printf("ext2_sb.compat = %08X:%08X:%08X\n", | 86 | DBG(DEBUG_PROBE, printf("ext2_sb.compat = %08X:%08X:%08X\n", |
87 | blkid_le32(es->s_feature_compat), | 87 | blkid_le32(es->s_feature_compat), |
88 | blkid_le32(es->s_feature_incompat), | 88 | blkid_le32(es->s_feature_incompat), |
89 | blkid_le32(es->s_feature_ro_compat))); | 89 | blkid_le32(es->s_feature_ro_compat))); |
@@ -95,8 +95,8 @@ static void get_ext2_info(blkid_dev dev, unsigned char *buf) | |||
95 | set_uuid(dev, es->s_uuid); | 95 | set_uuid(dev, es->s_uuid); |
96 | } | 96 | } |
97 | 97 | ||
98 | static int probe_ext3(int fd __BLKID_ATTR((unused)), | 98 | static int probe_ext3(int fd __BLKID_ATTR((unused)), |
99 | blkid_cache cache __BLKID_ATTR((unused)), | 99 | blkid_cache cache __BLKID_ATTR((unused)), |
100 | blkid_dev dev, | 100 | blkid_dev dev, |
101 | const struct blkid_magic *id, unsigned char *buf) | 101 | const struct blkid_magic *id, unsigned char *buf) |
102 | { | 102 | { |
@@ -105,7 +105,7 @@ static int probe_ext3(int fd __BLKID_ATTR((unused)), | |||
105 | es = (struct ext2_super_block *)buf; | 105 | es = (struct ext2_super_block *)buf; |
106 | 106 | ||
107 | /* Distinguish between jbd and ext2/3 fs */ | 107 | /* Distinguish between jbd and ext2/3 fs */ |
108 | if (blkid_le32(es->s_feature_incompat) & | 108 | if (blkid_le32(es->s_feature_incompat) & |
109 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) | 109 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) |
110 | return -BLKID_ERR_PARAM; | 110 | return -BLKID_ERR_PARAM; |
111 | 111 | ||
@@ -121,8 +121,8 @@ static int probe_ext3(int fd __BLKID_ATTR((unused)), | |||
121 | return 0; | 121 | return 0; |
122 | } | 122 | } |
123 | 123 | ||
124 | static int probe_ext2(int fd __BLKID_ATTR((unused)), | 124 | static int probe_ext2(int fd __BLKID_ATTR((unused)), |
125 | blkid_cache cache __BLKID_ATTR((unused)), | 125 | blkid_cache cache __BLKID_ATTR((unused)), |
126 | blkid_dev dev, | 126 | blkid_dev dev, |
127 | const struct blkid_magic *id, unsigned char *buf) | 127 | const struct blkid_magic *id, unsigned char *buf) |
128 | { | 128 | { |
@@ -132,7 +132,7 @@ static int probe_ext2(int fd __BLKID_ATTR((unused)), | |||
132 | es = (struct ext2_super_block *)buf; | 132 | es = (struct ext2_super_block *)buf; |
133 | 133 | ||
134 | /* Distinguish between jbd and ext2/3 fs */ | 134 | /* Distinguish between jbd and ext2/3 fs */ |
135 | if (blkid_le32(es->s_feature_incompat) & | 135 | if (blkid_le32(es->s_feature_incompat) & |
136 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) | 136 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) |
137 | return -BLKID_ERR_PARAM; | 137 | return -BLKID_ERR_PARAM; |
138 | 138 | ||
@@ -141,10 +141,10 @@ static int probe_ext2(int fd __BLKID_ATTR((unused)), | |||
141 | return 0; | 141 | return 0; |
142 | } | 142 | } |
143 | 143 | ||
144 | static int probe_jbd(int fd __BLKID_ATTR((unused)), | 144 | static int probe_jbd(int fd __BLKID_ATTR((unused)), |
145 | blkid_cache cache __BLKID_ATTR((unused)), | 145 | blkid_cache cache __BLKID_ATTR((unused)), |
146 | blkid_dev dev, | 146 | blkid_dev dev, |
147 | const struct blkid_magic *id __BLKID_ATTR((unused)), | 147 | const struct blkid_magic *id __BLKID_ATTR((unused)), |
148 | unsigned char *buf) | 148 | unsigned char *buf) |
149 | { | 149 | { |
150 | struct ext2_super_block *es = (struct ext2_super_block *) buf; | 150 | struct ext2_super_block *es = (struct ext2_super_block *) buf; |
@@ -158,10 +158,10 @@ static int probe_jbd(int fd __BLKID_ATTR((unused)), | |||
158 | return 0; | 158 | return 0; |
159 | } | 159 | } |
160 | 160 | ||
161 | static int probe_vfat(int fd __BLKID_ATTR((unused)), | 161 | static int probe_vfat(int fd __BLKID_ATTR((unused)), |
162 | blkid_cache cache __BLKID_ATTR((unused)), | 162 | blkid_cache cache __BLKID_ATTR((unused)), |
163 | blkid_dev dev, | 163 | blkid_dev dev, |
164 | const struct blkid_magic *id __BLKID_ATTR((unused)), | 164 | const struct blkid_magic *id __BLKID_ATTR((unused)), |
165 | unsigned char *buf) | 165 | unsigned char *buf) |
166 | { | 166 | { |
167 | struct vfat_super_block *vs; | 167 | struct vfat_super_block *vs; |
@@ -191,10 +191,10 @@ static int probe_vfat(int fd __BLKID_ATTR((unused)), | |||
191 | return 0; | 191 | return 0; |
192 | } | 192 | } |
193 | 193 | ||
194 | static int probe_msdos(int fd __BLKID_ATTR((unused)), | 194 | static int probe_msdos(int fd __BLKID_ATTR((unused)), |
195 | blkid_cache cache __BLKID_ATTR((unused)), | 195 | blkid_cache cache __BLKID_ATTR((unused)), |
196 | blkid_dev dev, | 196 | blkid_dev dev, |
197 | const struct blkid_magic *id __BLKID_ATTR((unused)), | 197 | const struct blkid_magic *id __BLKID_ATTR((unused)), |
198 | unsigned char *buf) | 198 | unsigned char *buf) |
199 | { | 199 | { |
200 | struct msdos_super_block *ms = (struct msdos_super_block *) buf; | 200 | struct msdos_super_block *ms = (struct msdos_super_block *) buf; |
@@ -223,10 +223,10 @@ static int probe_msdos(int fd __BLKID_ATTR((unused)), | |||
223 | return 0; | 223 | return 0; |
224 | } | 224 | } |
225 | 225 | ||
226 | static int probe_xfs(int fd __BLKID_ATTR((unused)), | 226 | static int probe_xfs(int fd __BLKID_ATTR((unused)), |
227 | blkid_cache cache __BLKID_ATTR((unused)), | 227 | blkid_cache cache __BLKID_ATTR((unused)), |
228 | blkid_dev dev, | 228 | blkid_dev dev, |
229 | const struct blkid_magic *id __BLKID_ATTR((unused)), | 229 | const struct blkid_magic *id __BLKID_ATTR((unused)), |
230 | unsigned char *buf) | 230 | unsigned char *buf) |
231 | { | 231 | { |
232 | struct xfs_super_block *xs; | 232 | struct xfs_super_block *xs; |
@@ -241,8 +241,8 @@ static int probe_xfs(int fd __BLKID_ATTR((unused)), | |||
241 | return 0; | 241 | return 0; |
242 | } | 242 | } |
243 | 243 | ||
244 | static int probe_reiserfs(int fd __BLKID_ATTR((unused)), | 244 | static int probe_reiserfs(int fd __BLKID_ATTR((unused)), |
245 | blkid_cache cache __BLKID_ATTR((unused)), | 245 | blkid_cache cache __BLKID_ATTR((unused)), |
246 | blkid_dev dev, | 246 | blkid_dev dev, |
247 | const struct blkid_magic *id, unsigned char *buf) | 247 | const struct blkid_magic *id, unsigned char *buf) |
248 | { | 248 | { |
@@ -268,10 +268,10 @@ static int probe_reiserfs(int fd __BLKID_ATTR((unused)), | |||
268 | return 0; | 268 | return 0; |
269 | } | 269 | } |
270 | 270 | ||
271 | static int probe_jfs(int fd __BLKID_ATTR((unused)), | 271 | static int probe_jfs(int fd __BLKID_ATTR((unused)), |
272 | blkid_cache cache __BLKID_ATTR((unused)), | 272 | blkid_cache cache __BLKID_ATTR((unused)), |
273 | blkid_dev dev, | 273 | blkid_dev dev, |
274 | const struct blkid_magic *id __BLKID_ATTR((unused)), | 274 | const struct blkid_magic *id __BLKID_ATTR((unused)), |
275 | unsigned char *buf) | 275 | unsigned char *buf) |
276 | { | 276 | { |
277 | struct jfs_super_block *js; | 277 | struct jfs_super_block *js; |
@@ -286,10 +286,10 @@ static int probe_jfs(int fd __BLKID_ATTR((unused)), | |||
286 | return 0; | 286 | return 0; |
287 | } | 287 | } |
288 | 288 | ||
289 | static int probe_romfs(int fd __BLKID_ATTR((unused)), | 289 | static int probe_romfs(int fd __BLKID_ATTR((unused)), |
290 | blkid_cache cache __BLKID_ATTR((unused)), | 290 | blkid_cache cache __BLKID_ATTR((unused)), |
291 | blkid_dev dev, | 291 | blkid_dev dev, |
292 | const struct blkid_magic *id __BLKID_ATTR((unused)), | 292 | const struct blkid_magic *id __BLKID_ATTR((unused)), |
293 | unsigned char *buf) | 293 | unsigned char *buf) |
294 | { | 294 | { |
295 | struct romfs_super_block *ros; | 295 | struct romfs_super_block *ros; |
@@ -340,7 +340,7 @@ static int probe_swap1(int fd, | |||
340 | /* arbitrary sanity check.. is there any garbage down there? */ | 340 | /* arbitrary sanity check.. is there any garbage down there? */ |
341 | if (sws->sws_pad[32] == 0 && sws->sws_pad[33] == 0) { | 341 | if (sws->sws_pad[32] == 0 && sws->sws_pad[33] == 0) { |
342 | if (sws->sws_volume[0]) | 342 | if (sws->sws_volume[0]) |
343 | blkid_set_tag(dev, "LABEL", sws->sws_volume, | 343 | blkid_set_tag(dev, "LABEL", sws->sws_volume, |
344 | sizeof(sws->sws_volume)); | 344 | sizeof(sws->sws_volume)); |
345 | if (sws->sws_uuid[0]) | 345 | if (sws->sws_uuid[0]) |
346 | set_uuid(dev, sws->sws_uuid); | 346 | set_uuid(dev, sws->sws_uuid); |
@@ -354,9 +354,9 @@ static const char | |||
354 | * const udf_magic[] = { "BEA01", "BOOT2", "CD001", "CDW02", "NSR02", | 354 | * const udf_magic[] = { "BEA01", "BOOT2", "CD001", "CDW02", "NSR02", |
355 | "NSR03", "TEA01", 0 }; | 355 | "NSR03", "TEA01", 0 }; |
356 | 356 | ||
357 | static int probe_udf(int fd, blkid_cache cache __BLKID_ATTR((unused)), | 357 | static int probe_udf(int fd, blkid_cache cache __BLKID_ATTR((unused)), |
358 | blkid_dev dev __BLKID_ATTR((unused)), | 358 | blkid_dev dev __BLKID_ATTR((unused)), |
359 | const struct blkid_magic *id __BLKID_ATTR((unused)), | 359 | const struct blkid_magic *id __BLKID_ATTR((unused)), |
360 | unsigned char *buf __BLKID_ATTR((unused))) | 360 | unsigned char *buf __BLKID_ATTR((unused))) |
361 | { | 361 | { |
362 | int j, bs; | 362 | int j, bs; |
@@ -396,10 +396,10 @@ static int probe_udf(int fd, blkid_cache cache __BLKID_ATTR((unused)), | |||
396 | return 1; | 396 | return 1; |
397 | } | 397 | } |
398 | 398 | ||
399 | static int probe_ocfs(int fd __BLKID_ATTR((unused)), | 399 | static int probe_ocfs(int fd __BLKID_ATTR((unused)), |
400 | blkid_cache cache __BLKID_ATTR((unused)), | 400 | blkid_cache cache __BLKID_ATTR((unused)), |
401 | blkid_dev dev, | 401 | blkid_dev dev, |
402 | const struct blkid_magic *id __BLKID_ATTR((unused)), | 402 | const struct blkid_magic *id __BLKID_ATTR((unused)), |
403 | unsigned char *buf) | 403 | unsigned char *buf) |
404 | { | 404 | { |
405 | struct ocfs_volume_header ovh; | 405 | struct ocfs_volume_header ovh; |
@@ -414,17 +414,17 @@ static int probe_ocfs(int fd __BLKID_ATTR((unused)), | |||
414 | blkid_set_tag(dev,"SEC_TYPE","ocfs1",sizeof("ocfs1")); | 414 | blkid_set_tag(dev,"SEC_TYPE","ocfs1",sizeof("ocfs1")); |
415 | else if (major >= 9) | 415 | else if (major >= 9) |
416 | blkid_set_tag(dev,"SEC_TYPE","ntocfs",sizeof("ntocfs")); | 416 | blkid_set_tag(dev,"SEC_TYPE","ntocfs",sizeof("ntocfs")); |
417 | 417 | ||
418 | blkid_set_tag(dev, "LABEL", ovl.label, ocfslabellen(ovl)); | 418 | blkid_set_tag(dev, "LABEL", ovl.label, ocfslabellen(ovl)); |
419 | blkid_set_tag(dev, "MOUNT", ovh.mount, ocfsmountlen(ovh)); | 419 | blkid_set_tag(dev, "MOUNT", ovh.mount, ocfsmountlen(ovh)); |
420 | set_uuid(dev, ovl.vol_id); | 420 | set_uuid(dev, ovl.vol_id); |
421 | return 0; | 421 | return 0; |
422 | } | 422 | } |
423 | 423 | ||
424 | static int probe_ocfs2(int fd __BLKID_ATTR((unused)), | 424 | static int probe_ocfs2(int fd __BLKID_ATTR((unused)), |
425 | blkid_cache cache __BLKID_ATTR((unused)), | 425 | blkid_cache cache __BLKID_ATTR((unused)), |
426 | blkid_dev dev, | 426 | blkid_dev dev, |
427 | const struct blkid_magic *id __BLKID_ATTR((unused)), | 427 | const struct blkid_magic *id __BLKID_ATTR((unused)), |
428 | unsigned char *buf) | 428 | unsigned char *buf) |
429 | { | 429 | { |
430 | struct ocfs2_super_block *osb; | 430 | struct ocfs2_super_block *osb; |
@@ -436,10 +436,10 @@ static int probe_ocfs2(int fd __BLKID_ATTR((unused)), | |||
436 | return 0; | 436 | return 0; |
437 | } | 437 | } |
438 | 438 | ||
439 | static int probe_oracleasm(int fd __BLKID_ATTR((unused)), | 439 | static int probe_oracleasm(int fd __BLKID_ATTR((unused)), |
440 | blkid_cache cache __BLKID_ATTR((unused)), | 440 | blkid_cache cache __BLKID_ATTR((unused)), |
441 | blkid_dev dev, | 441 | blkid_dev dev, |
442 | const struct blkid_magic *id __BLKID_ATTR((unused)), | 442 | const struct blkid_magic *id __BLKID_ATTR((unused)), |
443 | unsigned char *buf) | 443 | unsigned char *buf) |
444 | { | 444 | { |
445 | struct oracle_asm_disk_label *dl; | 445 | struct oracle_asm_disk_label *dl; |
@@ -548,13 +548,13 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) | |||
548 | diff = now - dev->bid_time; | 548 | diff = now - dev->bid_time; |
549 | 549 | ||
550 | if ((now < dev->bid_time) || | 550 | if ((now < dev->bid_time) || |
551 | (diff < BLKID_PROBE_MIN) || | 551 | (diff < BLKID_PROBE_MIN) || |
552 | (dev->bid_flags & BLKID_BID_FL_VERIFIED && | 552 | (dev->bid_flags & BLKID_BID_FL_VERIFIED && |
553 | diff < BLKID_PROBE_INTERVAL)) | 553 | diff < BLKID_PROBE_INTERVAL)) |
554 | return dev; | 554 | return dev; |
555 | 555 | ||
556 | DBG(DEBUG_PROBE, | 556 | DBG(DEBUG_PROBE, |
557 | printf("need to revalidate %s (time since last check %lu)\n", | 557 | printf("need to revalidate %s (time since last check %lu)\n", |
558 | dev->bid_name, diff)); | 558 | dev->bid_name, diff)); |
559 | 559 | ||
560 | if (((fd = open(dev->bid_name, O_RDONLY)) < 0) || | 560 | if (((fd = open(dev->bid_name, O_RDONLY)) < 0) || |
@@ -571,12 +571,12 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) | |||
571 | } | 571 | } |
572 | 572 | ||
573 | memset(bufs, 0, sizeof(bufs)); | 573 | memset(bufs, 0, sizeof(bufs)); |
574 | 574 | ||
575 | /* | 575 | /* |
576 | * Iterate over the type array. If we already know the type, | 576 | * Iterate over the type array. If we already know the type, |
577 | * then try that first. If it doesn't work, then blow away | 577 | * then try that first. If it doesn't work, then blow away |
578 | * the type information, and try again. | 578 | * the type information, and try again. |
579 | * | 579 | * |
580 | */ | 580 | */ |
581 | try_again: | 581 | try_again: |
582 | type = 0; | 582 | type = 0; |
@@ -637,7 +637,7 @@ try_again: | |||
637 | blkid_free_dev(dev); | 637 | blkid_free_dev(dev); |
638 | return NULL; | 638 | return NULL; |
639 | } | 639 | } |
640 | 640 | ||
641 | found_type: | 641 | found_type: |
642 | if (dev && type) { | 642 | if (dev && type) { |
643 | dev->bid_devno = st.st_rdev; | 643 | dev->bid_devno = st.st_rdev; |
@@ -646,7 +646,7 @@ found_type: | |||
646 | cache->bic_flags |= BLKID_BIC_FL_CHANGED; | 646 | cache->bic_flags |= BLKID_BIC_FL_CHANGED; |
647 | 647 | ||
648 | blkid_set_tag(dev, "TYPE", type, 0); | 648 | blkid_set_tag(dev, "TYPE", type, 0); |
649 | 649 | ||
650 | DBG(DEBUG_PROBE, printf("%s: devno 0x%04Lx, type %s\n", | 650 | DBG(DEBUG_PROBE, printf("%s: devno 0x%04Lx, type %s\n", |
651 | dev->bid_name, st.st_rdev, type)); | 651 | dev->bid_name, st.st_rdev, type)); |
652 | } | 652 | } |
@@ -696,7 +696,7 @@ int main(int argc, char **argv) | |||
696 | printf("\tlabel is '%s'\n", dev->bid_label); | 696 | printf("\tlabel is '%s'\n", dev->bid_label); |
697 | if (dev->bid_uuid) | 697 | if (dev->bid_uuid) |
698 | printf("\tuuid is %s\n", dev->bid_uuid); | 698 | printf("\tuuid is %s\n", dev->bid_uuid); |
699 | 699 | ||
700 | blkid_free_dev(dev); | 700 | blkid_free_dev(dev); |
701 | return (0); | 701 | return (0); |
702 | } | 702 | } |