]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/gnu/fs/ext2fs/ext2_fs.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / gnu / fs / ext2fs / ext2_fs.h
1 /*-
2  *  modified for EXT2FS support in Lites 1.1
3  *
4  *  Aug 1995, Godmar Back (gback@cs.utah.edu)
5  *  University of Utah, Department of Computer Science
6  *
7  * $FreeBSD$
8  */
9 /*-
10  *  linux/include/linux/ext2_fs.h
11  *
12  * Copyright (C) 1992, 1993, 1994, 1995
13  * Remy Card (card@masi.ibp.fr)
14  * Laboratoire MASI - Institut Blaise Pascal
15  * Universite Pierre et Marie Curie (Paris VI)
16  *
17  *  from
18  *
19  *  linux/include/linux/minix_fs.h
20  *
21  *  Copyright (C) 1991, 1992  Linus Torvalds
22  *
23  *      This program is free software; you can redistribute it and/or modify
24  *      it under the terms of the GNU General Public License as published by
25  *      the Free Software Foundation; either version 2 of the License.
26  *
27  *      This program is distributed in the hope that it will be useful,
28  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
29  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30  *      GNU General Public License for more details.
31  *
32  *      You should have received a copy of the GNU General Public License
33  *      along with this program; if not, write to the Free Software
34  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35  *
36  */
37
38 #ifndef _LINUX_EXT2_FS_H
39 #define _LINUX_EXT2_FS_H
40
41 #include <sys/types.h>
42
43 #define __u32 u_int32_t
44 #define u32   u_int32_t
45 #define __u16 u_int16_t
46 #define __u8  u_int8_t
47
48 #define __s32 int32_t
49 #define __s16 int16_t
50 #define __s8  int8_t
51
52 #define umode_t mode_t
53 #define loff_t  off_t
54
55 /*
56  * The second extended filesystem constants/structures
57  */
58
59 /*
60  * Define EXT2FS_DEBUG to produce debug messages
61  */
62 #undef EXT2FS_DEBUG
63
64 /*
65  * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files
66  */
67 #define EXT2_PREALLOCATE
68 #define EXT2_DEFAULT_PREALLOC_BLOCKS    8
69
70 /*
71  * The second extended file system version
72  */
73 #define EXT2FS_DATE             "95/08/09"
74 #define EXT2FS_VERSION          "0.5b"
75
76 /*
77  * Debug code
78  */
79 #ifdef EXT2FS_DEBUG
80 #       define ext2_debug(f, a...)      { \
81                                         printf ("EXT2-fs DEBUG (%s, %d): %s:", \
82                                                 __FILE__, __LINE__, __func__); \
83                                         printf (f, ## a); \
84                                         }
85 #else
86 #       define ext2_debug(f, a...)      /**/
87 #endif
88
89 /*
90  * Special inodes numbers
91  */
92 #define EXT2_BAD_INO             1      /* Bad blocks inode */
93 #define EXT2_ROOT_INO            2      /* Root inode */
94 #define EXT2_ACL_IDX_INO         3      /* ACL inode */
95 #define EXT2_ACL_DATA_INO        4      /* ACL inode */
96 #define EXT2_BOOT_LOADER_INO     5      /* Boot loader inode */
97 #define EXT2_UNDEL_DIR_INO       6      /* Undelete directory inode */
98
99 /* First non-reserved inode for old ext2 filesystems */
100 #define EXT2_GOOD_OLD_FIRST_INO 11
101
102 /*
103  * The second extended file system magic number
104  */
105 #define EXT2_SUPER_MAGIC        0xEF53
106
107 /*
108  * Maximal count of links to a file
109  */
110 #define EXT2_LINK_MAX           32000
111
112 /*
113  * Note: under FreeBSD, the "user" versions of the following macros are
114  * used (and must be used) in most cases, because ((s)->u.ext2_sb.s_es is
115  * not accessible.  This depends on __KERNEL__ not being defined for
116  * kernel builds under FreeBSD.
117  */
118
119 /*
120  * Macro-instructions used to manage several block sizes
121  */
122 #define EXT2_MIN_BLOCK_SIZE             1024
123 #define EXT2_MAX_BLOCK_SIZE             4096
124 #define EXT2_MIN_BLOCK_LOG_SIZE           10
125 #if defined(__KERNEL__) || (defined(__FreeBSD__) && defined(_KERNEL))
126 # define EXT2_BLOCK_SIZE(s)             ((s)->s_blocksize)
127 #else
128 # define EXT2_BLOCK_SIZE(s)             (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
129 #endif
130 #define EXT2_ACLE_PER_BLOCK(s)          (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
131 #define EXT2_ADDR_PER_BLOCK(s)          (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
132 #ifdef __KERNEL__
133 # define EXT2_BLOCK_SIZE_BITS(s)        ((s)->s_blocksize_bits)
134 #else
135 # define EXT2_BLOCK_SIZE_BITS(s)        ((s)->s_log_block_size + 10)
136 #endif
137 #ifdef notyet
138 #ifdef __KERNEL__
139 #define EXT2_ADDR_PER_BLOCK_BITS(s)     ((s)->u.ext2_sb.s_addr_per_block_bits)
140 #define EXT2_INODE_SIZE(s)              ((s)->u.ext2_sb.s_inode_size)
141 #define EXT2_FIRST_INO(s)               ((s)->u.ext2_sb.s_first_ino)
142 #else
143 #define EXT2_INODE_SIZE(s)      (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
144                                  EXT2_GOOD_OLD_INODE_SIZE : \
145                                  (s)->s_inode_size)
146 #define EXT2_FIRST_INO(s)       (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
147                                  EXT2_GOOD_OLD_FIRST_INO : \
148                                  (s)->s_first_ino)
149 #endif
150 #else /* !notyet */
151 #define EXT2_INODES_PER_BLOCK(s)        ((s)->s_inodes_per_block)
152 /* Should be sizeof(struct ext2_inode): */
153 #define EXT2_INODE_SIZE                 128
154 #define EXT2_FIRST_INO                  11
155 #endif /* notyet */
156
157 /*
158  * Macro-instructions used to manage fragments
159  */
160 #define EXT2_MIN_FRAG_SIZE              1024
161 #define EXT2_MAX_FRAG_SIZE              4096
162 #define EXT2_MIN_FRAG_LOG_SIZE            10
163 #ifdef __KERNEL__
164 # define EXT2_FRAG_SIZE(s)              ((s)->u.ext2_sb.s_frag_size)
165 # define EXT2_FRAGS_PER_BLOCK(s)        ((s)->u.ext2_sb.s_frags_per_block)
166 #else
167 # if defined(_KERNEL) && defined(__FreeBSD__)
168 # define EXT2_FRAG_SIZE(s)              ((s)->s_frag_size)
169 # else
170 # define EXT2_FRAG_SIZE(s)              (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
171 # endif
172 # define EXT2_FRAGS_PER_BLOCK(s)        (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
173 #endif
174
175 /*
176  * ACL structures
177  */
178 struct ext2_acl_header  /* Header of Access Control Lists */
179 {
180         __u32   aclh_size;
181         __u32   aclh_file_count;
182         __u32   aclh_acle_count;
183         __u32   aclh_first_acle;
184 };
185
186 struct ext2_acl_entry   /* Access Control List Entry */
187 {
188         __u32   acle_size;
189         __u16   acle_perms;     /* Access permissions */
190         __u16   acle_type;      /* Type of entry */
191         __u16   acle_tag;       /* User or group identity */
192         __u16   acle_pad1;
193         __u32   acle_next;      /* Pointer on next entry for the */
194                                         /* same inode or on next free entry */
195 };
196
197 /*
198  * Structure of a blocks group descriptor
199  */
200 struct ext2_group_desc
201 {
202         __u32   bg_block_bitmap;                /* Blocks bitmap block */
203         __u32   bg_inode_bitmap;                /* Inodes bitmap block */
204         __u32   bg_inode_table;         /* Inodes table block */
205         __u16   bg_free_blocks_count;   /* Free blocks count */
206         __u16   bg_free_inodes_count;   /* Free inodes count */
207         __u16   bg_used_dirs_count;     /* Directories count */
208         __u16   bg_pad;
209         __u32   bg_reserved[3];
210 };
211
212 /*
213  * Macro-instructions used to manage group descriptors
214  */
215 #ifdef __KERNEL__
216 # define EXT2_BLOCKS_PER_GROUP(s)       ((s)->u.ext2_sb.s_blocks_per_group)
217 # define EXT2_DESC_PER_BLOCK(s)         ((s)->u.ext2_sb.s_desc_per_block)
218 # define EXT2_INODES_PER_GROUP(s)       ((s)->u.ext2_sb.s_inodes_per_group)
219 # define EXT2_DESC_PER_BLOCK_BITS(s)    ((s)->u.ext2_sb.s_desc_per_block_bits)
220 #else
221 # define EXT2_BLOCKS_PER_GROUP(s)       ((s)->s_blocks_per_group)
222 # define EXT2_DESC_PER_BLOCK(s)         (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
223 # define EXT2_INODES_PER_GROUP(s)       ((s)->s_inodes_per_group)
224 #endif
225
226 /*
227  * Constants relative to the data blocks
228  */
229 #define EXT2_NDIR_BLOCKS                12
230 #define EXT2_IND_BLOCK                  EXT2_NDIR_BLOCKS
231 #define EXT2_DIND_BLOCK                 (EXT2_IND_BLOCK + 1)
232 #define EXT2_TIND_BLOCK                 (EXT2_DIND_BLOCK + 1)
233 #define EXT2_N_BLOCKS                   (EXT2_TIND_BLOCK + 1)
234 #define EXT2_MAXSYMLINKLEN              (EXT2_N_BLOCKS * sizeof (__u32))
235
236 /*
237  * Inode flags
238  */
239 #define EXT2_SECRM_FL                   0x00000001 /* Secure deletion */
240 #define EXT2_UNRM_FL                    0x00000002 /* Undelete */
241 #define EXT2_COMPR_FL                   0x00000004 /* Compress file */
242 #define EXT2_SYNC_FL                    0x00000008 /* Synchronous updates */
243 #define EXT2_IMMUTABLE_FL               0x00000010 /* Immutable file */
244 #define EXT2_APPEND_FL                  0x00000020 /* writes to file may only append */
245 #define EXT2_NODUMP_FL                  0x00000040 /* do not dump file */
246 #define EXT2_NOATIME_FL                 0x00000080 /* do not update atime */
247 /* Reserved for compression usage... */
248 #define EXT2_DIRTY_FL                   0x00000100
249 #define EXT2_COMPRBLK_FL                0x00000200 /* One or more compressed clusters */
250 #define EXT2_NOCOMP_FL                  0x00000400 /* Don't compress */
251 #define EXT2_ECOMPR_FL                  0x00000800 /* Compression error */
252 /* End compression flags --- maybe not all used */      
253 #define EXT2_BTREE_FL                   0x00001000 /* btree format dir */
254 #define EXT2_RESERVED_FL                0x80000000 /* reserved for ext2 lib */
255
256 #define EXT2_FL_USER_VISIBLE            0x00001FFF /* User visible flags */
257 #define EXT2_FL_USER_MODIFIABLE         0x000000FF /* User modifiable flags */
258
259 /*
260  * ioctl commands
261  */
262 #define EXT2_IOC_GETFLAGS               _IOR('f', 1, long)
263 #define EXT2_IOC_SETFLAGS               _IOW('f', 2, long)
264 #define EXT2_IOC_GETVERSION             _IOR('v', 1, long)
265 #define EXT2_IOC_SETVERSION             _IOW('v', 2, long)
266
267 /*
268  * Structure of an inode on the disk
269  */
270 struct ext2_inode {
271         __u16   i_mode;         /* File mode */
272         __u16   i_uid;          /* Owner Uid */
273         __u32   i_size;         /* Size in bytes */
274         __u32   i_atime;        /* Access time */
275         __u32   i_ctime;        /* Creation time */
276         __u32   i_mtime;        /* Modification time */
277         __u32   i_dtime;        /* Deletion Time */
278         __u16   i_gid;          /* Group Id */
279         __u16   i_links_count;  /* Links count */
280         __u32   i_blocks;       /* Blocks count */
281         __u32   i_flags;        /* File flags */
282         union {
283                 struct {
284                         __u32  l_i_reserved1;
285                 } linux1;
286                 struct {
287                         __u32  h_i_translator;
288                 } hurd1;
289                 struct {
290                         __u32  m_i_reserved1;
291                 } masix1;
292         } osd1;                         /* OS dependent 1 */
293         __u32   i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
294         __u32   i_generation;   /* File version (for NFS) */
295         __u32   i_file_acl;     /* File ACL */
296         __u32   i_dir_acl;      /* Directory ACL */
297         __u32   i_faddr;        /* Fragment address */
298         union {
299                 struct {
300                         __u8    l_i_frag;       /* Fragment number */
301                         __u8    l_i_fsize;      /* Fragment size */
302                         __u16   i_pad1;
303                         __u32   l_i_reserved2[2];
304                 } linux2;
305                 struct {
306                         __u8    h_i_frag;       /* Fragment number */
307                         __u8    h_i_fsize;      /* Fragment size */
308                         __u16   h_i_mode_high;
309                         __u16   h_i_uid_high;
310                         __u16   h_i_gid_high;
311                         __u32   h_i_author;
312                 } hurd2;
313                 struct {
314                         __u8    m_i_frag;       /* Fragment number */
315                         __u8    m_i_fsize;      /* Fragment size */
316                         __u16   m_pad1;
317                         __u32   m_i_reserved2[2];
318                 } masix2;
319         } osd2;                         /* OS dependent 2 */
320 };
321
322 #define i_size_high     i_dir_acl
323
324 #if defined(__KERNEL__) || defined(__linux__)
325 #define i_reserved1     osd1.linux1.l_i_reserved1
326 #define i_frag          osd2.linux2.l_i_frag
327 #define i_fsize         osd2.linux2.l_i_fsize
328 #define i_reserved2     osd2.linux2.l_i_reserved2
329 #endif
330
331 #ifdef  __hurd__
332 #define i_translator    osd1.hurd1.h_i_translator
333 #define i_frag          osd2.hurd2.h_i_frag;
334 #define i_fsize         osd2.hurd2.h_i_fsize;
335 #define i_uid_high      osd2.hurd2.h_i_uid_high
336 #define i_gid_high      osd2.hurd2.h_i_gid_high
337 #define i_author        osd2.hurd2.h_i_author
338 #endif
339
340 #ifdef  __masix__
341 #define i_reserved1     osd1.masix1.m_i_reserved1
342 #define i_frag          osd2.masix2.m_i_frag
343 #define i_fsize         osd2.masix2.m_i_fsize
344 #define i_reserved2     osd2.masix2.m_i_reserved2
345 #endif
346
347 /*
348  * File system states
349  */
350 #define EXT2_VALID_FS                   0x0001  /* Unmounted cleanly */
351 #define EXT2_ERROR_FS                   0x0002  /* Errors detected */
352
353 /*
354  * Mount flags
355  */
356 #define EXT2_MOUNT_CHECK_NORMAL         0x0001  /* Do some more checks */
357 #define EXT2_MOUNT_CHECK_STRICT         0x0002  /* Do again more checks */
358 #define EXT2_MOUNT_CHECK                (EXT2_MOUNT_CHECK_NORMAL | \
359                                          EXT2_MOUNT_CHECK_STRICT)
360 #define EXT2_MOUNT_GRPID                0x0004  /* Create files with directory's group */
361 #define EXT2_MOUNT_DEBUG                0x0008  /* Some debugging messages */
362 #define EXT2_MOUNT_ERRORS_CONT          0x0010  /* Continue on errors */
363 #define EXT2_MOUNT_ERRORS_RO            0x0020  /* Remount fs ro on errors */
364 #define EXT2_MOUNT_ERRORS_PANIC         0x0040  /* Panic on errors */
365 #define EXT2_MOUNT_MINIX_DF             0x0080  /* Mimics the Minix statfs */
366
367 #define clear_opt(o, opt)               o &= ~EXT2_MOUNT_##opt
368 #define set_opt(o, opt)                 o |= EXT2_MOUNT_##opt
369 #define test_opt(sb, opt)               ((sb)->u.ext2_sb.s_mount_opt & \
370                                          EXT2_MOUNT_##opt)
371 /*
372  * Maximal mount counts between two filesystem checks
373  */
374 #define EXT2_DFL_MAX_MNT_COUNT          20      /* Allow 20 mounts */
375 #define EXT2_DFL_CHECKINTERVAL          0       /* Don't use interval check */
376
377 /*
378  * Behaviour when detecting errors
379  */
380 #define EXT2_ERRORS_CONTINUE            1       /* Continue execution */
381 #define EXT2_ERRORS_RO                  2       /* Remount fs read-only */
382 #define EXT2_ERRORS_PANIC               3       /* Panic */
383 #define EXT2_ERRORS_DEFAULT             EXT2_ERRORS_CONTINUE
384
385 /*
386  * Structure of the super block
387  */
388 struct ext2_super_block {
389         __u32   s_inodes_count;         /* Inodes count */
390         __u32   s_blocks_count;         /* Blocks count */
391         __u32   s_r_blocks_count;       /* Reserved blocks count */
392         __u32   s_free_blocks_count;    /* Free blocks count */
393         __u32   s_free_inodes_count;    /* Free inodes count */
394         __u32   s_first_data_block;     /* First Data Block */
395         __u32   s_log_block_size;       /* Block size */
396         __s32   s_log_frag_size;        /* Fragment size */
397         __u32   s_blocks_per_group;     /* # Blocks per group */
398         __u32   s_frags_per_group;      /* # Fragments per group */
399         __u32   s_inodes_per_group;     /* # Inodes per group */
400         __u32   s_mtime;                /* Mount time */
401         __u32   s_wtime;                /* Write time */
402         __u16   s_mnt_count;            /* Mount count */
403         __s16   s_max_mnt_count;        /* Maximal mount count */
404         __u16   s_magic;                /* Magic signature */
405         __u16   s_state;                /* File system state */
406         __u16   s_errors;               /* Behaviour when detecting errors */
407         __u16   s_minor_rev_level;      /* minor revision level */
408         __u32   s_lastcheck;            /* time of last check */
409         __u32   s_checkinterval;        /* max. time between checks */
410         __u32   s_creator_os;           /* OS */
411         __u32   s_rev_level;            /* Revision level */
412         __u16   s_def_resuid;           /* Default uid for reserved blocks */
413         __u16   s_def_resgid;           /* Default gid for reserved blocks */
414         /*
415          * These fields are for EXT2_DYNAMIC_REV superblocks only.
416          *
417          * Note: the difference between the compatible feature set and
418          * the incompatible feature set is that if there is a bit set
419          * in the incompatible feature set that the kernel doesn't
420          * know about, it should refuse to mount the filesystem.
421          * 
422          * e2fsck's requirements are more strict; if it doesn't know
423          * about a feature in either the compatible or incompatible
424          * feature set, it must abort and not try to meddle with
425          * things it doesn't understand...
426          */
427         __u32   s_first_ino;            /* First non-reserved inode */
428         __u16   s_inode_size;           /* size of inode structure */
429         __u16   s_block_group_nr;       /* block group # of this superblock */
430         __u32   s_feature_compat;       /* compatible feature set */
431         __u32   s_feature_incompat;     /* incompatible feature set */
432         __u32   s_feature_ro_compat;    /* readonly-compatible feature set */
433         __u8    s_uuid[16];             /* 128-bit uuid for volume */
434         char    s_volume_name[16];      /* volume name */
435         char    s_last_mounted[64];     /* directory where last mounted */
436         __u32   s_algorithm_usage_bitmap; /* For compression */
437         /*
438          * Performance hints.  Directory preallocation should only
439          * happen if the EXT2_COMPAT_PREALLOC flag is on.
440          */
441         __u8    s_prealloc_blocks;      /* Nr of blocks to try to preallocate*/
442         __u8    s_prealloc_dir_blocks;  /* Nr to preallocate for dirs */
443         __u16   s_padding1;
444         __u32   s_reserved[204];        /* Padding to the end of the block */
445 };
446
447 #ifdef __KERNEL__
448 #define EXT2_SB(sb)     (&((sb)->u.ext2_sb))
449 #else
450 /* Assume that user mode programs are passing in an ext2fs superblock, not
451  * a kernel struct super_block.  This will allow us to call the feature-test
452  * macros from user land. */
453 #define EXT2_SB(sb)     (sb)
454 #endif
455
456 /*
457  * Codes for operating systems
458  */
459 #define EXT2_OS_LINUX           0
460 #define EXT2_OS_HURD            1
461 #define EXT2_OS_MASIX           2
462 #define EXT2_OS_FREEBSD         3
463 #define EXT2_OS_LITES           4
464
465 /*
466  * Revision levels
467  */
468 #define EXT2_GOOD_OLD_REV       0       /* The good old (original) format */
469 #define EXT2_DYNAMIC_REV        1       /* V2 format w/ dynamic inode sizes */
470
471 #define EXT2_CURRENT_REV        EXT2_GOOD_OLD_REV
472 #define EXT2_MAX_SUPP_REV       EXT2_DYNAMIC_REV
473
474 #define EXT2_GOOD_OLD_INODE_SIZE 128
475
476 /*
477  * Feature set definitions
478  */
479
480 #define EXT2_HAS_COMPAT_FEATURE(sb,mask)                        \
481         ( EXT2_SB(sb)->s_feature_compat & (mask) )
482 #define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask)                     \
483         ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
484 #define EXT2_HAS_INCOMPAT_FEATURE(sb,mask)                      \
485         ( EXT2_SB(sb)->s_feature_incompat & (mask) )
486
487 #define EXT2_FEATURE_COMPAT_DIR_PREALLOC        0x0001
488
489 #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER     0x0001
490 #define EXT2_FEATURE_RO_COMPAT_LARGE_FILE       0x0002
491 #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR        0x0004
492
493 #define EXT2_FEATURE_INCOMPAT_COMPRESSION       0x0001
494 #define EXT2_FEATURE_INCOMPAT_FILETYPE          0x0002
495
496 #define EXT2_FEATURE_COMPAT_SUPP        0
497 #define EXT2_FEATURE_INCOMPAT_SUPP      EXT2_FEATURE_INCOMPAT_FILETYPE
498 #ifdef notyet
499 #define EXT2_FEATURE_RO_COMPAT_SUPP     (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
500                                          EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
501                                          EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
502 #else
503 #define EXT2_FEATURE_RO_COMPAT_SUPP     (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
504                                          EXT2_FEATURE_RO_COMPAT_LARGE_FILE)
505 #endif
506
507 /*
508  * Default values for user and/or group using reserved blocks
509  */
510 #define EXT2_DEF_RESUID         0
511 #define EXT2_DEF_RESGID         0
512
513 /*
514  * Structure of a directory entry
515  */
516 #define EXT2_NAME_LEN 255
517
518 struct ext2_dir_entry {
519         __u32   inode;                  /* Inode number */
520         __u16   rec_len;                /* Directory entry length */
521         __u16   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         __u32   inode;                  /* Inode number */
533         __u16   rec_len;                /* Directory entry length */
534         __u8    name_len;               /* Name length */
535         __u8    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  /* _LINUX_EXT2_FS_H */