diff options
Diffstat (limited to 'util-linux/volume_id/ext.c')
-rw-r--r-- | util-linux/volume_id/ext.c | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/util-linux/volume_id/ext.c b/util-linux/volume_id/ext.c index b5194a7b5..97451067f 100644 --- a/util-linux/volume_id/ext.c +++ b/util-linux/volume_id/ext.c | |||
@@ -19,28 +19,8 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "volume_id_internal.h" | 21 | #include "volume_id_internal.h" |
22 | #include "bb_e2fs_defs.h" | ||
22 | 23 | ||
23 | struct ext2_super_block { | ||
24 | uint32_t inodes_count; | ||
25 | uint32_t blocks_count; | ||
26 | uint32_t r_blocks_count; | ||
27 | uint32_t free_blocks_count; | ||
28 | uint32_t free_inodes_count; | ||
29 | uint32_t first_data_block; | ||
30 | uint32_t log_block_size; | ||
31 | uint32_t dummy3[7]; | ||
32 | uint8_t magic[2]; | ||
33 | uint16_t state; | ||
34 | uint32_t dummy5[8]; | ||
35 | uint32_t feature_compat; | ||
36 | uint32_t feature_incompat; | ||
37 | uint32_t feature_ro_compat; | ||
38 | uint8_t uuid[16]; | ||
39 | uint8_t volume_name[16]; | ||
40 | } PACKED; | ||
41 | |||
42 | #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x00000004 | ||
43 | #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x00000008 | ||
44 | #define EXT_SUPERBLOCK_OFFSET 0x400 | 24 | #define EXT_SUPERBLOCK_OFFSET 0x400 |
45 | 25 | ||
46 | int FAST_FUNC volume_id_probe_ext(struct volume_id *id /*,uint64_t off*/) | 26 | int FAST_FUNC volume_id_probe_ext(struct volume_id *id /*,uint64_t off*/) |
@@ -54,23 +34,27 @@ int FAST_FUNC volume_id_probe_ext(struct volume_id *id /*,uint64_t off*/) | |||
54 | if (es == NULL) | 34 | if (es == NULL) |
55 | return -1; | 35 | return -1; |
56 | 36 | ||
57 | if (es->magic[0] != 0123 || es->magic[1] != 0357) { | 37 | if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) { |
58 | dbg("ext: no magic found"); | 38 | dbg("ext: no magic found"); |
59 | return -1; | 39 | return -1; |
60 | } | 40 | } |
61 | 41 | ||
62 | // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); | 42 | // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); |
63 | // volume_id_set_label_raw(id, es->volume_name, 16); | 43 | // volume_id_set_label_raw(id, es->volume_name, 16); |
64 | volume_id_set_label_string(id, es->volume_name, 16); | 44 | volume_id_set_label_string(id, (void*)es->s_volume_name, 16); |
65 | volume_id_set_uuid(id, es->uuid, UUID_DCE); | 45 | volume_id_set_uuid(id, es->s_uuid, UUID_DCE); |
66 | dbg("ext: label '%s' uuid '%s'", id->label, id->uuid); | 46 | dbg("ext: label '%s' uuid '%s'", id->label, id->uuid); |
67 | 47 | ||
68 | #if ENABLE_FEATURE_BLKID_TYPE | 48 | #if ENABLE_FEATURE_BLKID_TYPE |
69 | if ((le32_to_cpu(es->feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0) | 49 | if ((es->s_feature_ro_compat & cpu_to_le32(EXT4_FEATURE_RO_COMPAT_HUGE_FILE | EXT4_FEATURE_RO_COMPAT_DIR_NLINK)) |
50 | || (es->s_feature_incompat & cpu_to_le32(EXT4_FEATURE_INCOMPAT_EXTENTS | EXT4_FEATURE_INCOMPAT_64BIT)) | ||
51 | ) { | ||
52 | id->type = "ext4"; | ||
53 | } | ||
54 | else if (es->s_feature_compat & cpu_to_le32(EXT3_FEATURE_COMPAT_HAS_JOURNAL)) | ||
70 | id->type = "ext3"; | 55 | id->type = "ext3"; |
71 | else | 56 | else |
72 | id->type = "ext2"; | 57 | id->type = "ext2"; |
73 | #endif | 58 | #endif |
74 | |||
75 | return 0; | 59 | return 0; |
76 | } | 60 | } |