support seeking the recorded video
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-core / busybox / busybox-1.19.4 / 0002-Create-and-use-our-own-copy-of-linux-ext2_fs.h.patch
1 From 0b2b0f31a38d77ebfb2a6416011562687ef58191 Mon Sep 17 00:00:00 2001
2 From: Denys Vlasenko <vda.linux@googlemail.com>
3 Date: Fri, 13 Apr 2012 16:39:18 +0200
4 Subject: [PATCH 01/32] Create and use our own copy of linux/ext2_fs.h
5
6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
7 ---
8  e2fsprogs/tune2fs.c        |    8 +-
9  include/bb_linux_ext2_fs.h |  547 ++++++++++++++++++++++++++++++++++++++++++++
10  util-linux/mkfs_ext2.c     |    8 +-
11  3 files changed, 549 insertions(+), 14 deletions(-)
12  create mode 100644 include/bb_linux_ext2_fs.h
13
14 diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c
15 index 8da7432..841d58a 100644
16 --- a/e2fsprogs/tune2fs.c
17 +++ b/e2fsprogs/tune2fs.c
18 @@ -8,13 +8,7 @@
19   */
20  #include "libbb.h"
21  #include <linux/fs.h>
22 -/*
23 - * Work around linux/ext2_fs.h breakage.
24 - * See https://bugzilla.kernel.org/show_bug.cgi?id=42986.
25 - */
26 -typedef mode_t bb__umode_t;
27 -#define umode_t bb__umode_t
28 -#include <linux/ext2_fs.h>
29 +#include "bb_linux_ext2_fs.h"
30  
31  // storage helpers
32  char BUG_wrong_field_size(void);
33 diff --git a/include/bb_linux_ext2_fs.h b/include/bb_linux_ext2_fs.h
34 new file mode 100644
35 index 0000000..fdc470b
36 --- /dev/null
37 +++ b/include/bb_linux_ext2_fs.h
38 @@ -0,0 +1,547 @@
39 +/*
40 + * Work around linux/ext2_fs.h breakage.
41 + * linux/ext2_fs.h might be removed from future kernel header distribution.
42 + * See https://bugzilla.kernel.org/show_bug.cgi?id=42986
43 + *
44 + * Licensed under GPLv2, see file LICENSE in this source tree.
45 + */
46 +#ifndef BB_LINUX_EXT2_FS_H
47 +#define BB_LINUX_EXT2_FS_H
48 +
49 +/*
50 + * From linux/magic.h
51 + */
52 +
53 +#define EXT2_SUPER_MAGIC        0xEF53
54 +#define EXT3_SUPER_MAGIC        0xEF53
55 +#define EXT4_SUPER_MAGIC        0xEF53
56 +
57 +/*
58 + * From linux/ext2_fs.h, with minor changes.
59 + */
60 +
61 +/*
62 + * Copyright (C) 1992, 1993, 1994, 1995
63 + * Remy Card (card@masi.ibp.fr)
64 + * Laboratoire MASI - Institut Blaise Pascal
65 + * Universite Pierre et Marie Curie (Paris VI)
66 + *
67 + *  from
68 + *
69 + *  linux/include/linux/minix_fs.h
70 + *
71 + *  Copyright (C) 1991, 1992  Linus Torvalds
72 + */
73 +
74 +/*
75 + * The second extended filesystem constants/structures
76 + */
77 +
78 +/*
79 + * Define EXT2_RESERVATION to reserve data blocks for expanding files
80 + */
81 +#define EXT2_DEFAULT_RESERVE_BLOCKS     8
82 +/*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */
83 +#define EXT2_MAX_RESERVE_BLOCKS         1027
84 +#define EXT2_RESERVE_WINDOW_NOT_ALLOCATED 0
85 +
86 +/*
87 + * Special inode numbers
88 + */
89 +#define        EXT2_BAD_INO             1      /* Bad blocks inode */
90 +#define EXT2_ROOT_INO           2      /* Root inode */
91 +#define EXT2_BOOT_LOADER_INO    5      /* Boot loader inode */
92 +#define EXT2_UNDEL_DIR_INO      6      /* Undelete directory inode */
93 +
94 +/* First non-reserved inode for old ext2 filesystems */
95 +#define EXT2_GOOD_OLD_FIRST_INO        11
96 +
97 +/* Assume that user mode programs are passing in an ext2fs superblock, not
98 + * a kernel struct super_block.  This will allow us to call the feature-test
99 + * macros from user land. */
100 +#define EXT2_SB(sb)    (sb)
101 +
102 +/*
103 + * Maximal count of links to a file
104 + */
105 +#define EXT2_LINK_MAX          32000
106 +
107 +/*
108 + * Macro-instructions used to manage several block sizes
109 + */
110 +#define EXT2_MIN_BLOCK_SIZE            1024
111 +#define        EXT2_MAX_BLOCK_SIZE             4096
112 +#define EXT2_MIN_BLOCK_LOG_SIZE                  10
113 +# define EXT2_BLOCK_SIZE(s)            (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
114 +#define        EXT2_ADDR_PER_BLOCK(s)          (EXT2_BLOCK_SIZE(s) / sizeof (uint32_t))
115 +# define EXT2_BLOCK_SIZE_BITS(s)       ((s)->s_log_block_size + 10)
116 +#define EXT2_INODE_SIZE(s)     (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
117 +                                EXT2_GOOD_OLD_INODE_SIZE : \
118 +                                (s)->s_inode_size)
119 +#define EXT2_FIRST_INO(s)      (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
120 +                                EXT2_GOOD_OLD_FIRST_INO : \
121 +                                (s)->s_first_ino)
122 +
123 +/*
124 + * Macro-instructions used to manage fragments
125 + */
126 +#define EXT2_MIN_FRAG_SIZE             1024
127 +#define        EXT2_MAX_FRAG_SIZE              4096
128 +#define EXT2_MIN_FRAG_LOG_SIZE           10
129 +# define EXT2_FRAG_SIZE(s)             (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
130 +# define EXT2_FRAGS_PER_BLOCK(s)       (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
131 +
132 +/*
133 + * Structure of a blocks group descriptor
134 + */
135 +struct ext2_group_desc
136 +{
137 +       uint32_t        bg_block_bitmap;                /* Blocks bitmap block */
138 +       uint32_t        bg_inode_bitmap;                /* Inodes bitmap block */
139 +       uint32_t        bg_inode_table;         /* Inodes table block */
140 +       uint16_t        bg_free_blocks_count;   /* Free blocks count */
141 +       uint16_t        bg_free_inodes_count;   /* Free inodes count */
142 +       uint16_t        bg_used_dirs_count;     /* Directories count */
143 +       uint16_t        bg_pad;
144 +       uint32_t        bg_reserved[3];
145 +};
146 +
147 +/*
148 + * Macro-instructions used to manage group descriptors
149 + */
150 +# define EXT2_BLOCKS_PER_GROUP(s)      ((s)->s_blocks_per_group)
151 +# define EXT2_DESC_PER_BLOCK(s)                (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
152 +# define EXT2_INODES_PER_GROUP(s)      ((s)->s_inodes_per_group)
153 +
154 +/*
155 + * Constants relative to the data blocks
156 + */
157 +#define        EXT2_NDIR_BLOCKS                12
158 +#define        EXT2_IND_BLOCK                  EXT2_NDIR_BLOCKS
159 +#define        EXT2_DIND_BLOCK                 (EXT2_IND_BLOCK + 1)
160 +#define        EXT2_TIND_BLOCK                 (EXT2_DIND_BLOCK + 1)
161 +#define        EXT2_N_BLOCKS                   (EXT2_TIND_BLOCK + 1)
162 +
163 +/*
164 + * Inode flags (GETFLAGS/SETFLAGS)
165 + */
166 +#define        EXT2_SECRM_FL                   FS_SECRM_FL     /* Secure deletion */
167 +#define        EXT2_UNRM_FL                    FS_UNRM_FL      /* Undelete */
168 +#define        EXT2_COMPR_FL                   FS_COMPR_FL     /* Compress file */
169 +#define EXT2_SYNC_FL                   FS_SYNC_FL      /* Synchronous updates */
170 +#define EXT2_IMMUTABLE_FL              FS_IMMUTABLE_FL /* Immutable file */
171 +#define EXT2_APPEND_FL                 FS_APPEND_FL    /* writes to file may only append */
172 +#define EXT2_NODUMP_FL                 FS_NODUMP_FL    /* do not dump file */
173 +#define EXT2_NOATIME_FL                        FS_NOATIME_FL   /* do not update atime */
174 +/* Reserved for compression usage... */
175 +#define EXT2_DIRTY_FL                  FS_DIRTY_FL
176 +#define EXT2_COMPRBLK_FL               FS_COMPRBLK_FL  /* One or more compressed clusters */
177 +#define EXT2_NOCOMP_FL                 FS_NOCOMP_FL    /* Don't compress */
178 +#define EXT2_ECOMPR_FL                 FS_ECOMPR_FL    /* Compression error */
179 +/* End compression flags --- maybe not all used */
180 +#define EXT2_BTREE_FL                  FS_BTREE_FL     /* btree format dir */
181 +#define EXT2_INDEX_FL                  FS_INDEX_FL     /* hash-indexed directory */
182 +#define EXT2_IMAGIC_FL                 FS_IMAGIC_FL    /* AFS directory */
183 +#define EXT2_JOURNAL_DATA_FL           FS_JOURNAL_DATA_FL /* Reserved for ext3 */
184 +#define EXT2_NOTAIL_FL                 FS_NOTAIL_FL    /* file tail should not be merged */
185 +#define EXT2_DIRSYNC_FL                        FS_DIRSYNC_FL   /* dirsync behaviour (directories only) */
186 +#define EXT2_TOPDIR_FL                 FS_TOPDIR_FL    /* Top of directory hierarchies*/
187 +#define EXT2_RESERVED_FL               FS_RESERVED_FL  /* reserved for ext2 lib */
188 +
189 +#define EXT2_FL_USER_VISIBLE           FS_FL_USER_VISIBLE      /* User visible flags */
190 +#define EXT2_FL_USER_MODIFIABLE                FS_FL_USER_MODIFIABLE   /* User modifiable flags */
191 +
192 +/* Flags that should be inherited by new inodes from their parent. */
193 +#define EXT2_FL_INHERITED (EXT2_SECRM_FL | EXT2_UNRM_FL | EXT2_COMPR_FL |\
194 +                          EXT2_SYNC_FL | EXT2_IMMUTABLE_FL | EXT2_APPEND_FL |\
195 +                          EXT2_NODUMP_FL | EXT2_NOATIME_FL | EXT2_COMPRBLK_FL|\
196 +                          EXT2_NOCOMP_FL | EXT2_JOURNAL_DATA_FL |\
197 +                          EXT2_NOTAIL_FL | EXT2_DIRSYNC_FL)
198 +
199 +/* Flags that are appropriate for regular files (all but dir-specific ones). */
200 +#define EXT2_REG_FLMASK (~(EXT2_DIRSYNC_FL | EXT2_TOPDIR_FL))
201 +
202 +/* Flags that are appropriate for non-directories/regular files. */
203 +#define EXT2_OTHER_FLMASK (EXT2_NODUMP_FL | EXT2_NOATIME_FL)
204 +
205 +/* Mask out flags that are inappropriate for the given type of inode. */
206 +static inline uint32_t ext2_mask_flags(mode_t mode, uint32_t flags)
207 +{
208 +       if (S_ISDIR(mode))
209 +               return flags;
210 +       else if (S_ISREG(mode))
211 +               return flags & EXT2_REG_FLMASK;
212 +       else
213 +               return flags & EXT2_OTHER_FLMASK;
214 +}
215 +
216 +/*
217 + * ioctl commands
218 + */
219 +#define        EXT2_IOC_GETFLAGS               FS_IOC_GETFLAGS
220 +#define        EXT2_IOC_SETFLAGS               FS_IOC_SETFLAGS
221 +#define        EXT2_IOC_GETVERSION             FS_IOC_GETVERSION
222 +#define        EXT2_IOC_SETVERSION             FS_IOC_SETVERSION
223 +#define        EXT2_IOC_GETRSVSZ               _IOR('f', 5, long)
224 +#define        EXT2_IOC_SETRSVSZ               _IOW('f', 6, long)
225 +
226 +/*
227 + * ioctl commands in 32 bit emulation
228 + */
229 +#define EXT2_IOC32_GETFLAGS            FS_IOC32_GETFLAGS
230 +#define EXT2_IOC32_SETFLAGS            FS_IOC32_SETFLAGS
231 +#define EXT2_IOC32_GETVERSION          FS_IOC32_GETVERSION
232 +#define EXT2_IOC32_SETVERSION          FS_IOC32_SETVERSION
233 +
234 +/*
235 + * Structure of an inode on the disk
236 + */
237 +struct ext2_inode {
238 +       uint16_t        i_mode;         /* File mode */
239 +       uint16_t        i_uid;          /* Low 16 bits of Owner Uid */
240 +       uint32_t        i_size;         /* Size in bytes */
241 +       uint32_t        i_atime;        /* Access time */
242 +       uint32_t        i_ctime;        /* Creation time */
243 +       uint32_t        i_mtime;        /* Modification time */
244 +       uint32_t        i_dtime;        /* Deletion Time */
245 +       uint16_t        i_gid;          /* Low 16 bits of Group Id */
246 +       uint16_t        i_links_count;  /* Links count */
247 +       uint32_t        i_blocks;       /* Blocks count */
248 +       uint32_t        i_flags;        /* File flags */
249 +       union {
250 +               struct {
251 +                       uint32_t  l_i_reserved1;
252 +               } linux1;
253 +               struct {
254 +                       uint32_t  h_i_translator;
255 +               } hurd1;
256 +               struct {
257 +                       uint32_t  m_i_reserved1;
258 +               } masix1;
259 +       } osd1;                         /* OS dependent 1 */
260 +       uint32_t        i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
261 +       uint32_t        i_generation;   /* File version (for NFS) */
262 +       uint32_t        i_file_acl;     /* File ACL */
263 +       uint32_t        i_dir_acl;      /* Directory ACL */
264 +       uint32_t        i_faddr;        /* Fragment address */
265 +       union {
266 +               struct {
267 +                       uint8_t l_i_frag;       /* Fragment number */
268 +                       uint8_t l_i_fsize;      /* Fragment size */
269 +                       uint16_t        i_pad1;
270 +                       uint16_t        l_i_uid_high;   /* these 2 fields    */
271 +                       uint16_t        l_i_gid_high;   /* were reserved2[0] */
272 +                       uint32_t        l_i_reserved2;
273 +               } linux2;
274 +               struct {
275 +                       uint8_t h_i_frag;       /* Fragment number */
276 +                       uint8_t h_i_fsize;      /* Fragment size */
277 +                       uint16_t        h_i_mode_high;
278 +                       uint16_t        h_i_uid_high;
279 +                       uint16_t        h_i_gid_high;
280 +                       uint32_t        h_i_author;
281 +               } hurd2;
282 +               struct {
283 +                       uint8_t m_i_frag;       /* Fragment number */
284 +                       uint8_t m_i_fsize;      /* Fragment size */
285 +                       uint16_t        m_pad1;
286 +                       uint32_t        m_i_reserved2[2];
287 +               } masix2;
288 +       } osd2;                         /* OS dependent 2 */
289 +};
290 +
291 +#define i_size_high    i_dir_acl
292 +
293 +#if defined(__KERNEL__) || defined(__linux__)
294 +#define i_reserved1    osd1.linux1.l_i_reserved1
295 +#define i_frag         osd2.linux2.l_i_frag
296 +#define i_fsize                osd2.linux2.l_i_fsize
297 +#define i_uid_low      i_uid
298 +#define i_gid_low      i_gid
299 +#define i_uid_high     osd2.linux2.l_i_uid_high
300 +#define i_gid_high     osd2.linux2.l_i_gid_high
301 +#define i_reserved2    osd2.linux2.l_i_reserved2
302 +#endif
303 +
304 +#ifdef __hurd__
305 +#define i_translator   osd1.hurd1.h_i_translator
306 +#define i_frag         osd2.hurd2.h_i_frag
307 +#define i_fsize                osd2.hurd2.h_i_fsize
308 +#define i_uid_high     osd2.hurd2.h_i_uid_high
309 +#define i_gid_high     osd2.hurd2.h_i_gid_high
310 +#define i_author       osd2.hurd2.h_i_author
311 +#endif
312 +
313 +#ifdef __masix__
314 +#define i_reserved1    osd1.masix1.m_i_reserved1
315 +#define i_frag         osd2.masix2.m_i_frag
316 +#define i_fsize                osd2.masix2.m_i_fsize
317 +#define i_reserved2    osd2.masix2.m_i_reserved2
318 +#endif
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               0x000001  /* Do mount-time checks */
330 +#define EXT2_MOUNT_OLDALLOC            0x000002  /* Don't use the new Orlov allocator */
331 +#define EXT2_MOUNT_GRPID               0x000004  /* Create files with directory's group */
332 +#define EXT2_MOUNT_DEBUG               0x000008  /* Some debugging messages */
333 +#define EXT2_MOUNT_ERRORS_CONT         0x000010  /* Continue on errors */
334 +#define EXT2_MOUNT_ERRORS_RO           0x000020  /* Remount fs ro on errors */
335 +#define EXT2_MOUNT_ERRORS_PANIC                0x000040  /* Panic on errors */
336 +#define EXT2_MOUNT_MINIX_DF            0x000080  /* Mimics the Minix statfs */
337 +#define EXT2_MOUNT_NOBH                        0x000100  /* No buffer_heads */
338 +#define EXT2_MOUNT_NO_UID32            0x000200  /* Disable 32-bit UIDs */
339 +#define EXT2_MOUNT_XATTR_USER          0x004000  /* Extended user attributes */
340 +#define EXT2_MOUNT_POSIX_ACL           0x008000  /* POSIX Access Control Lists */
341 +#define EXT2_MOUNT_XIP                 0x010000  /* Execute in place */
342 +#define EXT2_MOUNT_USRQUOTA            0x020000  /* user quota */
343 +#define EXT2_MOUNT_GRPQUOTA            0x040000  /* group quota */
344 +#define EXT2_MOUNT_RESERVATION         0x080000  /* Preallocation */
345 +
346 +
347 +#define clear_opt(o, opt)              o &= ~EXT2_MOUNT_##opt
348 +#define set_opt(o, opt)                        o |= EXT2_MOUNT_##opt
349 +#define test_opt(sb, opt)              (EXT2_SB(sb)->s_mount_opt & \
350 +                                        EXT2_MOUNT_##opt)
351 +/*
352 + * Maximal mount counts between two filesystem checks
353 + */
354 +#define EXT2_DFL_MAX_MNT_COUNT         20      /* Allow 20 mounts */
355 +#define EXT2_DFL_CHECKINTERVAL         0       /* Don't use interval check */
356 +
357 +/*
358 + * Behaviour when detecting errors
359 + */
360 +#define EXT2_ERRORS_CONTINUE           1       /* Continue execution */
361 +#define EXT2_ERRORS_RO                 2       /* Remount fs read-only */
362 +#define EXT2_ERRORS_PANIC              3       /* Panic */
363 +#define EXT2_ERRORS_DEFAULT            EXT2_ERRORS_CONTINUE
364 +
365 +/*
366 + * Structure of the super block
367 + */
368 +struct ext2_super_block {
369 +       uint32_t        s_inodes_count;         /* Inodes count */
370 +       uint32_t        s_blocks_count;         /* Blocks count */
371 +       uint32_t        s_r_blocks_count;       /* Reserved blocks count */
372 +       uint32_t        s_free_blocks_count;    /* Free blocks count */
373 +       uint32_t        s_free_inodes_count;    /* Free inodes count */
374 +       uint32_t        s_first_data_block;     /* First Data Block */
375 +       uint32_t        s_log_block_size;       /* Block size */
376 +       uint32_t        s_log_frag_size;        /* Fragment size */
377 +       uint32_t        s_blocks_per_group;     /* # Blocks per group */
378 +       uint32_t        s_frags_per_group;      /* # Fragments per group */
379 +       uint32_t        s_inodes_per_group;     /* # Inodes per group */
380 +       uint32_t        s_mtime;                /* Mount time */
381 +       uint32_t        s_wtime;                /* Write time */
382 +       uint16_t        s_mnt_count;            /* Mount count */
383 +       uint16_t        s_max_mnt_count;        /* Maximal mount count */
384 +       uint16_t        s_magic;                /* Magic signature */
385 +       uint16_t        s_state;                /* File system state */
386 +       uint16_t        s_errors;               /* Behaviour when detecting errors */
387 +       uint16_t        s_minor_rev_level;      /* minor revision level */
388 +       uint32_t        s_lastcheck;            /* time of last check */
389 +       uint32_t        s_checkinterval;        /* max. time between checks */
390 +       uint32_t        s_creator_os;           /* OS */
391 +       uint32_t        s_rev_level;            /* Revision level */
392 +       uint16_t        s_def_resuid;           /* Default uid for reserved blocks */
393 +       uint16_t        s_def_resgid;           /* Default gid for reserved blocks */
394 +       /*
395 +        * These fields are for EXT2_DYNAMIC_REV superblocks only.
396 +        *
397 +        * Note: the difference between the compatible feature set and
398 +        * the incompatible feature set is that if there is a bit set
399 +        * in the incompatible feature set that the kernel doesn't
400 +        * know about, it should refuse to mount the filesystem.
401 +        *
402 +        * e2fsck's requirements are more strict; if it doesn't know
403 +        * about a feature in either the compatible or incompatible
404 +        * feature set, it must abort and not try to meddle with
405 +        * things it doesn't understand...
406 +        */
407 +       uint32_t        s_first_ino;            /* First non-reserved inode */
408 +       uint16_t   s_inode_size;                /* size of inode structure */
409 +       uint16_t        s_block_group_nr;       /* block group # of this superblock */
410 +       uint32_t        s_feature_compat;       /* compatible feature set */
411 +       uint32_t        s_feature_incompat;     /* incompatible feature set */
412 +       uint32_t        s_feature_ro_compat;    /* readonly-compatible feature set */
413 +       uint8_t s_uuid[16];             /* 128-bit uuid for volume */
414 +       char    s_volume_name[16];      /* volume name */
415 +       char    s_last_mounted[64];     /* directory where last mounted */
416 +       uint32_t        s_algorithm_usage_bitmap; /* For compression */
417 +       /*
418 +        * Performance hints.  Directory preallocation should only
419 +        * happen if the EXT2_COMPAT_PREALLOC flag is on.
420 +        */
421 +       uint8_t s_prealloc_blocks;      /* Nr of blocks to try to preallocate*/
422 +       uint8_t s_prealloc_dir_blocks;  /* Nr to preallocate for dirs */
423 +       uint16_t        s_padding1;
424 +       /*
425 +        * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
426 +        */
427 +       uint8_t s_journal_uuid[16];     /* uuid of journal superblock */
428 +       uint32_t        s_journal_inum;         /* inode number of journal file */
429 +       uint32_t        s_journal_dev;          /* device number of journal file */
430 +       uint32_t        s_last_orphan;          /* start of list of inodes to delete */
431 +       uint32_t        s_hash_seed[4];         /* HTREE hash seed */
432 +       uint8_t s_def_hash_version;     /* Default hash version to use */
433 +       uint8_t s_reserved_char_pad;
434 +       uint16_t        s_reserved_word_pad;
435 +       uint32_t        s_default_mount_opts;
436 +       uint32_t        s_first_meta_bg;        /* First metablock block group */
437 +       uint32_t        s_reserved[190];        /* Padding to the end of the block */
438 +};
439 +
440 +/*
441 + * Codes for operating systems
442 + */
443 +#define EXT2_OS_LINUX          0
444 +#define EXT2_OS_HURD           1
445 +#define EXT2_OS_MASIX          2
446 +#define EXT2_OS_FREEBSD                3
447 +#define EXT2_OS_LITES          4
448 +
449 +/*
450 + * Revision levels
451 + */
452 +#define EXT2_GOOD_OLD_REV      0       /* The good old (original) format */
453 +#define EXT2_DYNAMIC_REV       1       /* V2 format w/ dynamic inode sizes */
454 +
455 +#define EXT2_CURRENT_REV       EXT2_GOOD_OLD_REV
456 +#define EXT2_MAX_SUPP_REV      EXT2_DYNAMIC_REV
457 +
458 +#define EXT2_GOOD_OLD_INODE_SIZE 128
459 +
460 +/*
461 + * Feature set definitions
462 + */
463 +
464 +#define EXT2_HAS_COMPAT_FEATURE(sb,mask)                       \
465 +       ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
466 +#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask)                    \
467 +       ( EXT2_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
468 +#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask)                     \
469 +       ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
470 +#define EXT2_SET_COMPAT_FEATURE(sb,mask)                       \
471 +       EXT2_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
472 +#define EXT2_SET_RO_COMPAT_FEATURE(sb,mask)                    \
473 +       EXT2_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
474 +#define EXT2_SET_INCOMPAT_FEATURE(sb,mask)                     \
475 +       EXT2_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
476 +#define EXT2_CLEAR_COMPAT_FEATURE(sb,mask)                     \
477 +       EXT2_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
478 +#define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask)                  \
479 +       EXT2_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
480 +#define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask)                   \
481 +       EXT2_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
482 +
483 +#define EXT2_FEATURE_COMPAT_DIR_PREALLOC       0x0001
484 +#define EXT2_FEATURE_COMPAT_IMAGIC_INODES      0x0002
485 +#define EXT3_FEATURE_COMPAT_HAS_JOURNAL                0x0004
486 +#define EXT2_FEATURE_COMPAT_EXT_ATTR           0x0008
487 +#define EXT2_FEATURE_COMPAT_RESIZE_INO         0x0010
488 +#define EXT2_FEATURE_COMPAT_DIR_INDEX          0x0020
489 +#define EXT2_FEATURE_COMPAT_ANY                        0xffffffff
490 +
491 +#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER    0x0001
492 +#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE      0x0002
493 +#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR       0x0004
494 +#define EXT2_FEATURE_RO_COMPAT_ANY             0xffffffff
495 +
496 +#define EXT2_FEATURE_INCOMPAT_COMPRESSION      0x0001
497 +#define EXT2_FEATURE_INCOMPAT_FILETYPE         0x0002
498 +#define EXT3_FEATURE_INCOMPAT_RECOVER          0x0004
499 +#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV      0x0008
500 +#define EXT2_FEATURE_INCOMPAT_META_BG          0x0010
501 +#define EXT2_FEATURE_INCOMPAT_ANY              0xffffffff
502 +
503 +#define EXT2_FEATURE_COMPAT_SUPP       EXT2_FEATURE_COMPAT_EXT_ATTR
504 +#define EXT2_FEATURE_INCOMPAT_SUPP     (EXT2_FEATURE_INCOMPAT_FILETYPE| \
505 +                                        EXT2_FEATURE_INCOMPAT_META_BG)
506 +#define EXT2_FEATURE_RO_COMPAT_SUPP    (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
507 +                                        EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
508 +                                        EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
509 +#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED     ~EXT2_FEATURE_RO_COMPAT_SUPP
510 +#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED      ~EXT2_FEATURE_INCOMPAT_SUPP
511 +
512 +/*
513 + * Default values for user and/or group using reserved blocks
514 + */
515 +#define        EXT2_DEF_RESUID         0
516 +#define        EXT2_DEF_RESGID         0
517 +
518 +/*
519 + * Default mount options
520 + */
521 +#define EXT2_DEFM_DEBUG                0x0001
522 +#define EXT2_DEFM_BSDGROUPS    0x0002
523 +#define EXT2_DEFM_XATTR_USER   0x0004
524 +#define EXT2_DEFM_ACL          0x0008
525 +#define EXT2_DEFM_UID16                0x0010
526 +    /* Not used by ext2, but reserved for use by ext3 */
527 +#define EXT3_DEFM_JMODE                0x0060 
528 +#define EXT3_DEFM_JMODE_DATA   0x0020
529 +#define EXT3_DEFM_JMODE_ORDERED        0x0040
530 +#define EXT3_DEFM_JMODE_WBACK  0x0060
531 +
532 +/*
533 + * Structure of a directory entry
534 + */
535 +#define EXT2_NAME_LEN 255
536 +
537 +struct ext2_dir_entry {
538 +       uint32_t        inode;                  /* Inode number */
539 +       uint16_t        rec_len;                /* Directory entry length */
540 +       uint16_t        name_len;               /* Name length */
541 +       char    name[EXT2_NAME_LEN];    /* File name */
542 +};
543 +
544 +/*
545 + * The new version of the directory entry.  Since EXT2 structures are
546 + * stored in intel byte order, and the name_len field could never be
547 + * bigger than 255 chars, it's safe to reclaim the extra byte for the
548 + * file_type field.
549 + */
550 +struct ext2_dir_entry_2 {
551 +       uint32_t        inode;                  /* Inode number */
552 +       uint16_t        rec_len;                /* Directory entry length */
553 +       uint8_t name_len;               /* Name length */
554 +       uint8_t file_type;
555 +       char    name[EXT2_NAME_LEN];    /* File name */
556 +};
557 +
558 +/*
559 + * Ext2 directory file types.  Only the low 3 bits are used.  The
560 + * other bits are reserved for now.
561 + */
562 +enum {
563 +       EXT2_FT_UNKNOWN         = 0,
564 +       EXT2_FT_REG_FILE        = 1,
565 +       EXT2_FT_DIR             = 2,
566 +       EXT2_FT_CHRDEV          = 3,
567 +       EXT2_FT_BLKDEV          = 4,
568 +       EXT2_FT_FIFO            = 5,
569 +       EXT2_FT_SOCK            = 6,
570 +       EXT2_FT_SYMLINK         = 7,
571 +       EXT2_FT_MAX
572 +};
573 +
574 +/*
575 + * EXT2_DIR_PAD defines the directory entries boundaries
576 + *
577 + * NOTE: It must be a multiple of 4
578 + */
579 +#define EXT2_DIR_PAD                   4
580 +#define EXT2_DIR_ROUND                         (EXT2_DIR_PAD - 1)
581 +#define EXT2_DIR_REC_LEN(name_len)     (((name_len) + 8 + EXT2_DIR_ROUND) & \
582 +                                        ~EXT2_DIR_ROUND)
583 +#define EXT2_MAX_REC_LEN               ((1<<16)-1)
584 +
585 +#endif
586 diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c
587 index 759bb0a..2d9d720 100644
588 --- a/util-linux/mkfs_ext2.c
589 +++ b/util-linux/mkfs_ext2.c
590 @@ -48,13 +48,7 @@
591  
592  #include "libbb.h"
593  #include <linux/fs.h>
594 -/*
595 - * Work around linux/ext2_fs.h breakage.
596 - * See https://bugzilla.kernel.org/show_bug.cgi?id=42986.
597 - */
598 -typedef mode_t bb__umode_t;
599 -#define umode_t bb__umode_t
600 -#include <linux/ext2_fs.h>
601 +#include "bb_linux_ext2_fs.h"
602  
603  #define ENABLE_FEATURE_MKFS_EXT2_RESERVED_GDT 0
604  #define ENABLE_FEATURE_MKFS_EXT2_DIR_INDEX    1
605 -- 
606 1.7.9.5
607