packages: clean up the package folder
[openwrt/staging/yousong.git] / package / utils / busybox / patches / 007-upstream_mkfs_ext2_fixes.patch
1 --- a/e2fsprogs/e2fs_defs.h
2 +++ /dev/null
3 @@ -1,561 +0,0 @@
4 -/* vi: set sw=4 ts=4: */
5 -/*
6 - * linux/include/linux/ext2_fs.h
7 - *
8 - * Copyright (C) 1992, 1993, 1994, 1995
9 - * Remy Card (card@masi.ibp.fr)
10 - * Laboratoire MASI - Institut Blaise Pascal
11 - * Universite Pierre et Marie Curie (Paris VI)
12 - *
13 - * Copyright (C) 1991, 1992 Linus Torvalds
14 - */
15 -
16 -#ifndef LINUX_EXT2_FS_H
17 -#define LINUX_EXT2_FS_H 1
18 -
19 -/*
20 - * Special inode numbers
21 - */
22 -#define EXT2_BAD_INO 1 /* Bad blocks inode */
23 -#define EXT2_ROOT_INO 2 /* Root inode */
24 -#define EXT2_ACL_IDX_INO 3 /* ACL inode */
25 -#define EXT2_ACL_DATA_INO 4 /* ACL inode */
26 -#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
27 -#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
28 -#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */
29 -#define EXT2_JOURNAL_INO 8 /* Journal inode */
30 -
31 -/* First non-reserved inode for old ext2 filesystems */
32 -#define EXT2_GOOD_OLD_FIRST_INO 11
33 -
34 -/*
35 - * The second extended file system magic number
36 - */
37 -#define EXT2_SUPER_MAGIC 0xEF53
38 -
39 -/* Assume that user mode programs are passing in an ext2fs superblock, not
40 - * a kernel struct super_block. This will allow us to call the feature-test
41 - * macros from user land. */
42 -#define EXT2_SB(sb) (sb)
43 -
44 -/*
45 - * Maximal count of links to a file
46 - */
47 -#define EXT2_LINK_MAX 32000
48 -
49 -/*
50 - * Macro-instructions used to manage several block sizes
51 - */
52 -#define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */
53 -#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */
54 -#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE)
55 -#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE)
56 -#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
57 -#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
58 -#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
59 - EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
60 -#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
61 - EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino)
62 -#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t))
63 -
64 -/*
65 - * Macro-instructions used to manage fragments
66 - */
67 -#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
68 -#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
69 -#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
70 -#define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
71 -#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
72 -
73 -/*
74 - * ACL structures
75 - */
76 -struct ext2_acl_header { /* Header of Access Control Lists */
77 - uint32_t aclh_size;
78 - uint32_t aclh_file_count;
79 - uint32_t aclh_acle_count;
80 - uint32_t aclh_first_acle;
81 -};
82 -
83 -struct ext2_acl_entry { /* Access Control List Entry */
84 - uint32_t acle_size;
85 - uint16_t acle_perms; /* Access permissions */
86 - uint16_t acle_type; /* Type of entry */
87 - uint16_t acle_tag; /* User or group identity */
88 - uint16_t acle_pad1;
89 - uint32_t acle_next; /* Pointer on next entry for the */
90 - /* same inode or on next free entry */
91 -};
92 -
93 -/*
94 - * Structure of a blocks group descriptor
95 - */
96 -struct ext2_group_desc {
97 - uint32_t bg_block_bitmap; /* Blocks bitmap block */
98 - uint32_t bg_inode_bitmap; /* Inodes bitmap block */
99 - uint32_t bg_inode_table; /* Inodes table block */
100 - uint16_t bg_free_blocks_count; /* Free blocks count */
101 - uint16_t bg_free_inodes_count; /* Free inodes count */
102 - uint16_t bg_used_dirs_count; /* Directories count */
103 - uint16_t bg_pad;
104 - uint32_t bg_reserved[3];
105 -};
106 -
107 -/*
108 - * Data structures used by the directory indexing feature
109 - *
110 - * Note: all of the multibyte integer fields are little endian.
111 - */
112 -
113 -/*
114 - * Note: dx_root_info is laid out so that if it should somehow get
115 - * overlaid by a dirent the two low bits of the hash version will be
116 - * zero. Therefore, the hash version mod 4 should never be 0.
117 - * Sincerely, the paranoia department.
118 - */
119 -struct ext2_dx_root_info {
120 - uint32_t reserved_zero;
121 - uint8_t hash_version; /* 0 now, 1 at release */
122 - uint8_t info_length; /* 8 */
123 - uint8_t indirect_levels;
124 - uint8_t unused_flags;
125 -};
126 -
127 -#define EXT2_HASH_LEGACY 0
128 -#define EXT2_HASH_HALF_MD4 1
129 -#define EXT2_HASH_TEA 2
130 -
131 -#define EXT2_HASH_FLAG_INCOMPAT 0x1
132 -
133 -struct ext2_dx_entry {
134 - uint32_t hash;
135 - uint32_t block;
136 -};
137 -
138 -struct ext2_dx_countlimit {
139 - uint16_t limit;
140 - uint16_t count;
141 -};
142 -
143 -
144 -/*
145 - * Macro-instructions used to manage group descriptors
146 - */
147 -#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
148 -#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
149 -#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
150 -/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
151 -#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8)
152 -#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s))
153 -#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
154 -
155 -/*
156 - * Constants relative to the data blocks
157 - */
158 -#define EXT2_NDIR_BLOCKS 12
159 -#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
160 -#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
161 -#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
162 -#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
163 -
164 -/*
165 - * Inode flags
166 - */
167 -#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
168 -#define EXT2_UNRM_FL 0x00000002 /* Undelete */
169 -#define EXT2_COMPR_FL 0x00000004 /* Compress file */
170 -#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
171 -#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
172 -#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
173 -#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
174 -#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */
175 -/* Reserved for compression usage... */
176 -#define EXT2_DIRTY_FL 0x00000100
177 -#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
178 -#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */
179 -#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */
180 -/* End compression flags --- maybe not all used */
181 -#define EXT2_BTREE_FL 0x00001000 /* btree format dir */
182 -#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */
183 -#define EXT2_IMAGIC_FL 0x00002000
184 -#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
185 -#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */
186 -#define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */
187 -#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
188 -#define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */
189 -#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
190 -
191 -#define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
192 -#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */
193 -
194 -/*
195 - * ioctl commands
196 - */
197 -#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
198 -#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
199 -#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
200 -#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
201 -
202 -/*
203 - * Structure of an inode on the disk
204 - */
205 -struct ext2_inode {
206 - uint16_t i_mode; /* File mode */
207 - uint16_t i_uid; /* Low 16 bits of Owner Uid */
208 - uint32_t i_size; /* Size in bytes */
209 - uint32_t i_atime; /* Access time */
210 - uint32_t i_ctime; /* Creation time */
211 - uint32_t i_mtime; /* Modification time */
212 - uint32_t i_dtime; /* Deletion Time */
213 - uint16_t i_gid; /* Low 16 bits of Group Id */
214 - uint16_t i_links_count; /* Links count */
215 - uint32_t i_blocks; /* Blocks count */
216 - uint32_t i_flags; /* File flags */
217 - union {
218 - struct {
219 - uint32_t l_i_reserved1;
220 - } linux1;
221 - struct {
222 - uint32_t h_i_translator;
223 - } hurd1;
224 - struct {
225 - uint32_t m_i_reserved1;
226 - } masix1;
227 - } osd1; /* OS dependent 1 */
228 - uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
229 - uint32_t i_generation; /* File version (for NFS) */
230 - uint32_t i_file_acl; /* File ACL */
231 - uint32_t i_dir_acl; /* Directory ACL */
232 - uint32_t i_faddr; /* Fragment address */
233 - union {
234 - struct {
235 - uint8_t l_i_frag; /* Fragment number */
236 - uint8_t l_i_fsize; /* Fragment size */
237 - uint16_t i_pad1;
238 - uint16_t l_i_uid_high; /* these 2 fields */
239 - uint16_t l_i_gid_high; /* were reserved2[0] */
240 - uint32_t l_i_reserved2;
241 - } linux2;
242 - struct {
243 - uint8_t h_i_frag; /* Fragment number */
244 - uint8_t h_i_fsize; /* Fragment size */
245 - uint16_t h_i_mode_high;
246 - uint16_t h_i_uid_high;
247 - uint16_t h_i_gid_high;
248 - uint32_t h_i_author;
249 - } hurd2;
250 - struct {
251 - uint8_t m_i_frag; /* Fragment number */
252 - uint8_t m_i_fsize; /* Fragment size */
253 - uint16_t m_pad1;
254 - uint32_t m_i_reserved2[2];
255 - } masix2;
256 - } osd2; /* OS dependent 2 */
257 -};
258 -
259 -/*
260 - * Permanent part of an large inode on the disk
261 - */
262 -struct ext2_inode_large {
263 - uint16_t i_mode; /* File mode */
264 - uint16_t i_uid; /* Low 16 bits of Owner Uid */
265 - uint32_t i_size; /* Size in bytes */
266 - uint32_t i_atime; /* Access time */
267 - uint32_t i_ctime; /* Creation time */
268 - uint32_t i_mtime; /* Modification time */
269 - uint32_t i_dtime; /* Deletion Time */
270 - uint16_t i_gid; /* Low 16 bits of Group Id */
271 - uint16_t i_links_count; /* Links count */
272 - uint32_t i_blocks; /* Blocks count */
273 - uint32_t i_flags; /* File flags */
274 - union {
275 - struct {
276 - uint32_t l_i_reserved1;
277 - } linux1;
278 - struct {
279 - uint32_t h_i_translator;
280 - } hurd1;
281 - struct {
282 - uint32_t m_i_reserved1;
283 - } masix1;
284 - } osd1; /* OS dependent 1 */
285 - uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
286 - uint32_t i_generation; /* File version (for NFS) */
287 - uint32_t i_file_acl; /* File ACL */
288 - uint32_t i_dir_acl; /* Directory ACL */
289 - uint32_t i_faddr; /* Fragment address */
290 - union {
291 - struct {
292 - uint8_t l_i_frag; /* Fragment number */
293 - uint8_t l_i_fsize; /* Fragment size */
294 - uint16_t i_pad1;
295 - uint16_t l_i_uid_high; /* these 2 fields */
296 - uint16_t l_i_gid_high; /* were reserved2[0] */
297 - uint32_t l_i_reserved2;
298 - } linux2;
299 - struct {
300 - uint8_t h_i_frag; /* Fragment number */
301 - uint8_t h_i_fsize; /* Fragment size */
302 - uint16_t h_i_mode_high;
303 - uint16_t h_i_uid_high;
304 - uint16_t h_i_gid_high;
305 - uint32_t h_i_author;
306 - } hurd2;
307 - struct {
308 - uint8_t m_i_frag; /* Fragment number */
309 - uint8_t m_i_fsize; /* Fragment size */
310 - uint16_t m_pad1;
311 - uint32_t m_i_reserved2[2];
312 - } masix2;
313 - } osd2; /* OS dependent 2 */
314 - uint16_t i_extra_isize;
315 - uint16_t i_pad1;
316 -};
317 -
318 -#define i_size_high i_dir_acl
319 -
320 -/*
321 - * File system states
322 - */
323 -#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
324 -#define EXT2_ERROR_FS 0x0002 /* Errors detected */
325 -
326 -/*
327 - * Mount flags
328 - */
329 -#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
330 -#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
331 -#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
332 -#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
333 -#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
334 -#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
335 -#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
336 -#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
337 -
338 -#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
339 -#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
340 -#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
341 - EXT2_MOUNT_##opt)
342 -/*
343 - * Maximal mount counts between two filesystem checks
344 - */
345 -#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
346 -#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
347 -
348 -/*
349 - * Behaviour when detecting errors
350 - */
351 -#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
352 -#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
353 -#define EXT2_ERRORS_PANIC 3 /* Panic */
354 -#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
355 -
356 -/*
357 - * Structure of the super block
358 - */
359 -struct ext2_super_block {
360 - uint32_t s_inodes_count; /* Inodes count */
361 - uint32_t s_blocks_count; /* Blocks count */
362 - uint32_t s_r_blocks_count; /* Reserved blocks count */
363 - uint32_t s_free_blocks_count; /* Free blocks count */
364 - uint32_t s_free_inodes_count; /* Free inodes count */
365 - uint32_t s_first_data_block; /* First Data Block */
366 - uint32_t s_log_block_size; /* Block size */
367 - int32_t s_log_frag_size; /* Fragment size */
368 - uint32_t s_blocks_per_group; /* # Blocks per group */
369 - uint32_t s_frags_per_group; /* # Fragments per group */
370 - uint32_t s_inodes_per_group; /* # Inodes per group */
371 - uint32_t s_mtime; /* Mount time */
372 - uint32_t s_wtime; /* Write time */
373 - uint16_t s_mnt_count; /* Mount count */
374 - int16_t s_max_mnt_count; /* Maximal mount count */
375 - uint16_t s_magic; /* Magic signature */
376 - uint16_t s_state; /* File system state */
377 - uint16_t s_errors; /* Behaviour when detecting errors */
378 - uint16_t s_minor_rev_level; /* minor revision level */
379 - uint32_t s_lastcheck; /* time of last check */
380 - uint32_t s_checkinterval; /* max. time between checks */
381 - uint32_t s_creator_os; /* OS */
382 - uint32_t s_rev_level; /* Revision level */
383 - uint16_t s_def_resuid; /* Default uid for reserved blocks */
384 - uint16_t s_def_resgid; /* Default gid for reserved blocks */
385 - /*
386 - * These fields are for EXT2_DYNAMIC_REV superblocks only.
387 - *
388 - * Note: the difference between the compatible feature set and
389 - * the incompatible feature set is that if there is a bit set
390 - * in the incompatible feature set that the kernel doesn't
391 - * know about, it should refuse to mount the filesystem.
392 - *
393 - * e2fsck's requirements are more strict; if it doesn't know
394 - * about a feature in either the compatible or incompatible
395 - * feature set, it must abort and not try to meddle with
396 - * things it doesn't understand...
397 - */
398 - uint32_t s_first_ino; /* First non-reserved inode */
399 - uint16_t s_inode_size; /* size of inode structure */
400 - uint16_t s_block_group_nr; /* block group # of this superblock */
401 - uint32_t s_feature_compat; /* compatible feature set */
402 - uint32_t s_feature_incompat; /* incompatible feature set */
403 - uint32_t s_feature_ro_compat; /* readonly-compatible feature set */
404 - uint8_t s_uuid[16]; /* 128-bit uuid for volume */
405 - char s_volume_name[16]; /* volume name */
406 - char s_last_mounted[64]; /* directory where last mounted */
407 - uint32_t s_algorithm_usage_bitmap; /* For compression */
408 - /*
409 - * Performance hints. Directory preallocation should only
410 - * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
411 - */
412 - uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
413 - uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
414 - uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */
415 - /*
416 - * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
417 - */
418 - uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
419 - uint32_t s_journal_inum; /* inode number of journal file */
420 - uint32_t s_journal_dev; /* device number of journal file */
421 - uint32_t s_last_orphan; /* start of list of inodes to delete */
422 - uint32_t s_hash_seed[4]; /* HTREE hash seed */
423 - uint8_t s_def_hash_version; /* Default hash version to use */
424 - uint8_t s_jnl_backup_type; /* Default type of journal backup */
425 - uint16_t s_reserved_word_pad;
426 - uint32_t s_default_mount_opts;
427 - uint32_t s_first_meta_bg; /* First metablock group */
428 - uint32_t s_mkfs_time; /* When the filesystem was created */
429 - uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */
430 - uint32_t s_reserved[172]; /* Padding to the end of the block */
431 -};
432 -
433 -/*
434 - * Codes for operating systems
435 - */
436 -#define EXT2_OS_LINUX 0
437 -#define EXT2_OS_HURD 1
438 -#define EXT2_OS_MASIX 2
439 -#define EXT2_OS_FREEBSD 3
440 -#define EXT2_OS_LITES 4
441 -
442 -/*
443 - * Revision levels
444 - */
445 -#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
446 -#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
447 -
448 -#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
449 -#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
450 -
451 -#define EXT2_GOOD_OLD_INODE_SIZE 128
452 -
453 -/*
454 - * Journal inode backup types
455 - */
456 -#define EXT3_JNL_BACKUP_BLOCKS 1
457 -
458 -/*
459 - * Feature set definitions
460 - */
461 -
462 -#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
463 - ( EXT2_SB(sb)->s_feature_compat & (mask) )
464 -#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
465 - ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
466 -#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
467 - ( EXT2_SB(sb)->s_feature_incompat & (mask) )
468 -
469 -#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
470 -#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
471 -#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
472 -#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
473 -#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010
474 -#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
475 -
476 -#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
477 -#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
478 -/* #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 not used */
479 -
480 -#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
481 -#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
482 -#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
483 -#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
484 -#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
485 -#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040
486 -
487 -
488 -#define EXT2_FEATURE_COMPAT_SUPP 0
489 -#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE)
490 -#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
491 - EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
492 - EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
493 -
494 -/*
495 - * Default values for user and/or group using reserved blocks
496 - */
497 -#define EXT2_DEF_RESUID 0
498 -#define EXT2_DEF_RESGID 0
499 -
500 -/*
501 - * Default mount options
502 - */
503 -#define EXT2_DEFM_DEBUG 0x0001
504 -#define EXT2_DEFM_BSDGROUPS 0x0002
505 -#define EXT2_DEFM_XATTR_USER 0x0004
506 -#define EXT2_DEFM_ACL 0x0008
507 -#define EXT2_DEFM_UID16 0x0010
508 -#define EXT3_DEFM_JMODE 0x0060
509 -#define EXT3_DEFM_JMODE_DATA 0x0020
510 -#define EXT3_DEFM_JMODE_ORDERED 0x0040
511 -#define EXT3_DEFM_JMODE_WBACK 0x0060
512 -
513 -/*
514 - * Structure of a directory entry
515 - */
516 -#define EXT2_NAME_LEN 255
517 -
518 -struct ext2_dir_entry {
519 - uint32_t inode; /* Inode number */
520 - uint16_t rec_len; /* Directory entry length */
521 - uint16_t name_len; /* Name length */
522 - char name[EXT2_NAME_LEN]; /* File name */
523 -};
524 -
525 -/*
526 - * The new version of the directory entry. Since EXT2 structures are
527 - * stored in intel byte order, and the name_len field could never be
528 - * bigger than 255 chars, it's safe to reclaim the extra byte for the
529 - * file_type field.
530 - */
531 -struct ext2_dir_entry_2 {
532 - uint32_t inode; /* Inode number */
533 - uint16_t rec_len; /* Directory entry length */
534 - uint8_t name_len; /* Name length */
535 - uint8_t file_type;
536 - char name[EXT2_NAME_LEN]; /* File name */
537 -};
538 -
539 -/*
540 - * Ext2 directory file types. Only the low 3 bits are used. The
541 - * other bits are reserved for now.
542 - */
543 -#define EXT2_FT_UNKNOWN 0
544 -#define EXT2_FT_REG_FILE 1
545 -#define EXT2_FT_DIR 2
546 -#define EXT2_FT_CHRDEV 3
547 -#define EXT2_FT_BLKDEV 4
548 -#define EXT2_FT_FIFO 5
549 -#define EXT2_FT_SOCK 6
550 -#define EXT2_FT_SYMLINK 7
551 -
552 -#define EXT2_FT_MAX 8
553 -
554 -/*
555 - * EXT2_DIR_PAD defines the directory entries boundaries
556 - *
557 - * NOTE: It must be a multiple of 4
558 - */
559 -#define EXT2_DIR_PAD 4
560 -#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
561 -#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
562 - ~EXT2_DIR_ROUND)
563 -
564 -#endif
565 --- a/e2fsprogs/e2fs_lib.h
566 +++ b/e2fsprogs/e2fs_lib.h
567 @@ -7,7 +7,7 @@
568 */
569
570 /* Constants and structures */
571 -#include "e2fs_defs.h"
572 +#include "bb_e2fs_defs.h"
573
574 PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
575
576 --- a/e2fsprogs/old_e2fsprogs/e2fsck.c
577 +++ b/e2fsprogs/old_e2fsprogs/e2fsck.c
578 @@ -11577,7 +11577,7 @@ static void check_resize_inode(e2fsck_t
579 * s_reserved_gdt_blocks must be zero.
580 */
581 if (!(fs->super->s_feature_compat &
582 - EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
583 + EXT2_FEATURE_COMPAT_RESIZE_INO)) {
584 if (fs->super->s_reserved_gdt_blocks) {
585 pctx.num = fs->super->s_reserved_gdt_blocks;
586 if (fix_problem(ctx, PR_0_NONZERO_RESERVED_GDT_BLOCKS,
587 @@ -11593,7 +11593,7 @@ static void check_resize_inode(e2fsck_t
588 retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode);
589 if (retval) {
590 if (fs->super->s_feature_compat &
591 - EXT2_FEATURE_COMPAT_RESIZE_INODE)
592 + EXT2_FEATURE_COMPAT_RESIZE_INO)
593 ctx->flags |= E2F_FLAG_RESIZE_INODE;
594 return;
595 }
596 @@ -11603,7 +11603,7 @@ static void check_resize_inode(e2fsck_t
597 * the resize inode is cleared; then we're done.
598 */
599 if (!(fs->super->s_feature_compat &
600 - EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
601 + EXT2_FEATURE_COMPAT_RESIZE_INO)) {
602 for (i=0; i < EXT2_N_BLOCKS; i++) {
603 if (inode.i_block[i])
604 break;
605 --- a/e2fsprogs/old_e2fsprogs/e2p/feature.c
606 +++ b/e2fsprogs/old_e2fsprogs/e2p/feature.c
607 @@ -34,7 +34,7 @@ static const struct feature feature_list
608 "ext_attr" },
609 { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_INDEX,
610 "dir_index" },
611 - { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INODE,
612 + { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INO,
613 "resize_inode" },
614 { E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER,
615 "sparse_super" },
616 --- a/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h
617 +++ b/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h
618 @@ -475,7 +475,7 @@ struct ext2_super_block {
619 #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
620 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
621 #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
622 -#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010
623 +#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
624 #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
625
626 #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
627 --- a/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h
628 +++ b/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h
629 @@ -383,7 +383,7 @@ typedef struct ext2_icount *ext2_icount_
630 #define EXT2_LIB_FEATURE_COMPAT_SUPP (EXT2_FEATURE_COMPAT_DIR_PREALLOC|\
631 EXT2_FEATURE_COMPAT_IMAGIC_INODES|\
632 EXT3_FEATURE_COMPAT_HAS_JOURNAL|\
633 - EXT2_FEATURE_COMPAT_RESIZE_INODE|\
634 + EXT2_FEATURE_COMPAT_RESIZE_INO|\
635 EXT2_FEATURE_COMPAT_DIR_INDEX|\
636 EXT2_FEATURE_COMPAT_EXT_ATTR)
637
638 --- a/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c
639 +++ b/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c
640 @@ -284,7 +284,7 @@ retry:
641 /*
642 * check the number of reserved group descriptor table blocks
643 */
644 - if (super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE)
645 + if (super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INO)
646 rsv_gdt = calc_reserved_gdt_blocks(fs);
647 else
648 rsv_gdt = 0;
649 --- a/e2fsprogs/old_e2fsprogs/mke2fs.c
650 +++ b/e2fsprogs/old_e2fsprogs/mke2fs.c
651 @@ -757,7 +757,7 @@ static void parse_extended_opts(struct e
652
653 if (rsv_gdb > 0) {
654 sb_param->s_feature_compat |=
655 - EXT2_FEATURE_COMPAT_RESIZE_INODE;
656 + EXT2_FEATURE_COMPAT_RESIZE_INO;
657
658 sb_param->s_reserved_gdt_blocks = rsv_gdb;
659 }
660 @@ -778,7 +778,7 @@ static void parse_extended_opts(struct e
661
662 static __u32 ok_features[3] = {
663 EXT3_FEATURE_COMPAT_HAS_JOURNAL |
664 - EXT2_FEATURE_COMPAT_RESIZE_INODE |
665 + EXT2_FEATURE_COMPAT_RESIZE_INO |
666 EXT2_FEATURE_COMPAT_DIR_INDEX, /* Compat */
667 EXT2_FEATURE_INCOMPAT_FILETYPE| /* Incompat */
668 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
669 @@ -1123,7 +1123,7 @@ static int PRS(int argc, char **argv)
670 /* Since sparse_super is the default, we would only have a problem
671 * here if it was explicitly disabled.
672 */
673 - if ((param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
674 + if ((param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INO) &&
675 !(param.s_feature_ro_compat&EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
676 bb_error_msg_and_die("reserved online resize blocks not supported "
677 "on non-sparse filesystem");
678 @@ -1312,7 +1312,7 @@ int mke2fs_main (int argc, char **argv)
679 reserve_inodes(fs);
680 create_bad_block_inode(fs, bb_list);
681 if (fs->super->s_feature_compat &
682 - EXT2_FEATURE_COMPAT_RESIZE_INODE) {
683 + EXT2_FEATURE_COMPAT_RESIZE_INO) {
684 retval = ext2fs_create_resize_inode(fs);
685 mke2fs_error_msg_and_die(retval, "reserve blocks for online resize");
686 }
687 --- a/e2fsprogs/tune2fs.c
688 +++ b/e2fsprogs/tune2fs.c
689 @@ -8,7 +8,7 @@
690 */
691 #include "libbb.h"
692 #include <linux/fs.h>
693 -#include <linux/ext2_fs.h>
694 +#include "bb_e2fs_defs.h"
695
696 // storage helpers
697 char BUG_wrong_field_size(void);
698 --- /dev/null
699 +++ b/include/bb_e2fs_defs.h
700 @@ -0,0 +1,602 @@
701 +/* vi: set sw=4 ts=4: */
702 +/*
703 + * linux/include/linux/ext2_fs.h
704 + *
705 + * Copyright (C) 1992, 1993, 1994, 1995
706 + * Remy Card (card@masi.ibp.fr)
707 + * Laboratoire MASI - Institut Blaise Pascal
708 + * Universite Pierre et Marie Curie (Paris VI)
709 + *
710 + * Copyright (C) 1991, 1992 Linus Torvalds
711 + */
712 +
713 +#ifndef LINUX_EXT2_FS_H
714 +#define LINUX_EXT2_FS_H 1
715 +
716 +/*
717 + * Special inode numbers
718 + */
719 +#define EXT2_BAD_INO 1 /* Bad blocks inode */
720 +#define EXT2_ROOT_INO 2 /* Root inode */
721 +#define EXT2_ACL_IDX_INO 3 /* ACL inode */
722 +#define EXT2_ACL_DATA_INO 4 /* ACL inode */
723 +#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
724 +#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
725 +#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */
726 +#define EXT2_JOURNAL_INO 8 /* Journal inode */
727 +
728 +/* First non-reserved inode for old ext2 filesystems */
729 +#define EXT2_GOOD_OLD_FIRST_INO 11
730 +
731 +/*
732 + * The second extended file system magic number
733 + */
734 +#define EXT2_SUPER_MAGIC 0xEF53
735 +
736 +/* Assume that user mode programs are passing in an ext2fs superblock, not
737 + * a kernel struct super_block. This will allow us to call the feature-test
738 + * macros from user land. */
739 +#define EXT2_SB(sb) (sb)
740 +
741 +/*
742 + * Maximal count of links to a file
743 + */
744 +#define EXT2_LINK_MAX 32000
745 +
746 +/*
747 + * Macro-instructions used to manage several block sizes
748 + */
749 +#define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */
750 +#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */
751 +#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE)
752 +#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE)
753 +#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
754 +#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
755 +#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
756 + EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
757 +#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
758 + EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino)
759 +#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t))
760 +
761 +/*
762 + * Macro-instructions used to manage fragments
763 + */
764 +#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
765 +#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
766 +#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
767 +#define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
768 +#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
769 +
770 +/*
771 + * ACL structures
772 + */
773 +struct ext2_acl_header { /* Header of Access Control Lists */
774 + uint32_t aclh_size;
775 + uint32_t aclh_file_count;
776 + uint32_t aclh_acle_count;
777 + uint32_t aclh_first_acle;
778 +};
779 +
780 +struct ext2_acl_entry { /* Access Control List Entry */
781 + uint32_t acle_size;
782 + uint16_t acle_perms; /* Access permissions */
783 + uint16_t acle_type; /* Type of entry */
784 + uint16_t acle_tag; /* User or group identity */
785 + uint16_t acle_pad1;
786 + uint32_t acle_next; /* Pointer on next entry for the */
787 + /* same inode or on next free entry */
788 +};
789 +
790 +/*
791 + * Structure of a blocks group descriptor
792 + */
793 +struct ext2_group_desc {
794 + uint32_t bg_block_bitmap; /* Blocks bitmap block */
795 + uint32_t bg_inode_bitmap; /* Inodes bitmap block */
796 + uint32_t bg_inode_table; /* Inodes table block */
797 + uint16_t bg_free_blocks_count; /* Free blocks count */
798 + uint16_t bg_free_inodes_count; /* Free inodes count */
799 + uint16_t bg_used_dirs_count; /* Directories count */
800 + uint16_t bg_pad;
801 + uint32_t bg_reserved[3];
802 +};
803 +
804 +/*
805 + * Data structures used by the directory indexing feature
806 + *
807 + * Note: all of the multibyte integer fields are little endian.
808 + */
809 +
810 +/*
811 + * Note: dx_root_info is laid out so that if it should somehow get
812 + * overlaid by a dirent the two low bits of the hash version will be
813 + * zero. Therefore, the hash version mod 4 should never be 0.
814 + * Sincerely, the paranoia department.
815 + */
816 +struct ext2_dx_root_info {
817 + uint32_t reserved_zero;
818 + uint8_t hash_version; /* 0 now, 1 at release */
819 + uint8_t info_length; /* 8 */
820 + uint8_t indirect_levels;
821 + uint8_t unused_flags;
822 +};
823 +
824 +#define EXT2_HASH_LEGACY 0
825 +#define EXT2_HASH_HALF_MD4 1
826 +#define EXT2_HASH_TEA 2
827 +
828 +#define EXT2_HASH_FLAG_INCOMPAT 0x1
829 +
830 +struct ext2_dx_entry {
831 + uint32_t hash;
832 + uint32_t block;
833 +};
834 +
835 +struct ext2_dx_countlimit {
836 + uint16_t limit;
837 + uint16_t count;
838 +};
839 +
840 +
841 +/*
842 + * Macro-instructions used to manage group descriptors
843 + */
844 +#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
845 +#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
846 +#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
847 +/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
848 +#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8)
849 +#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s))
850 +#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
851 +
852 +/*
853 + * Constants relative to the data blocks
854 + */
855 +#define EXT2_NDIR_BLOCKS 12
856 +#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
857 +#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
858 +#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
859 +#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
860 +
861 +/*
862 + * Inode flags
863 + */
864 +#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
865 +#define EXT2_UNRM_FL 0x00000002 /* Undelete */
866 +#define EXT2_COMPR_FL 0x00000004 /* Compress file */
867 +#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
868 +#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
869 +#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
870 +#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
871 +#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */
872 +/* Reserved for compression usage... */
873 +#define EXT2_DIRTY_FL 0x00000100
874 +#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
875 +#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */
876 +#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */
877 +/* End compression flags --- maybe not all used */
878 +#define EXT2_BTREE_FL 0x00001000 /* btree format dir */
879 +#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */
880 +#define EXT2_IMAGIC_FL 0x00002000
881 +#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
882 +#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */
883 +#define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */
884 +#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
885 +#define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */
886 +#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
887 +
888 +#define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
889 +#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */
890 +
891 +/*
892 + * ioctl commands
893 + */
894 +#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
895 +#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
896 +#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
897 +#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
898 +
899 +/*
900 + * Structure of an inode on the disk
901 + */
902 +struct ext2_inode {
903 + uint16_t i_mode; /* File mode */
904 + uint16_t i_uid; /* Low 16 bits of Owner Uid */
905 + uint32_t i_size; /* Size in bytes */
906 + uint32_t i_atime; /* Access time */
907 + uint32_t i_ctime; /* Creation time */
908 + uint32_t i_mtime; /* Modification time */
909 + uint32_t i_dtime; /* Deletion Time */
910 + uint16_t i_gid; /* Low 16 bits of Group Id */
911 + uint16_t i_links_count; /* Links count */
912 + uint32_t i_blocks; /* Blocks count */
913 + uint32_t i_flags; /* File flags */
914 + union {
915 + struct {
916 + uint32_t l_i_reserved1;
917 + } linux1;
918 + struct {
919 + uint32_t h_i_translator;
920 + } hurd1;
921 + struct {
922 + uint32_t m_i_reserved1;
923 + } masix1;
924 + } osd1; /* OS dependent 1 */
925 + uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
926 + uint32_t i_generation; /* File version (for NFS) */
927 + uint32_t i_file_acl; /* File ACL */
928 + uint32_t i_dir_acl; /* Directory ACL */
929 + uint32_t i_faddr; /* Fragment address */
930 + union {
931 + struct {
932 + uint8_t l_i_frag; /* Fragment number */
933 + uint8_t l_i_fsize; /* Fragment size */
934 + uint16_t i_pad1;
935 + uint16_t l_i_uid_high; /* these 2 fields */
936 + uint16_t l_i_gid_high; /* were reserved2[0] */
937 + uint32_t l_i_reserved2;
938 + } linux2;
939 + struct {
940 + uint8_t h_i_frag; /* Fragment number */
941 + uint8_t h_i_fsize; /* Fragment size */
942 + uint16_t h_i_mode_high;
943 + uint16_t h_i_uid_high;
944 + uint16_t h_i_gid_high;
945 + uint32_t h_i_author;
946 + } hurd2;
947 + struct {
948 + uint8_t m_i_frag; /* Fragment number */
949 + uint8_t m_i_fsize; /* Fragment size */
950 + uint16_t m_pad1;
951 + uint32_t m_i_reserved2[2];
952 + } masix2;
953 + } osd2; /* OS dependent 2 */
954 +};
955 +
956 +/*
957 + * Permanent part of an large inode on the disk
958 + */
959 +struct ext2_inode_large {
960 + uint16_t i_mode; /* File mode */
961 + uint16_t i_uid; /* Low 16 bits of Owner Uid */
962 + uint32_t i_size; /* Size in bytes */
963 + uint32_t i_atime; /* Access time */
964 + uint32_t i_ctime; /* Creation time */
965 + uint32_t i_mtime; /* Modification time */
966 + uint32_t i_dtime; /* Deletion Time */
967 + uint16_t i_gid; /* Low 16 bits of Group Id */
968 + uint16_t i_links_count; /* Links count */
969 + uint32_t i_blocks; /* Blocks count */
970 + uint32_t i_flags; /* File flags */
971 + union {
972 + struct {
973 + uint32_t l_i_reserved1;
974 + } linux1;
975 + struct {
976 + uint32_t h_i_translator;
977 + } hurd1;
978 + struct {
979 + uint32_t m_i_reserved1;
980 + } masix1;
981 + } osd1; /* OS dependent 1 */
982 + uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
983 + uint32_t i_generation; /* File version (for NFS) */
984 + uint32_t i_file_acl; /* File ACL */
985 + uint32_t i_dir_acl; /* Directory ACL */
986 + uint32_t i_faddr; /* Fragment address */
987 + union {
988 + struct {
989 + uint8_t l_i_frag; /* Fragment number */
990 + uint8_t l_i_fsize; /* Fragment size */
991 + uint16_t i_pad1;
992 + uint16_t l_i_uid_high; /* these 2 fields */
993 + uint16_t l_i_gid_high; /* were reserved2[0] */
994 + uint32_t l_i_reserved2;
995 + } linux2;
996 + struct {
997 + uint8_t h_i_frag; /* Fragment number */
998 + uint8_t h_i_fsize; /* Fragment size */
999 + uint16_t h_i_mode_high;
1000 + uint16_t h_i_uid_high;
1001 + uint16_t h_i_gid_high;
1002 + uint32_t h_i_author;
1003 + } hurd2;
1004 + struct {
1005 + uint8_t m_i_frag; /* Fragment number */
1006 + uint8_t m_i_fsize; /* Fragment size */
1007 + uint16_t m_pad1;
1008 + uint32_t m_i_reserved2[2];
1009 + } masix2;
1010 + } osd2; /* OS dependent 2 */
1011 + uint16_t i_extra_isize;
1012 + uint16_t i_pad1;
1013 +};
1014 +
1015 +#define i_size_high i_dir_acl
1016 +
1017 +/*
1018 + * File system states
1019 + */
1020 +#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
1021 +#define EXT2_ERROR_FS 0x0002 /* Errors detected */
1022 +
1023 +/*
1024 + * Mount flags
1025 + */
1026 +#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
1027 +#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
1028 +#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
1029 +#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
1030 +#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
1031 +#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
1032 +#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
1033 +#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
1034 +
1035 +#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
1036 +#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
1037 +#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
1038 + EXT2_MOUNT_##opt)
1039 +/*
1040 + * Maximal mount counts between two filesystem checks
1041 + */
1042 +#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
1043 +#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
1044 +
1045 +/*
1046 + * Behaviour when detecting errors
1047 + */
1048 +#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
1049 +#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
1050 +#define EXT2_ERRORS_PANIC 3 /* Panic */
1051 +#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
1052 +
1053 +/*
1054 + * Structure of the super block
1055 + */
1056 +struct ext2_super_block {
1057 + uint32_t s_inodes_count; /* Inodes count */
1058 + uint32_t s_blocks_count; /* Blocks count */
1059 + uint32_t s_r_blocks_count; /* Reserved blocks count */
1060 + uint32_t s_free_blocks_count; /* Free blocks count */
1061 + uint32_t s_free_inodes_count; /* Free inodes count */
1062 + uint32_t s_first_data_block; /* First Data Block */
1063 + uint32_t s_log_block_size; /* Block size */
1064 + int32_t s_log_frag_size; /* Fragment size */
1065 + uint32_t s_blocks_per_group; /* # Blocks per group */
1066 + uint32_t s_frags_per_group; /* # Fragments per group */
1067 + uint32_t s_inodes_per_group; /* # Inodes per group */
1068 + uint32_t s_mtime; /* Mount time */
1069 + uint32_t s_wtime; /* Write time */
1070 + uint16_t s_mnt_count; /* Mount count */
1071 + int16_t s_max_mnt_count; /* Maximal mount count */
1072 + uint16_t s_magic; /* Magic signature */
1073 + uint16_t s_state; /* File system state */
1074 + uint16_t s_errors; /* Behaviour when detecting errors */
1075 + uint16_t s_minor_rev_level; /* minor revision level */
1076 + uint32_t s_lastcheck; /* time of last check */
1077 + uint32_t s_checkinterval; /* max. time between checks */
1078 + uint32_t s_creator_os; /* OS */
1079 + uint32_t s_rev_level; /* Revision level */
1080 + uint16_t s_def_resuid; /* Default uid for reserved blocks */
1081 + uint16_t s_def_resgid; /* Default gid for reserved blocks */
1082 + /*
1083 + * These fields are for EXT2_DYNAMIC_REV superblocks only.
1084 + *
1085 + * Note: the difference between the compatible feature set and
1086 + * the incompatible feature set is that if there is a bit set
1087 + * in the incompatible feature set that the kernel doesn't
1088 + * know about, it should refuse to mount the filesystem.
1089 + *
1090 + * e2fsck's requirements are more strict; if it doesn't know
1091 + * about a feature in either the compatible or incompatible
1092 + * feature set, it must abort and not try to meddle with
1093 + * things it doesn't understand...
1094 + */
1095 + uint32_t s_first_ino; /* First non-reserved inode */
1096 + uint16_t s_inode_size; /* size of inode structure */
1097 + uint16_t s_block_group_nr; /* block group # of this superblock */
1098 + uint32_t s_feature_compat; /* compatible feature set */
1099 + uint32_t s_feature_incompat; /* incompatible feature set */
1100 + uint32_t s_feature_ro_compat; /* readonly-compatible feature set */
1101 + uint8_t s_uuid[16]; /* 128-bit uuid for volume */
1102 + char s_volume_name[16]; /* volume name */
1103 + char s_last_mounted[64]; /* directory where last mounted */
1104 + uint32_t s_algorithm_usage_bitmap; /* For compression */
1105 + /*
1106 + * Performance hints. Directory preallocation should only
1107 + * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
1108 + */
1109 + uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
1110 + uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
1111 + uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */
1112 + /*
1113 + * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
1114 + */
1115 +/*D0*/ uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
1116 +/*E0*/ uint32_t s_journal_inum; /* inode number of journal file */
1117 + uint32_t s_journal_dev; /* device number of journal file */
1118 + uint32_t s_last_orphan; /* start of list of inodes to delete */
1119 + uint32_t s_hash_seed[4]; /* HTREE hash seed */
1120 + uint8_t s_def_hash_version; /* Default hash version to use */
1121 + uint8_t s_jnl_backup_type; /* Default type of journal backup */
1122 + uint16_t s_reserved_word_pad;
1123 +/*100*/ uint32_t s_default_mount_opts;
1124 + uint32_t s_first_meta_bg; /* First metablock group */
1125 + /* ext3 additions */
1126 + uint32_t s_mkfs_time; /* When the filesystem was created */
1127 + uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */
1128 + /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
1129 +/*150*/ uint32_t s_blocks_count_hi; /* Blocks count */
1130 + uint32_t s_r_blocks_count_hi; /* Reserved blocks count */
1131 + uint32_t s_free_blocks_count_hi; /* Free blocks count */
1132 + uint16_t s_min_extra_isize; /* All inodes have at least # bytes */
1133 + uint16_t s_want_extra_isize; /* New inodes should reserve # bytes */
1134 + uint32_t s_flags; /* Miscellaneous flags */
1135 + uint16_t s_raid_stride; /* RAID stride */
1136 + uint16_t s_mmp_interval; /* # seconds to wait in MMP checking */
1137 + uint64_t s_mmp_block; /* Block for multi-mount protection */
1138 + uint32_t s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
1139 + uint8_t s_log_groups_per_flex; /* FLEX_BG group size */
1140 + uint8_t s_reserved_char_pad2;
1141 + uint16_t s_reserved_pad;
1142 + uint32_t s_reserved[162]; /* Padding to the end of the block */
1143 +};
1144 +struct BUG_ext2_super_block {
1145 + char bug[sizeof(struct ext2_super_block) == 1024 ? 1 : -1];
1146 +};
1147 +
1148 +/*
1149 + * Codes for operating systems
1150 + */
1151 +#define EXT2_OS_LINUX 0
1152 +#define EXT2_OS_HURD 1
1153 +#define EXT2_OS_MASIX 2
1154 +#define EXT2_OS_FREEBSD 3
1155 +#define EXT2_OS_LITES 4
1156 +
1157 +/*
1158 + * Revision levels
1159 + */
1160 +#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
1161 +#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
1162 +
1163 +#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
1164 +#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
1165 +
1166 +#define EXT2_GOOD_OLD_INODE_SIZE 128
1167 +
1168 +/*
1169 + * Journal inode backup types
1170 + */
1171 +#define EXT3_JNL_BACKUP_BLOCKS 1
1172 +
1173 +/*
1174 + * Feature set definitions
1175 + */
1176 +
1177 +#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
1178 + ( EXT2_SB(sb)->s_feature_compat & (mask) )
1179 +#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
1180 + ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
1181 +#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
1182 + ( EXT2_SB(sb)->s_feature_incompat & (mask) )
1183 +
1184 +/* for s_feature_compat */
1185 +#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
1186 +#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
1187 +#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
1188 +#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
1189 +#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
1190 +#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
1191 +
1192 +/* for s_feature_ro_compat */
1193 +#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
1194 +#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
1195 +#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 /* not used */
1196 +#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
1197 +#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
1198 +#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
1199 +#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
1200 +
1201 +/* for s_feature_incompat */
1202 +#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
1203 +#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
1204 +#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
1205 +#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
1206 +#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
1207 +#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040
1208 +#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
1209 +#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
1210 +#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
1211 +
1212 +
1213 +#define EXT2_FEATURE_COMPAT_SUPP 0
1214 +#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
1215 + EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
1216 + EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
1217 +#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
1218 + EXT2_FEATURE_INCOMPAT_META_BG)
1219 +#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED (~EXT2_FEATURE_INCOMPAT_SUPP)
1220 +#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT2_FEATURE_RO_COMPAT_SUPP)
1221 +
1222 +#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
1223 + EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
1224 + EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
1225 +#define EXT3_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
1226 + EXT3_FEATURE_INCOMPAT_RECOVER| \
1227 + EXT2_FEATURE_INCOMPAT_META_BG)
1228 +#define EXT3_FEATURE_INCOMPAT_UNSUPPORTED (~EXT3_FEATURE_INCOMPAT_SUPP)
1229 +#define EXT3_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT3_FEATURE_RO_COMPAT_SUPP)
1230 +
1231 +
1232 +/*
1233 + * Default values for user and/or group using reserved blocks
1234 + */
1235 +#define EXT2_DEF_RESUID 0
1236 +#define EXT2_DEF_RESGID 0
1237 +
1238 +/*
1239 + * Default mount options
1240 + */
1241 +#define EXT2_DEFM_DEBUG 0x0001
1242 +#define EXT2_DEFM_BSDGROUPS 0x0002
1243 +#define EXT2_DEFM_XATTR_USER 0x0004
1244 +#define EXT2_DEFM_ACL 0x0008
1245 +#define EXT2_DEFM_UID16 0x0010
1246 +#define EXT3_DEFM_JMODE 0x0060
1247 +#define EXT3_DEFM_JMODE_DATA 0x0020
1248 +#define EXT3_DEFM_JMODE_ORDERED 0x0040
1249 +#define EXT3_DEFM_JMODE_WBACK 0x0060
1250 +
1251 +/*
1252 + * Structure of a directory entry
1253 + */
1254 +#define EXT2_NAME_LEN 255
1255 +
1256 +struct ext2_dir_entry {
1257 + uint32_t inode; /* Inode number */
1258 + uint16_t rec_len; /* Directory entry length */
1259 + uint16_t name_len; /* Name length */
1260 + char name[EXT2_NAME_LEN]; /* File name */
1261 +};
1262 +
1263 +/*
1264 + * The new version of the directory entry. Since EXT2 structures are
1265 + * stored in intel byte order, and the name_len field could never be
1266 + * bigger than 255 chars, it's safe to reclaim the extra byte for the
1267 + * file_type field.
1268 + */
1269 +struct ext2_dir_entry_2 {
1270 + uint32_t inode; /* Inode number */
1271 + uint16_t rec_len; /* Directory entry length */
1272 + uint8_t name_len; /* Name length */
1273 + uint8_t file_type;
1274 + char name[EXT2_NAME_LEN]; /* File name */
1275 +};
1276 +
1277 +/*
1278 + * Ext2 directory file types. Only the low 3 bits are used. The
1279 + * other bits are reserved for now.
1280 + */
1281 +#define EXT2_FT_UNKNOWN 0
1282 +#define EXT2_FT_REG_FILE 1
1283 +#define EXT2_FT_DIR 2
1284 +#define EXT2_FT_CHRDEV 3
1285 +#define EXT2_FT_BLKDEV 4
1286 +#define EXT2_FT_FIFO 5
1287 +#define EXT2_FT_SOCK 6
1288 +#define EXT2_FT_SYMLINK 7
1289 +
1290 +#define EXT2_FT_MAX 8
1291 +
1292 +/*
1293 + * EXT2_DIR_PAD defines the directory entries boundaries
1294 + *
1295 + * NOTE: It must be a multiple of 4
1296 + */
1297 +#define EXT2_DIR_PAD 4
1298 +#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
1299 +#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
1300 + ~EXT2_DIR_ROUND)
1301 +
1302 +#endif
1303 --- a/testsuite/mount.tests
1304 +++ b/testsuite/mount.tests
1305 @@ -36,7 +36,8 @@ testing "mount -o remount,mand" \
1306 "mount -o loop mount.image1m $testdir "\
1307 "&& grep -Fc $testdir </proc/mounts "\
1308 "&& mount -o remount,mand $testdir "\
1309 -"&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'" \
1310 +"&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'"\
1311 +"|| grep -F $testdir </proc/mounts" \
1312 "1\n""1\n" \
1313 "" ""
1314
1315 @@ -83,4 +84,28 @@ b
1316 "" ""
1317 SKIP=
1318
1319 +
1320 +testing "mount RO loop" "\
1321 +exec 2>&1
1322 +umount -d mount.dir 2>/dev/null
1323 +rmdir mount.dir 2>/dev/null
1324 +mkdir -p mount.dir
1325 +(
1326 +cd mount.dir || { echo 'cd error'; exit 1; }
1327 +mkdir z1 z2 || { echo 'mkdir error'; exit 1; }
1328 +mount -t tmpfs tmpfs z1 || { echo 'mount tmpfs error'; exit 1; }
1329 +dd if=/dev/zero of=z1/e2img count=10 bs=1M 2>/dev/null || { echo 'dd error'; exit 1; }
1330 +mke2fs -F z1/e2img 2>/dev/null >&2 || { echo 'mke2fs error'; exit 1; }
1331 +mount -r -o loop -t ext2 z1/e2img z2 || { echo 'mount -r -o loop error'; exit 1; }
1332 +mount -o remount,ro z1 || { echo 'mount -o remount,ro error'; exit 1; }
1333 +)
1334 +umount -d mount.dir/z2
1335 +##losetup -d /dev/loop*
1336 +umount -d mount.dir/z1
1337 +rm -rf mount.dir
1338 +echo DONE
1339 +" \
1340 +"DONE\n" "" ""
1341 +
1342 +
1343 exit $FAILCOUNT
1344 --- a/util-linux/mkfs_ext2.c
1345 +++ b/util-linux/mkfs_ext2.c
1346 @@ -48,16 +48,11 @@
1347
1348 #include "libbb.h"
1349 #include <linux/fs.h>
1350 -#include <linux/ext2_fs.h>
1351 +#include "bb_e2fs_defs.h"
1352
1353 #define ENABLE_FEATURE_MKFS_EXT2_RESERVED_GDT 0
1354 #define ENABLE_FEATURE_MKFS_EXT2_DIR_INDEX 1
1355
1356 -// from e2fsprogs
1357 -#define s_reserved_gdt_blocks s_padding1
1358 -#define s_mkfs_time s_reserved[0]
1359 -#define s_flags s_reserved[22]
1360 -
1361 #define EXT2_HASH_HALF_MD4 1
1362 #define EXT2_FLAGS_SIGNED_HASH 0x0001
1363 #define EXT2_FLAGS_UNSIGNED_HASH 0x0002
1364 @@ -482,8 +477,10 @@ int mkfs_ext2_main(int argc UNUSED_PARAM
1365 STORE_LE(sb->s_magic, EXT2_SUPER_MAGIC);
1366 STORE_LE(sb->s_inode_size, inodesize);
1367 // set "Required extra isize" and "Desired extra isize" fields to 28
1368 - if (inodesize != sizeof(*inode))
1369 - STORE_LE(sb->s_reserved[21], 0x001C001C);
1370 + if (inodesize != sizeof(*inode)) {
1371 + STORE_LE(sb->s_min_extra_isize, 0x001c);
1372 + STORE_LE(sb->s_want_extra_isize, 0x001c);
1373 + }
1374 STORE_LE(sb->s_first_ino, EXT2_GOOD_OLD_FIRST_INO);
1375 STORE_LE(sb->s_log_block_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE);
1376 STORE_LE(sb->s_log_frag_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE);
1377 --- a/util-linux/volume_id/ext.c
1378 +++ b/util-linux/volume_id/ext.c
1379 @@ -19,28 +19,8 @@
1380 */
1381
1382 #include "volume_id_internal.h"
1383 +#include "bb_e2fs_defs.h"
1384
1385 -struct ext2_super_block {
1386 - uint32_t inodes_count;
1387 - uint32_t blocks_count;
1388 - uint32_t r_blocks_count;
1389 - uint32_t free_blocks_count;
1390 - uint32_t free_inodes_count;
1391 - uint32_t first_data_block;
1392 - uint32_t log_block_size;
1393 - uint32_t dummy3[7];
1394 - uint8_t magic[2];
1395 - uint16_t state;
1396 - uint32_t dummy5[8];
1397 - uint32_t feature_compat;
1398 - uint32_t feature_incompat;
1399 - uint32_t feature_ro_compat;
1400 - uint8_t uuid[16];
1401 - uint8_t volume_name[16];
1402 -} PACKED;
1403 -
1404 -#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x00000004
1405 -#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x00000008
1406 #define EXT_SUPERBLOCK_OFFSET 0x400
1407
1408 int FAST_FUNC volume_id_probe_ext(struct volume_id *id /*,uint64_t off*/)
1409 @@ -54,23 +34,27 @@ int FAST_FUNC volume_id_probe_ext(struct
1410 if (es == NULL)
1411 return -1;
1412
1413 - if (es->magic[0] != 0123 || es->magic[1] != 0357) {
1414 + if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
1415 dbg("ext: no magic found");
1416 return -1;
1417 }
1418
1419 // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
1420 // volume_id_set_label_raw(id, es->volume_name, 16);
1421 - volume_id_set_label_string(id, es->volume_name, 16);
1422 - volume_id_set_uuid(id, es->uuid, UUID_DCE);
1423 + volume_id_set_label_string(id, (void*)es->s_volume_name, 16);
1424 + volume_id_set_uuid(id, es->s_uuid, UUID_DCE);
1425 dbg("ext: label '%s' uuid '%s'", id->label, id->uuid);
1426
1427 #if ENABLE_FEATURE_BLKID_TYPE
1428 - if ((le32_to_cpu(es->feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0)
1429 + if ((es->s_feature_ro_compat & cpu_to_le32(EXT4_FEATURE_RO_COMPAT_HUGE_FILE | EXT4_FEATURE_RO_COMPAT_DIR_NLINK))
1430 + || (es->s_feature_incompat & cpu_to_le32(EXT4_FEATURE_INCOMPAT_EXTENTS | EXT4_FEATURE_INCOMPAT_64BIT))
1431 + ) {
1432 + id->type = "ext4";
1433 + }
1434 + else if (es->s_feature_compat & cpu_to_le32(EXT3_FEATURE_COMPAT_HAS_JOURNAL))
1435 id->type = "ext3";
1436 else
1437 id->type = "ext2";
1438 #endif
1439 -
1440 return 0;
1441 }