~ubuntu-branches/ubuntu/hardy/silo/hardy-proposed

« back to all changes in this revision

Viewing changes to include/ext2fs/ext2fs.h

  • Committer: Bazaar Package Importer
  • Author(s): Fabio M. Di Nitto
  • Date: 2007-10-25 09:28:08 UTC
  • mfrom: (15.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071025092808-1yhj12t7s4zqsfu5
Tags: 1.4.13a+git20070930-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Build with -fno-stack-protector.
  - Change silo.postinst to automatically update the boot block without
    invoking siloconfig and keep asking questions on upgrades.
  - Convert silo.conf to use /dev/disk/by-uuid.
  - Ubuntu maintainer foobar.
  - Fix debian/rules call to dh_installdocs.
  - Drop the requirement of gcc-4.1 and start using default gcc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ext2fs.h --- ext2fs
 
3
 * 
 
4
 * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
 
5
 *
 
6
 * %Begin-Header%
 
7
 * This file may be redistributed under the terms of the GNU Public
 
8
 * License.
 
9
 * %End-Header%
 
10
 */
 
11
 
 
12
#ifndef _EXT2FS_EXT2FS_H
 
13
#define _EXT2FS_EXT2FS_H
 
14
 
 
15
#ifdef __cplusplus
 
16
extern "C" {
 
17
#endif
 
18
 
 
19
/*
 
20
 * Non-GNU C compilers won't necessarily understand inline
 
21
 */
 
22
#if (!defined(__GNUC__) && !defined(__WATCOMC__))
 
23
#define NO_INLINE_FUNCS
 
24
#endif
 
25
 
 
26
/*
 
27
 * Where the master copy of the superblock is located, and how big
 
28
 * superblocks are supposed to be.  We define SUPERBLOCK_SIZE because
 
29
 * the size of the superblock structure is not necessarily trustworthy
 
30
 * (some versions have the padding set up so that the superblock is
 
31
 * 1032 bytes long).
 
32
 */
 
33
#define SUPERBLOCK_OFFSET       1024
 
34
#define SUPERBLOCK_SIZE         1024
 
35
 
 
36
/*
 
37
 * The last ext2fs revision level that this version of the library is
 
38
 * able to support.
 
39
 */
 
40
#define EXT2_LIB_CURRENT_REV    0
 
41
 
 
42
#ifdef HAVE_SYS_TYPES_H
 
43
#include <sys/types.h>
 
44
#endif
 
45
 
 
46
#ifdef HAVE_STDLIB_H
 
47
#include <stdlib.h>
 
48
#endif
 
49
 
 
50
#if EXT2_FLAT_INCLUDES
 
51
#include "e2_types.h"
 
52
#else
 
53
#include <asm/types.h>
 
54
#if !defined(__GNUC__) || defined(__STRICT_ANSI__)  /* asm/types.h already defines __s64 and __u64 otherwise */
 
55
#if SIZEOF_LONG == 8
 
56
typedef __signed__ long __s64;
 
57
typedef unsigned long __u64;
 
58
#elif SIZEOF_LONG_LONG == 8 || \
 
59
  defined(__GNUC__) && (((~0UL) == 0xffffffff) || defined(__i386__))
 
60
typedef __signed__ long long __s64;
 
61
typedef unsigned long long __u64;
 
62
#endif /* SIZEOF_LONG == 8 */
 
63
#endif
 
64
#endif /* EXT2_FLAT_INCLUDES */
 
65
 
 
66
typedef __u32           blk_t;
 
67
typedef __u32           dgrp_t;
 
68
typedef __u32           ext2_off_t;
 
69
typedef __s64           e2_blkcnt_t;
 
70
 
 
71
#if EXT2_FLAT_INCLUDES
 
72
#include "com_err.h"
 
73
#include "ext2_io.h"
 
74
#include "ext2_err.h"
 
75
#else
 
76
#include "et/com_err.h"
 
77
#include "ext2fs/ext2_io.h"
 
78
#include "ext2fs/ext2_err.h"
 
79
#endif
 
80
 
 
81
/*
 
82
 * Portability help for Microsoft Visual C++
 
83
 */
 
84
#ifdef _MSC_VER
 
85
#define EXT2_QSORT_TYPE int __cdecl
 
86
#else
 
87
#define EXT2_QSORT_TYPE int
 
88
#endif
 
89
 
 
90
typedef struct struct_ext2_filsys *ext2_filsys;
 
91
 
 
92
struct ext2fs_struct_generic_bitmap {
 
93
        errcode_t       magic;
 
94
        ext2_filsys     fs;
 
95
        __u32           start, end;
 
96
        __u32           real_end;
 
97
        char    *       description;
 
98
        char    *       bitmap;
 
99
        errcode_t       base_error_code;
 
100
        __u32           reserved[7];
 
101
};
 
102
 
 
103
#define EXT2FS_MARK_ERROR       0
 
104
#define EXT2FS_UNMARK_ERROR     1
 
105
#define EXT2FS_TEST_ERROR       2
 
106
 
 
107
typedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap;
 
108
typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap;
 
109
typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap;
 
110
 
 
111
#ifdef EXT2_DYNAMIC_REV
 
112
#define EXT2_FIRST_INODE(s)     EXT2_FIRST_INO(s)
 
113
#else
 
114
#define EXT2_FIRST_INODE(s)     EXT2_FIRST_INO
 
115
#define EXT2_INODE_SIZE(s)      sizeof(struct ext2_inode)
 
116
#endif
 
117
 
 
118
/*
 
119
 * badblocks list definitions
 
120
 */
 
121
 
 
122
typedef struct ext2_struct_badblocks_list *ext2_badblocks_list;
 
123
typedef struct ext2_struct_badblocks_iterate *ext2_badblocks_iterate;
 
124
 
 
125
/* old */
 
126
typedef struct ext2_struct_badblocks_list *badblocks_list;
 
127
typedef struct ext2_struct_badblocks_iterate *badblocks_iterate;
 
128
 
 
129
#define BADBLOCKS_FLAG_DIRTY    1
 
130
 
 
131
/*
 
132
 * ext2_dblist structure and abstractions (see dblist.c)
 
133
 */
 
134
struct ext2_db_entry {
 
135
        ino_t   ino;
 
136
        blk_t   blk;
 
137
        int     blockcnt;
 
138
};
 
139
 
 
140
typedef struct ext2_struct_dblist *ext2_dblist;
 
141
 
 
142
#define DBLIST_ABORT    1
 
143
 
 
144
/*
 
145
 * ext2_fileio definitions
 
146
 */
 
147
 
 
148
#define EXT2_FILE_WRITE         0x0001
 
149
#define EXT2_FILE_CREATE        0x0002
 
150
 
 
151
#define EXT2_FILE_MASK          0x00FF
 
152
 
 
153
#define EXT2_FILE_BUF_DIRTY     0x4000
 
154
#define EXT2_FILE_BUF_VALID     0x2000
 
155
 
 
156
typedef struct ext2_file *ext2_file_t;
 
157
 
 
158
#define EXT2_SEEK_SET   0
 
159
#define EXT2_SEEK_CUR   1
 
160
#define EXT2_SEEK_END   2
 
161
 
 
162
/*
 
163
 * Flags for the ext2_filsys structure
 
164
 */
 
165
 
 
166
#define EXT2_FLAG_RW                    0x01
 
167
#define EXT2_FLAG_CHANGED               0x02
 
168
#define EXT2_FLAG_DIRTY                 0x04
 
169
#define EXT2_FLAG_VALID                 0x08
 
170
#define EXT2_FLAG_IB_DIRTY              0x10
 
171
#define EXT2_FLAG_BB_DIRTY              0x20
 
172
#define EXT2_FLAG_SWAP_BYTES            0x40
 
173
#define EXT2_FLAG_SWAP_BYTES_READ       0x80
 
174
#define EXT2_FLAG_SWAP_BYTES_WRITE      0x100
 
175
#define EXT2_FLAG_MASTER_SB_ONLY        0x200
 
176
#define EXT2_FLAG_FORCE                 0x400
 
177
 
 
178
/*
 
179
 * Special flag in the ext2 inode i_flag field that means that this is
 
180
 * a new inode.  (So that ext2_write_inode() can clear extra fields.)
 
181
 */
 
182
#define EXT2_NEW_INODE_FL       0x80000000
 
183
 
 
184
struct struct_ext2_filsys {
 
185
        errcode_t                       magic;
 
186
        io_channel                      io;
 
187
        int                             flags;
 
188
        char *                          device_name;
 
189
        struct ext2_super_block *       super;
 
190
        int                             blocksize;
 
191
        int                             fragsize;
 
192
        dgrp_t                          group_desc_count;
 
193
        unsigned long                   desc_blocks;
 
194
        struct ext2_group_desc *        group_desc;
 
195
        int                             inode_blocks_per_group;
 
196
        ext2fs_inode_bitmap             inode_map;
 
197
        ext2fs_block_bitmap             block_map;
 
198
        errcode_t (*get_blocks)(ext2_filsys fs, ino_t ino, blk_t *blocks);
 
199
        errcode_t (*check_directory)(ext2_filsys fs, ino_t ino);
 
200
        errcode_t (*write_bitmaps)(ext2_filsys fs);
 
201
        errcode_t (*read_inode)(ext2_filsys fs, ino_t ino,
 
202
                                struct ext2_inode *inode);
 
203
        errcode_t (*write_inode)(ext2_filsys fs, ino_t ino,
 
204
                                struct ext2_inode *inode);
 
205
        badblocks_list                  badblocks;
 
206
        ext2_dblist                     dblist;
 
207
        __u32                           stride; /* for mke2fs */
 
208
        /*
 
209
         * Reserved for future expansion
 
210
         */
 
211
        __u32                           reserved[11];
 
212
 
 
213
        /*
 
214
         * Reserved for the use of the calling application.
 
215
         */
 
216
        void *                          priv_data;
 
217
 
 
218
        /*
 
219
         * Inode cache
 
220
         */
 
221
        struct ext2_inode_cache         *icache;
 
222
};
 
223
 
 
224
#if EXT2_FLAT_INCLUDES
 
225
#include "e2_bitops.h"
 
226
#else
 
227
#include "ext2fs/bitops.h"
 
228
#endif
 
229
 
 
230
/*
 
231
 * Return flags for the block iterator functions
 
232
 */
 
233
#define BLOCK_CHANGED   1
 
234
#define BLOCK_ABORT     2
 
235
#define BLOCK_ERROR     4
 
236
 
 
237
/*
 
238
 * Block interate flags
 
239
 *
 
240
 * BLOCK_FLAG_APPEND, or BLOCK_FLAG_HOLE, indicates that the interator
 
241
 * function should be called on blocks where the block number is zero.
 
242
 * This is used by ext2fs_expand_dir() to be able to add a new block
 
243
 * to an inode.  It can also be used for programs that want to be able
 
244
 * to deal with files that contain "holes".
 
245
 * 
 
246
 * BLOCK_FLAG_TRAVERSE indicates that the iterator function for the
 
247
 * indirect, doubly indirect, etc. blocks should be called after all
 
248
 * of the blocks containined in the indirect blocks are processed.
 
249
 * This is useful if you are going to be deallocating blocks from an
 
250
 * inode.
 
251
 *
 
252
 * BLOCK_FLAG_DATA_ONLY indicates that the iterator function should be
 
253
 * called for data blocks only.
 
254
 *
 
255
 * BLOCK_FLAG_NO_LARGE is for internal use only.  It informs
 
256
 * ext2fs_block_iterate2 that large files won't be accepted.
 
257
 */
 
258
#define BLOCK_FLAG_APPEND       1
 
259
#define BLOCK_FLAG_HOLE         1
 
260
#define BLOCK_FLAG_DEPTH_TRAVERSE       2
 
261
#define BLOCK_FLAG_DATA_ONLY    4
 
262
 
 
263
#define BLOCK_FLAG_NO_LARGE     0x1000
 
264
 
 
265
/*
 
266
 * Magic "block count" return values for the block iterator function.
 
267
 */
 
268
#define BLOCK_COUNT_IND         (-1)
 
269
#define BLOCK_COUNT_DIND        (-2)
 
270
#define BLOCK_COUNT_TIND        (-3)
 
271
#define BLOCK_COUNT_TRANSLATOR  (-4)
 
272
 
 
273
#if 0
 
274
/*
 
275
 * Flags for ext2fs_move_blocks
 
276
 */
 
277
#define EXT2_BMOVE_GET_DBLIST   0x0001  
 
278
#define EXT2_BMOVE_DEBUG        0x0002
 
279
#endif
 
280
 
 
281
/*
 
282
 * Return flags for the directory iterator functions
 
283
 */
 
284
#define DIRENT_CHANGED  1
 
285
#define DIRENT_ABORT    2
 
286
#define DIRENT_ERROR    3
 
287
 
 
288
/*
 
289
 * Directory iterator flags
 
290
 */
 
291
 
 
292
#define DIRENT_FLAG_INCLUDE_EMPTY       1
 
293
 
 
294
 
 
295
#define DIRENT_DOT_FILE         1
 
296
#define DIRENT_DOT_DOT_FILE     2
 
297
#define DIRENT_OTHER_FILE       3
 
298
 
 
299
/*
 
300
 * Inode scan definitions
 
301
 */
 
302
typedef struct ext2_struct_inode_scan *ext2_inode_scan;
 
303
 
 
304
/*
 
305
 * ext2fs_scan flags
 
306
 */
 
307
#define EXT2_SF_CHK_BADBLOCKS   0x0001
 
308
#define EXT2_SF_BAD_INODE_BLK   0x0002
 
309
#define EXT2_SF_BAD_EXTRA_BYTES 0x0004
 
310
#define EXT2_SF_SKIP_MISSING_ITABLE     0x0008
 
311
 
 
312
/*
 
313
 * ext2fs_check_if_mounted flags
 
314
 */
 
315
#define EXT2_MF_MOUNTED         1
 
316
#define EXT2_MF_ISROOT          2
 
317
#define EXT2_MF_READONLY        4
 
318
 
 
319
/*
 
320
 * Ext2/linux mode flags.  We define them here so that we don't need
 
321
 * to depend on the OS's sys/stat.h, since we may be compiling on a
 
322
 * non-Linux system.
 
323
 */
 
324
#define LINUX_S_IFMT  00170000
 
325
#define LINUX_S_IFSOCK 0140000
 
326
#define LINUX_S_IFLNK    0120000
 
327
#define LINUX_S_IFREG  0100000
 
328
#define LINUX_S_IFBLK  0060000
 
329
#define LINUX_S_IFDIR  0040000
 
330
#define LINUX_S_IFCHR  0020000
 
331
#define LINUX_S_IFIFO  0010000
 
332
#define LINUX_S_ISUID  0004000
 
333
#define LINUX_S_ISGID  0002000
 
334
#define LINUX_S_ISVTX  0001000
 
335
 
 
336
#define LINUX_S_IRWXU 00700
 
337
#define LINUX_S_IRUSR 00400
 
338
#define LINUX_S_IWUSR 00200
 
339
#define LINUX_S_IXUSR 00100
 
340
 
 
341
#define LINUX_S_IRWXG 00070
 
342
#define LINUX_S_IRGRP 00040
 
343
#define LINUX_S_IWGRP 00020
 
344
#define LINUX_S_IXGRP 00010
 
345
 
 
346
#define LINUX_S_IRWXO 00007
 
347
#define LINUX_S_IROTH 00004
 
348
#define LINUX_S_IWOTH 00002
 
349
#define LINUX_S_IXOTH 00001
 
350
 
 
351
#define LINUX_S_ISLNK(m)        (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK)
 
352
#define LINUX_S_ISREG(m)        (((m) & LINUX_S_IFMT) == LINUX_S_IFREG)
 
353
#define LINUX_S_ISDIR(m)        (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)
 
354
#define LINUX_S_ISCHR(m)        (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR)
 
355
#define LINUX_S_ISBLK(m)        (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK)
 
356
#define LINUX_S_ISFIFO(m)       (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO)
 
357
#define LINUX_S_ISSOCK(m)       (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK)
 
358
 
 
359
/*
 
360
 * ext2_icount_t abstraction
 
361
 */
 
362
#define EXT2_ICOUNT_OPT_INCREMENT       0x01
 
363
 
 
364
typedef struct ext2_icount *ext2_icount_t;
 
365
 
 
366
/*
 
367
 * Flags for ext2fs_bmap
 
368
 */
 
369
#define BMAP_ALLOC      1
 
370
 
 
371
/*
 
372
 * For checking structure magic numbers...
 
373
 */
 
374
 
 
375
#define EXT2_CHECK_MAGIC(struct, code) \
 
376
          if ((struct)->magic != (code)) return (code)
 
377
 
 
378
 
 
379
/*
 
380
 * The ext2fs library private definition of the ext2 superblock, so we
 
381
 * don't have to depend on the kernel's definition of the superblock,
 
382
 * which might not have the latest features.
 
383
 */
 
384
struct ext2fs_sb {
 
385
        __u32   s_inodes_count;         /* Inodes count */
 
386
        __u32   s_blocks_count;         /* Blocks count */
 
387
        __u32   s_r_blocks_count;       /* Reserved blocks count */
 
388
        __u32   s_free_blocks_count;    /* Free blocks count */
 
389
        __u32   s_free_inodes_count;    /* Free inodes count */
 
390
        __u32   s_first_data_block;     /* First Data Block */
 
391
        __u32   s_log_block_size;       /* Block size */
 
392
        __s32   s_log_frag_size;        /* Fragment size */
 
393
        __u32   s_blocks_per_group;     /* # Blocks per group */
 
394
        __u32   s_frags_per_group;      /* # Fragments per group */
 
395
        __u32   s_inodes_per_group;     /* # Inodes per group */
 
396
        __u32   s_mtime;                /* Mount time */
 
397
        __u32   s_wtime;                /* Write time */
 
398
        __u16   s_mnt_count;            /* Mount count */
 
399
        __s16   s_max_mnt_count;        /* Maximal mount count */
 
400
        __u16   s_magic;                /* Magic signature */
 
401
        __u16   s_state;                /* File system state */
 
402
        __u16   s_errors;               /* Behaviour when detecting errors */
 
403
        __u16   s_minor_rev_level;      /* minor revision level */
 
404
        __u32   s_lastcheck;            /* time of last check */
 
405
        __u32   s_checkinterval;        /* max. time between checks */
 
406
        __u32   s_creator_os;           /* OS */
 
407
        __u32   s_rev_level;            /* Revision level */
 
408
        __u16   s_def_resuid;           /* Default uid for reserved blocks */
 
409
        __u16   s_def_resgid;           /* Default gid for reserved blocks */
 
410
        /*
 
411
         * These fields are for EXT2_DYNAMIC_REV superblocks only.
 
412
         *
 
413
         * Note: the difference between the compatible feature set and
 
414
         * the incompatible feature set is that if there is a bit set
 
415
         * in the incompatible feature set that the kernel doesn't
 
416
         * know about, it should refuse to mount the filesystem.
 
417
         * 
 
418
         * e2fsck's requirements are more strict; if it doesn't know
 
419
         * about a feature in either the compatible or incompatible
 
420
         * feature set, it must abort and not try to meddle with
 
421
         * things it doesn't understand...
 
422
         */
 
423
        __u32   s_first_ino;            /* First non-reserved inode */
 
424
        __u16   s_inode_size;           /* size of inode structure */
 
425
        __u16   s_block_group_nr;       /* block group # of this superblock */
 
426
        __u32   s_feature_compat;       /* compatible feature set */
 
427
        __u32   s_feature_incompat;     /* incompatible feature set */
 
428
        __u32   s_feature_ro_compat;    /* readonly-compatible feature set */
 
429
        __u8    s_uuid[16];             /* 128-bit uuid for volume */
 
430
        char    s_volume_name[16];      /* volume name */
 
431
        char    s_last_mounted[64];     /* directory where last mounted */
 
432
        __u32   s_algorithm_usage_bitmap; /* For compression */
 
433
        /*
 
434
         * Performance hints.  Directory preallocation should only
 
435
         * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
 
436
         */
 
437
        __u8    s_prealloc_blocks;      /* Nr of blocks to try to preallocate*/
 
438
        __u8    s_prealloc_dir_blocks;  /* Nr to preallocate for dirs */
 
439
        __u16   s_padding1;
 
440
        /* 
 
441
         * Journaling support.
 
442
         */
 
443
        __u8    s_journal_uuid[16];     /* uuid of journal superblock */
 
444
        __u32   s_journal_inum;         /* inode number of journal file */
 
445
        __u32   s_journal_dev;          /* device number of journal file */
 
446
        __u32   s_last_orphan;          /* start of list of inodes to delete */
 
447
        
 
448
        __u32   s_reserved[197];        /* Padding to the end of the block */
 
449
};
 
450
 
 
451
#define EXT2FS_COMPRESSED_BLKADDR ((blk_t) 0xffffffff)
 
452
#define HOLE_BLKADDR(_b) ((_b) == 0 || (_b) == EXT2FS_COMPRESSED_BLKADDR)
 
453
 
 
454
/*
 
455
 * Feature set definitions (that might not be in ext2_fs.h
 
456
 */
 
457
 
 
458
#ifndef EXT2_FEATURE_COMPAT_DIR_PREALLOC
 
459
#define EXT2_FEATURE_COMPAT_DIR_PREALLOC        0x0001
 
460
#endif
 
461
 
 
462
#ifndef EXT2_FEATURE_COMPAT_IMAGIC_INODES /* for AFS, etc. */
 
463
#define EXT2_FEATURE_COMPAT_IMAGIC_INODES               0x0002
 
464
#define EXT2_IMAGIC_FL          0x00002000
 
465
#endif
 
466
 
 
467
#ifndef EXT3_FEATURE_COMPAT_HAS_JOURNAL
 
468
#define EXT3_FEATURE_COMPAT_HAS_JOURNAL         0x0004
 
469
#endif
 
470
 
 
471
#ifndef EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
 
472
#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER     0x0001
 
473
#endif
 
474
 
 
475
#ifndef EXT2_FEATURE_RO_COMPAT_LARGE_FILE
 
476
#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE       0x0002
 
477
#define i_size_high i_dir_acl
 
478
#endif
 
479
 
 
480
#ifndef EXT2_FEATURE_RO_COMPAT_BTREE_DIR
 
481
#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR        0x0004
 
482
#endif
 
483
 
 
484
#ifndef EXT2_FEATURE_INCOMPAT_COMPRESSION
 
485
#define EXT2_FEATURE_INCOMPAT_COMPRESSION       0x0001
 
486
#endif
 
487
 
 
488
#ifndef EXT2_FEATURE_INCOMPAT_FILETYPE
 
489
#define EXT2_FEATURE_INCOMPAT_FILETYPE  0x0002
 
490
#endif
 
491
 
 
492
#ifndef EXT3_FEATURE_INCOMPAT_RECOVER 
 
493
#define EXT3_FEATURE_INCOMPAT_RECOVER   0x0004 /* Needs recovery */
 
494
#endif
 
495
 
 
496
#define EXT2_LIB_FEATURE_COMPAT_SUPP    (EXT2_FEATURE_COMPAT_DIR_PREALLOC|\
 
497
                                         EXT2_FEATURE_COMPAT_IMAGIC_INODES|\
 
498
                                         EXT3_FEATURE_COMPAT_HAS_JOURNAL)
 
499
/* This #ifdef is temporary until compression is fully supported */
 
500
#ifdef ENABLE_COMPRESSION
 
501
#ifndef I_KNOW_THAT_COMPRESSION_IS_EXPERIMENTAL
 
502
/* If the below warning bugs you, then have
 
503
   `CPPFLAGS=-DI_KNOW_THAT_COMPRESSION_IS_EXPERIMENTAL' in your
 
504
   environment at configure time. */
 
505
#warning "Compression support is experimental"
 
506
#endif
 
507
#define EXT2_LIB_FEATURE_INCOMPAT_SUPP  (EXT2_FEATURE_INCOMPAT_FILETYPE|\
 
508
                                         EXT2_FEATURE_INCOMPAT_COMPRESSION|\
 
509
                                         EXT3_FEATURE_INCOMPAT_RECOVER)
 
510
#else
 
511
#define EXT2_LIB_FEATURE_INCOMPAT_SUPP  (EXT2_FEATURE_INCOMPAT_FILETYPE|\
 
512
                                         EXT3_FEATURE_INCOMPAT_RECOVER)
 
513
#endif
 
514
#define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
 
515
                                         EXT2_FEATURE_RO_COMPAT_LARGE_FILE)
 
516
/*
 
517
 * function prototypes
 
518
 */
 
519
 
 
520
/* alloc.c */
 
521
extern errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode,
 
522
                                  ext2fs_inode_bitmap map, ino_t *ret);
 
523
extern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal,
 
524
                                  ext2fs_block_bitmap map, blk_t *ret);
 
525
extern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start,
 
526
                                        blk_t finish, int num,
 
527
                                        ext2fs_block_bitmap map,
 
528
                                        blk_t *ret);
 
529
extern errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal,
 
530
                                    char *block_buf, blk_t *ret);
 
531
 
 
532
/* alloc_tables.c */
 
533
extern errcode_t ext2fs_allocate_tables(ext2_filsys fs);
 
534
extern errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
 
535
                                             ext2fs_block_bitmap bmap);
 
536
 
 
537
/* badblocks.c */
 
538
extern errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret,
 
539
                                            int size);
 
540
extern errcode_t ext2fs_badblocks_list_add(ext2_badblocks_list bb,
 
541
                                           blk_t blk);
 
542
extern int ext2fs_badblocks_list_test(ext2_badblocks_list bb,
 
543
                                    blk_t blk);
 
544
extern errcode_t
 
545
        ext2fs_badblocks_list_iterate_begin(ext2_badblocks_list bb,
 
546
                                            ext2_badblocks_iterate *ret);
 
547
extern int ext2fs_badblocks_list_iterate(ext2_badblocks_iterate iter,
 
548
                                         blk_t *blk);
 
549
extern void ext2fs_badblocks_list_iterate_end(ext2_badblocks_iterate iter);
 
550
extern errcode_t ext2fs_badblocks_copy(ext2_badblocks_list src,
 
551
                                       ext2_badblocks_list *dest);
 
552
extern int ext2fs_badblocks_equal(ext2_badblocks_list bb1,
 
553
                                  ext2_badblocks_list bb2);
 
554
 
 
555
/* bb_compat */
 
556
extern errcode_t badblocks_list_create(badblocks_list *ret, int size);
 
557
extern errcode_t badblocks_list_add(badblocks_list bb, blk_t blk);
 
558
extern int badblocks_list_test(badblocks_list bb, blk_t blk);
 
559
extern errcode_t badblocks_list_iterate_begin(badblocks_list bb,
 
560
                                              badblocks_iterate *ret);
 
561
extern int badblocks_list_iterate(badblocks_iterate iter, blk_t *blk);
 
562
extern void badblocks_list_iterate_end(badblocks_iterate iter);
 
563
extern void badblocks_list_free(badblocks_list bb);
 
564
 
 
565
/* bb_inode.c */
 
566
extern errcode_t ext2fs_update_bb_inode(ext2_filsys fs,
 
567
                                        ext2_badblocks_list bb_list);
 
568
 
 
569
/* bitmaps.c */
 
570
extern errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs);
 
571
extern errcode_t ext2fs_write_block_bitmap (ext2_filsys fs);
 
572
extern errcode_t ext2fs_read_inode_bitmap (ext2_filsys fs);
 
573
extern errcode_t ext2fs_read_block_bitmap(ext2_filsys fs);
 
574
extern errcode_t ext2fs_allocate_generic_bitmap(__u32 start,
 
575
                                                __u32 end,
 
576
                                                __u32 real_end,
 
577
                                                const char *descr,
 
578
                                                ext2fs_generic_bitmap *ret);
 
579
extern errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
 
580
                                              const char *descr,
 
581
                                              ext2fs_block_bitmap *ret);
 
582
extern errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs,
 
583
                                              const char *descr,
 
584
                                              ext2fs_inode_bitmap *ret);
 
585
extern errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap,
 
586
                                               ino_t end, ino_t *oend);
 
587
extern errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap,
 
588
                                               blk_t end, blk_t *oend);
 
589
extern void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap);
 
590
extern void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap);
 
591
extern errcode_t ext2fs_read_bitmaps(ext2_filsys fs);
 
592
extern errcode_t ext2fs_write_bitmaps(ext2_filsys fs);
 
593
 
 
594
/* block.c */
 
595
extern errcode_t ext2fs_block_iterate(ext2_filsys fs,
 
596
                                      ino_t     ino,
 
597
                                      int       flags,
 
598
                                      char *block_buf,
 
599
                                      int (*func)(ext2_filsys fs,
 
600
                                                  blk_t *blocknr,
 
601
                                                  int   blockcnt,
 
602
                                                  void  *priv_data),
 
603
                                      void *priv_data);
 
604
errcode_t ext2fs_block_iterate2(ext2_filsys fs,
 
605
                                ino_t   ino,
 
606
                                int     flags,
 
607
                                char *block_buf,
 
608
                                int (*func)(ext2_filsys fs,
 
609
                                            blk_t       *blocknr,
 
610
                                            e2_blkcnt_t blockcnt,
 
611
                                            blk_t       ref_blk,
 
612
                                            int         ref_offset,
 
613
                                            void        *priv_data),
 
614
                                void *priv_data);
 
615
 
 
616
/* bmap.c */
 
617
extern errcode_t ext2fs_bmap(ext2_filsys fs, ino_t ino,
 
618
                             struct ext2_inode *inode, 
 
619
                             char *block_buf, int bmap_flags,
 
620
                             blk_t block, blk_t *phys_blk);
 
621
 
 
622
 
 
623
#if 0
 
624
/* bmove.c */
 
625
extern errcode_t ext2fs_move_blocks(ext2_filsys fs,
 
626
                                    ext2fs_block_bitmap reserve,
 
627
                                    ext2fs_block_bitmap alloc_map,
 
628
                                    int flags);
 
629
#endif
 
630
 
 
631
/* check_desc.c */
 
632
extern errcode_t ext2fs_check_desc(ext2_filsys fs);
 
633
 
 
634
/* closefs.c */
 
635
extern errcode_t ext2fs_close(ext2_filsys fs);
 
636
extern errcode_t ext2fs_flush(ext2_filsys fs);
 
637
extern int ext2fs_bg_has_super(ext2_filsys fs, int group_block);
 
638
 
 
639
/* cmp_bitmaps.c */
 
640
extern errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1,
 
641
                                             ext2fs_block_bitmap bm2);
 
642
extern errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
 
643
                                             ext2fs_inode_bitmap bm2);
 
644
 
 
645
/* dblist.c */
 
646
 
 
647
extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ino_t *ret_num_dirs);
 
648
extern errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist);
 
649
extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ino_t ino,
 
650
                                      blk_t blk, int blockcnt);
 
651
extern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist,
 
652
        int (*func)(ext2_filsys fs, struct ext2_db_entry *db_info,
 
653
                    void        *priv_data),
 
654
       void *priv_data);
 
655
extern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ino_t ino,
 
656
                                      blk_t blk, int blockcnt);
 
657
extern errcode_t ext2fs_copy_dblist(ext2_dblist src,
 
658
                                    ext2_dblist *dest);
 
659
extern int ext2fs_dblist_count(ext2_dblist dblist);
 
660
 
 
661
/* dblist_dir.c */
 
662
extern errcode_t
 
663
        ext2fs_dblist_dir_iterate(ext2_dblist dblist,
 
664
                                  int   flags,
 
665
                                  char  *block_buf,
 
666
                                  int (*func)(ino_t     dir,
 
667
                                              int               entry,
 
668
                                              struct ext2_dir_entry *dirent,
 
669
                                              int       offset,
 
670
                                              int       blocksize,
 
671
                                              char      *buf,
 
672
                                              void      *priv_data),
 
673
                                  void *priv_data);
 
674
 
 
675
/* dirblock.c */
 
676
extern errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block,
 
677
                                       void *buf);
 
678
extern errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block,
 
679
                                        void *buf);
 
680
 
 
681
/* dir_iterate.c */
 
682
extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, 
 
683
                              ino_t dir,
 
684
                              int flags,
 
685
                              char *block_buf,
 
686
                              int (*func)(struct ext2_dir_entry *dirent,
 
687
                                          int   offset,
 
688
                                          int   blocksize,
 
689
                                          char  *buf,
 
690
                                          void  *priv_data),
 
691
                              void *priv_data);
 
692
 
 
693
/* dupfs.c */
 
694
extern errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest);
 
695
 
 
696
/* expanddir.c */
 
697
extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ino_t dir);
 
698
 
 
699
/* fileio.c */
 
700
extern errcode_t ext2fs_file_open(ext2_filsys fs, ino_t ino,
 
701
                                  int flags, ext2_file_t *ret);
 
702
extern ext2_filsys ext2fs_file_get_fs(ext2_file_t file);
 
703
extern errcode_t ext2fs_file_close(ext2_file_t file);
 
704
extern errcode_t ext2fs_file_read(ext2_file_t file, void *buf,
 
705
                                  unsigned int wanted, unsigned int *got);
 
706
extern errcode_t ext2fs_file_write(ext2_file_t file, void *buf,
 
707
                                   unsigned int nbytes, unsigned int *written);
 
708
extern errcode_t ext2fs_file_lseek(ext2_file_t file, ext2_off_t offset,
 
709
                                   int whence, ext2_off_t *ret_pos);
 
710
extern ext2_off_t ext2fs_file_get_size(ext2_file_t file);
 
711
extern errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size);
 
712
 
 
713
/* freefs.c */
 
714
extern void ext2fs_free(ext2_filsys fs);
 
715
extern void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap);
 
716
extern void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap);
 
717
extern void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap);
 
718
extern void ext2fs_free_dblist(ext2_dblist dblist);
 
719
extern void ext2fs_badblocks_list_free(badblocks_list bb);
 
720
 
 
721
/* getsize.c */
 
722
extern errcode_t ext2fs_get_device_size(const char *file, int blocksize,
 
723
                                        blk_t *retblocks);
 
724
 
 
725
/* initialize.c */
 
726
extern errcode_t ext2fs_initialize(const char *name, int flags,
 
727
                                   struct ext2_super_block *param,
 
728
                                   io_manager manager, ext2_filsys *ret_fs);
 
729
 
 
730
/* inode.c */
 
731
extern errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks,
 
732
                                  ext2_inode_scan *ret_scan);
 
733
extern void ext2fs_close_inode_scan(ext2_inode_scan scan);
 
734
extern errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ino_t *ino,
 
735
                               struct ext2_inode *inode);
 
736
extern errcode_t ext2fs_inode_scan_goto_blockgroup(ext2_inode_scan scan,
 
737
                                                   int  group);
 
738
extern void ext2fs_set_inode_callback
 
739
        (ext2_inode_scan scan,
 
740
         errcode_t (*done_group)(ext2_filsys fs,
 
741
                                 ext2_inode_scan scan,
 
742
                                 dgrp_t group,
 
743
                                 void * priv_data),
 
744
         void *done_group_data);
 
745
extern int ext2fs_inode_scan_flags(ext2_inode_scan scan, int set_flags,
 
746
                                   int clear_flags);
 
747
extern errcode_t ext2fs_read_inode (ext2_filsys fs, ino_t ino,
 
748
                            struct ext2_inode * inode);
 
749
extern errcode_t ext2fs_write_inode(ext2_filsys fs, ino_t ino,
 
750
                            struct ext2_inode * inode);
 
751
extern errcode_t ext2fs_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks);
 
752
extern errcode_t ext2fs_check_directory(ext2_filsys fs, ino_t ino);
 
753
 
 
754
/* icount.c */
 
755
extern void ext2fs_free_icount(ext2_icount_t icount);
 
756
extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, int size,
 
757
                                       ext2_icount_t hint, ext2_icount_t *ret);
 
758
extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, int size,
 
759
                                      ext2_icount_t *ret);
 
760
extern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ino_t ino,
 
761
                                     __u16 *ret);
 
762
extern errcode_t ext2fs_icount_increment(ext2_icount_t icount, ino_t ino,
 
763
                                         __u16 *ret);
 
764
extern errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ino_t ino,
 
765
                                         __u16 *ret);
 
766
extern errcode_t ext2fs_icount_store(ext2_icount_t icount, ino_t ino,
 
767
                                     __u16 count);
 
768
extern ino_t ext2fs_get_icount_size(ext2_icount_t icount);
 
769
errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *);
 
770
 
 
771
/* ismounted.c */
 
772
extern errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags);
 
773
 
 
774
/* namei.c */
 
775
extern errcode_t ext2fs_lookup(ext2_filsys fs, ino_t dir, const char *name,
 
776
                         int namelen, char *buf, ino_t *inode);
 
777
extern errcode_t ext2fs_namei(ext2_filsys fs, ino_t root, ino_t cwd,
 
778
                        const char *name, ino_t *inode);
 
779
errcode_t ext2fs_namei_follow(ext2_filsys fs, ino_t root, ino_t cwd,
 
780
                              const char *name, ino_t *inode);
 
781
extern errcode_t ext2fs_follow_link(ext2_filsys fs, ino_t root, ino_t cwd,
 
782
                        ino_t inode, ino_t *res_inode);
 
783
 
 
784
/* native.c */
 
785
int ext2fs_native_flag(void);
 
786
 
 
787
/* newdir.c */
 
788
extern errcode_t ext2fs_new_dir_block(ext2_filsys fs, ino_t dir_ino,
 
789
                                ino_t parent_ino, char **block);
 
790
 
 
791
/* mkdir.c */
 
792
extern errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum,
 
793
                              const char *name);
 
794
 
 
795
/* openfs.c */
 
796
extern errcode_t ext2fs_open(const char *name, int flags, int superblock,
 
797
                             int block_size, io_manager manager,
 
798
                             ext2_filsys *ret_fs);
 
799
 
 
800
/* get_pathname.c */
 
801
extern errcode_t ext2fs_get_pathname(ext2_filsys fs, ino_t dir, ino_t ino,
 
802
                               char **name);
 
803
 
 
804
/* link.c */
 
805
errcode_t ext2fs_link(ext2_filsys fs, ino_t dir, const char *name,
 
806
                      ino_t ino, int flags);
 
807
errcode_t ext2fs_unlink(ext2_filsys fs, ino_t dir, const char *name,
 
808
                        ino_t ino, int flags);
 
809
 
 
810
/* read_bb.c */
 
811
extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs,
 
812
                                      ext2_badblocks_list *bb_list);
 
813
 
 
814
/* read_bb_file.c */
 
815
extern errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f, 
 
816
                                      ext2_badblocks_list *bb_list,
 
817
                                      void *private,
 
818
                                      void (*invalid)(ext2_filsys fs,
 
819
                                                      blk_t blk,
 
820
                                                      char *badstr,
 
821
                                                      void *private));
 
822
extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, 
 
823
                                     ext2_badblocks_list *bb_list,
 
824
                                     void (*invalid)(ext2_filsys fs,
 
825
                                                     blk_t blk));
 
826
 
 
827
/* rs_bitmap.c */
 
828
extern errcode_t ext2fs_resize_generic_bitmap(__u32 new_end,
 
829
                                              __u32 new_real_end,
 
830
                                              ext2fs_generic_bitmap bmap);
 
831
extern errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end,
 
832
                                            ext2fs_inode_bitmap bmap);
 
833
extern errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end,
 
834
                                            ext2fs_block_bitmap bmap);
 
835
extern errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src,
 
836
                                    ext2fs_generic_bitmap *dest);
 
837
 
 
838
/* swapfs.c */
 
839
extern void ext2fs_swap_super(struct ext2_super_block * super);
 
840
extern void ext2fs_swap_group_desc(struct ext2_group_desc *gdp);
 
841
extern void ext2fs_swap_inode(ext2_filsys fs,struct ext2_inode *t,
 
842
                              struct ext2_inode *f, int hostorder);
 
843
 
 
844
/* valid_blk.c */
 
845
extern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode);
 
846
 
 
847
/* version.c */
 
848
extern int ext2fs_parse_version_string(const char *ver_string);
 
849
extern int ext2fs_get_library_version(const char **ver_string,
 
850
                                      const char **date_string);
 
851
 
 
852
/* inline functions */
 
853
extern errcode_t ext2fs_get_mem(unsigned long size, void **ptr);
 
854
extern errcode_t ext2fs_free_mem(void **ptr);
 
855
#if 0
 
856
extern errcode_t ext2fs_resize_mem(unsigned long old_size,
 
857
                                   unsigned long size, void **ptr);
 
858
#endif
 
859
extern void ext2fs_mark_super_dirty(ext2_filsys fs);
 
860
extern void ext2fs_mark_changed(ext2_filsys fs);
 
861
extern int ext2fs_test_changed(ext2_filsys fs);
 
862
extern void ext2fs_mark_valid(ext2_filsys fs);
 
863
extern void ext2fs_unmark_valid(ext2_filsys fs);
 
864
extern int ext2fs_test_valid(ext2_filsys fs);
 
865
extern void ext2fs_mark_ib_dirty(ext2_filsys fs);
 
866
extern void ext2fs_mark_bb_dirty(ext2_filsys fs);
 
867
extern int ext2fs_test_ib_dirty(ext2_filsys fs);
 
868
extern int ext2fs_test_bb_dirty(ext2_filsys fs);
 
869
extern int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk);
 
870
extern int ext2fs_group_of_ino(ext2_filsys fs, ino_t ino);
 
871
extern blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
 
872
                                     struct ext2_inode *inode);
 
873
 
 
874
/*
 
875
 * The actual inlined functions definitions themselves...
 
876
 *
 
877
 * If NO_INLINE_FUNCS is defined, then we won't try to do inline
 
878
 * functions at all!
 
879
 */
 
880
#if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
 
881
#ifdef INCLUDE_INLINE_FUNCS
 
882
#define _INLINE_ extern
 
883
#else
 
884
#ifdef __GNUC__
 
885
#define _INLINE_ extern __inline__
 
886
#else                           /* For Watcom C */
 
887
#define _INLINE_ extern inline
 
888
#endif
 
889
#endif
 
890
 
 
891
#ifndef EXT2_CUSTOM_MEMORY_ROUTINES
 
892
/*
 
893
 *  Allocate memory
 
894
 */
 
895
_INLINE_ errcode_t ext2fs_get_mem(unsigned long size, void **ptr)
 
896
{
 
897
        *ptr = malloc(size);
 
898
        if (!*ptr)
 
899
                return EXT2_ET_NO_MEMORY;
 
900
        return 0;
 
901
}
 
902
 
 
903
/*
 
904
 * Free memory
 
905
 */
 
906
_INLINE_ errcode_t ext2fs_free_mem(void **ptr)
 
907
{
 
908
        free(*ptr);
 
909
        *ptr = 0;
 
910
        return 0;
 
911
}
 
912
 
 
913
#if 0
 
914
/*
 
915
 *  Resize memory
 
916
 */
 
917
_INLINE_ errcode_t ext2fs_resize_mem(unsigned long old_size,
 
918
                                     unsigned long size, void **ptr)
 
919
{
 
920
        void *p;
 
921
 
 
922
        p = realloc(*ptr, size);
 
923
        if (!p)
 
924
                return EXT2_ET_NO_MEMORY;
 
925
        *ptr = p;
 
926
        return 0;
 
927
}
 
928
#endif
 
929
#endif  /* Custom memory routines */
 
930
 
 
931
/*
 
932
 * Mark a filesystem superblock as dirty
 
933
 */
 
934
_INLINE_ void ext2fs_mark_super_dirty(ext2_filsys fs)
 
935
{
 
936
        fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_CHANGED;
 
937
}
 
938
 
 
939
/*
 
940
 * Mark a filesystem as changed
 
941
 */
 
942
_INLINE_ void ext2fs_mark_changed(ext2_filsys fs)
 
943
{
 
944
        fs->flags |= EXT2_FLAG_CHANGED;
 
945
}
 
946
 
 
947
/*
 
948
 * Check to see if a filesystem has changed
 
949
 */
 
950
_INLINE_ int ext2fs_test_changed(ext2_filsys fs)
 
951
{
 
952
        return (fs->flags & EXT2_FLAG_CHANGED);
 
953
}
 
954
 
 
955
/*
 
956
 * Mark a filesystem as valid
 
957
 */
 
958
_INLINE_ void ext2fs_mark_valid(ext2_filsys fs)
 
959
{
 
960
        fs->flags |= EXT2_FLAG_VALID;
 
961
}
 
962
 
 
963
/*
 
964
 * Mark a filesystem as NOT valid
 
965
 */
 
966
_INLINE_ void ext2fs_unmark_valid(ext2_filsys fs)
 
967
{
 
968
        fs->flags &= ~EXT2_FLAG_VALID;
 
969
}
 
970
 
 
971
/*
 
972
 * Check to see if a filesystem is valid
 
973
 */
 
974
_INLINE_ int ext2fs_test_valid(ext2_filsys fs)
 
975
{
 
976
        return (fs->flags & EXT2_FLAG_VALID);
 
977
}
 
978
 
 
979
/*
 
980
 * Mark the inode bitmap as dirty
 
981
 */
 
982
_INLINE_ void ext2fs_mark_ib_dirty(ext2_filsys fs)
 
983
{
 
984
        fs->flags |= EXT2_FLAG_IB_DIRTY | EXT2_FLAG_CHANGED;
 
985
}
 
986
 
 
987
/*
 
988
 * Mark the block bitmap as dirty
 
989
 */
 
990
_INLINE_ void ext2fs_mark_bb_dirty(ext2_filsys fs)
 
991
{
 
992
        fs->flags |= EXT2_FLAG_BB_DIRTY | EXT2_FLAG_CHANGED;
 
993
}
 
994
 
 
995
/*
 
996
 * Check to see if a filesystem's inode bitmap is dirty
 
997
 */
 
998
_INLINE_ int ext2fs_test_ib_dirty(ext2_filsys fs)
 
999
{
 
1000
        return (fs->flags & EXT2_FLAG_IB_DIRTY);
 
1001
}
 
1002
 
 
1003
/*
 
1004
 * Check to see if a filesystem's block bitmap is dirty
 
1005
 */
 
1006
_INLINE_ int ext2fs_test_bb_dirty(ext2_filsys fs)
 
1007
{
 
1008
        return (fs->flags & EXT2_FLAG_BB_DIRTY);
 
1009
}
 
1010
 
 
1011
/*
 
1012
 * Return the group # of a block
 
1013
 */
 
1014
_INLINE_ int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk)
 
1015
{
 
1016
        return (blk - fs->super->s_first_data_block) /
 
1017
                fs->super->s_blocks_per_group;
 
1018
}
 
1019
 
 
1020
/*
 
1021
 * Return the group # of an inode number
 
1022
 */
 
1023
_INLINE_ int ext2fs_group_of_ino(ext2_filsys fs, ino_t ino)
 
1024
{
 
1025
        return (ino - 1) / fs->super->s_inodes_per_group;
 
1026
}
 
1027
#undef _INLINE_
 
1028
#endif
 
1029
 
 
1030
#ifdef __cplusplus
 
1031
}
 
1032
#endif
 
1033
 
 
1034
#endif /* _EXT2FS_EXT2FS_H */