1 | /*
|
---|
2 | * Copyright (c) 2011 Frantisek Princ
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup libext4
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 |
|
---|
33 | #ifndef LIBEXT4_LIBEXT4_FILESYSTEM_H_
|
---|
34 | #define LIBEXT4_LIBEXT4_FILESYSTEM_H_
|
---|
35 |
|
---|
36 | #include <libblock.h>
|
---|
37 | #include "libext4_block_group.h"
|
---|
38 | #include "libext4_inode.h"
|
---|
39 | #include "libext4_superblock.h"
|
---|
40 |
|
---|
41 | typedef struct ext4_filesystem {
|
---|
42 | service_id_t device;
|
---|
43 | ext4_superblock_t * superblock;
|
---|
44 | } ext4_filesystem_t;
|
---|
45 |
|
---|
46 | #define EXT4_MAX_BLOCK_SIZE 65536 //64 KiB
|
---|
47 | #define EXT4_REV0_INODE_SIZE 128
|
---|
48 |
|
---|
49 | /* Compatible features */
|
---|
50 | // TODO features comments !!!
|
---|
51 | #define EXT4_FEATURE_COMPAT_DIR_PREALLOC 0x0001
|
---|
52 | #define EXT4_FEATURE_COMPAT_IMAGIC_INODES 0x0002
|
---|
53 | #define EXT4_FEATURE_COMPAT_HAS_JOURNAL 0x0004
|
---|
54 | #define EXT4_FEATURE_COMPAT_EXT_ATTR 0x0008
|
---|
55 | #define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010
|
---|
56 | #define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020
|
---|
57 |
|
---|
58 | /* Read-only compatible features */
|
---|
59 | // TODO features comments !!!
|
---|
60 | #define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
|
---|
61 | #define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
|
---|
62 | #define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
|
---|
63 | #define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
|
---|
64 | #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
|
---|
65 | #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
|
---|
66 | #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
|
---|
67 |
|
---|
68 | /* Incompatible features */
|
---|
69 | // TODO features comments !!!
|
---|
70 | #define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001
|
---|
71 | #define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
|
---|
72 | #define EXT4_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
|
---|
73 | #define EXT4_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
|
---|
74 | #define EXT4_FEATURE_INCOMPAT_META_BG 0x0010
|
---|
75 | #define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
|
---|
76 | #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
|
---|
77 | #define EXT4_FEATURE_INCOMPAT_MMP 0x0100
|
---|
78 | #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
|
---|
79 | #define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400 /* EA in inode */
|
---|
80 | #define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000 /* data in dirent */
|
---|
81 |
|
---|
82 |
|
---|
83 | // TODO MODIFY features corresponding with implementation
|
---|
84 | #define EXT4_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR
|
---|
85 |
|
---|
86 | #define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
|
---|
87 | EXT4_FEATURE_INCOMPAT_RECOVER| \
|
---|
88 | EXT4_FEATURE_INCOMPAT_META_BG| \
|
---|
89 | EXT4_FEATURE_INCOMPAT_EXTENTS| \
|
---|
90 | EXT4_FEATURE_INCOMPAT_64BIT| \
|
---|
91 | EXT4_FEATURE_INCOMPAT_FLEX_BG)
|
---|
92 |
|
---|
93 | #define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \
|
---|
94 | EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
|
---|
95 | EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \
|
---|
96 | EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \
|
---|
97 | EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \
|
---|
98 | EXT4_FEATURE_RO_COMPAT_BTREE_DIR |\
|
---|
99 | EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
|
---|
100 |
|
---|
101 |
|
---|
102 | extern int ext4_filesystem_init(ext4_filesystem_t *, service_id_t);
|
---|
103 | extern void ext4_filesystem_fini(ext4_filesystem_t *fs);
|
---|
104 | extern int ext4_filesystem_check_sanity(ext4_filesystem_t *fs);
|
---|
105 | extern int ext4_filesystem_check_features(ext4_filesystem_t *, bool *);
|
---|
106 | extern int ext4_filesystem_get_block_group_ref(ext4_filesystem_t *, uint32_t,
|
---|
107 | ext4_block_group_ref_t **);
|
---|
108 | extern int ext4_filesystem_get_inode_ref(ext4_filesystem_t *, uint32_t,
|
---|
109 | ext4_inode_ref_t **);
|
---|
110 |
|
---|
111 |
|
---|
112 | #endif
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * @}
|
---|
116 | */
|
---|