1 /****************************************************************************
2  ****************************************************************************
3  ***
4  ***   This header was automatically generated from a Linux kernel header
5  ***   of the same name, to make information necessary for userspace to
6  ***   call into the kernel available to libc.  It contains only constants,
7  ***   structures, and macros generated from the original header, and thus,
8  ***   contains no copyrightable information.
9  ***
10  ***   To edit the content of this header, modify the corresponding
11  ***   source file (e.g. under external/kernel-headers/original/) then
12  ***   run bionic/libc/kernel/tools/update_all.py
13  ***
14  ***   Any manual change here will be lost the next time this script will
15  ***   be run. You've been warned!
16  ***
17  ****************************************************************************
18  ****************************************************************************/
19 #ifndef _LINUX_NILFS2_ONDISK_H
20 #define _LINUX_NILFS2_ONDISK_H
21 #include <linux/types.h>
22 #include <linux/magic.h>
23 #include <asm/byteorder.h>
24 #define NILFS_INODE_BMAP_SIZE 7
25 struct nilfs_inode {
26   __le64 i_blocks;
27   __le64 i_size;
28   __le64 i_ctime;
29   __le64 i_mtime;
30   __le32 i_ctime_nsec;
31   __le32 i_mtime_nsec;
32   __le32 i_uid;
33   __le32 i_gid;
34   __le16 i_mode;
35   __le16 i_links_count;
36   __le32 i_flags;
37   __le64 i_bmap[NILFS_INODE_BMAP_SIZE];
38 #define i_device_code i_bmap[0]
39   __le64 i_xattr;
40   __le32 i_generation;
41   __le32 i_pad;
42 };
43 #define NILFS_MIN_INODE_SIZE 128
44 struct nilfs_super_root {
45   __le32 sr_sum;
46   __le16 sr_bytes;
47   __le16 sr_flags;
48   __le64 sr_nongc_ctime;
49   struct nilfs_inode sr_dat;
50   struct nilfs_inode sr_cpfile;
51   struct nilfs_inode sr_sufile;
52 };
53 #define NILFS_SR_MDT_OFFSET(inode_size,i) ((unsigned long) & ((struct nilfs_super_root *) 0)->sr_dat + (inode_size) * (i))
54 #define NILFS_SR_DAT_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 0)
55 #define NILFS_SR_CPFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 1)
56 #define NILFS_SR_SUFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 2)
57 #define NILFS_SR_BYTES(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 3)
58 #define NILFS_DFL_MAX_MNT_COUNT 50
59 #define NILFS_VALID_FS 0x0001
60 #define NILFS_ERROR_FS 0x0002
61 #define NILFS_RESIZE_FS 0x0004
62 #define NILFS_MOUNT_ERROR_MODE 0x0070
63 #define NILFS_MOUNT_ERRORS_CONT 0x0010
64 #define NILFS_MOUNT_ERRORS_RO 0x0020
65 #define NILFS_MOUNT_ERRORS_PANIC 0x0040
66 #define NILFS_MOUNT_BARRIER 0x1000
67 #define NILFS_MOUNT_STRICT_ORDER 0x2000
68 #define NILFS_MOUNT_NORECOVERY 0x4000
69 #define NILFS_MOUNT_DISCARD 0x8000
70 struct nilfs_super_block {
71   __le32 s_rev_level;
72   __le16 s_minor_rev_level;
73   __le16 s_magic;
74   __le16 s_bytes;
75   __le16 s_flags;
76   __le32 s_crc_seed;
77   __le32 s_sum;
78   __le32 s_log_block_size;
79   __le64 s_nsegments;
80   __le64 s_dev_size;
81   __le64 s_first_data_block;
82   __le32 s_blocks_per_segment;
83   __le32 s_r_segments_percentage;
84   __le64 s_last_cno;
85   __le64 s_last_pseg;
86   __le64 s_last_seq;
87   __le64 s_free_blocks_count;
88   __le64 s_ctime;
89   __le64 s_mtime;
90   __le64 s_wtime;
91   __le16 s_mnt_count;
92   __le16 s_max_mnt_count;
93   __le16 s_state;
94   __le16 s_errors;
95   __le64 s_lastcheck;
96   __le32 s_checkinterval;
97   __le32 s_creator_os;
98   __le16 s_def_resuid;
99   __le16 s_def_resgid;
100   __le32 s_first_ino;
101   __le16 s_inode_size;
102   __le16 s_dat_entry_size;
103   __le16 s_checkpoint_size;
104   __le16 s_segment_usage_size;
105   __u8 s_uuid[16];
106   char s_volume_name[80];
107   __le32 s_c_interval;
108   __le32 s_c_block_max;
109   __le64 s_feature_compat;
110   __le64 s_feature_compat_ro;
111   __le64 s_feature_incompat;
112   __u32 s_reserved[186];
113 };
114 #define NILFS_OS_LINUX 0
115 #define NILFS_CURRENT_REV 2
116 #define NILFS_MINOR_REV 0
117 #define NILFS_MIN_SUPP_REV 2
118 #define NILFS_FEATURE_COMPAT_RO_BLOCK_COUNT 0x00000001ULL
119 #define NILFS_FEATURE_COMPAT_SUPP 0ULL
120 #define NILFS_FEATURE_COMPAT_RO_SUPP NILFS_FEATURE_COMPAT_RO_BLOCK_COUNT
121 #define NILFS_FEATURE_INCOMPAT_SUPP 0ULL
122 #define NILFS_SB_BYTES ((long) & ((struct nilfs_super_block *) 0)->s_reserved)
123 #define NILFS_ROOT_INO 2
124 #define NILFS_DAT_INO 3
125 #define NILFS_CPFILE_INO 4
126 #define NILFS_SUFILE_INO 5
127 #define NILFS_IFILE_INO 6
128 #define NILFS_ATIME_INO 7
129 #define NILFS_XATTR_INO 8
130 #define NILFS_SKETCH_INO 10
131 #define NILFS_USER_INO 11
132 #define NILFS_SB_OFFSET_BYTES 1024
133 #define NILFS_SEG_MIN_BLOCKS 16
134 #define NILFS_PSEG_MIN_BLOCKS 2
135 #define NILFS_MIN_NRSVSEGS 8
136 #define NILFS_ROOT_METADATA_FILE(ino) ((ino) >= NILFS_DAT_INO && (ino) <= NILFS_SUFILE_INO)
137 #define NILFS_SB2_OFFSET_BYTES(devsize) ((((devsize) >> 12) - 1) << 12)
138 #define NILFS_LINK_MAX 32000
139 #define NILFS_NAME_LEN 255
140 #define NILFS_MIN_BLOCK_SIZE 1024
141 #define NILFS_MAX_BLOCK_SIZE 65536
142 struct nilfs_dir_entry {
143   __le64 inode;
144   __le16 rec_len;
145   __u8 name_len;
146   __u8 file_type;
147   char name[NILFS_NAME_LEN];
148   char pad;
149 };
150 enum {
151   NILFS_FT_UNKNOWN,
152   NILFS_FT_REG_FILE,
153   NILFS_FT_DIR,
154   NILFS_FT_CHRDEV,
155   NILFS_FT_BLKDEV,
156   NILFS_FT_FIFO,
157   NILFS_FT_SOCK,
158   NILFS_FT_SYMLINK,
159   NILFS_FT_MAX
160 };
161 #define NILFS_DIR_PAD 8
162 #define NILFS_DIR_ROUND (NILFS_DIR_PAD - 1)
163 #define NILFS_DIR_REC_LEN(name_len) (((name_len) + 12 + NILFS_DIR_ROUND) & ~NILFS_DIR_ROUND)
164 #define NILFS_MAX_REC_LEN ((1 << 16) - 1)
165 struct nilfs_finfo {
166   __le64 fi_ino;
167   __le64 fi_cno;
168   __le32 fi_nblocks;
169   __le32 fi_ndatablk;
170 };
171 struct nilfs_binfo_v {
172   __le64 bi_vblocknr;
173   __le64 bi_blkoff;
174 };
175 struct nilfs_binfo_dat {
176   __le64 bi_blkoff;
177   __u8 bi_level;
178   __u8 bi_pad[7];
179 };
180 union nilfs_binfo {
181   struct nilfs_binfo_v bi_v;
182   struct nilfs_binfo_dat bi_dat;
183 };
184 struct nilfs_segment_summary {
185   __le32 ss_datasum;
186   __le32 ss_sumsum;
187   __le32 ss_magic;
188   __le16 ss_bytes;
189   __le16 ss_flags;
190   __le64 ss_seq;
191   __le64 ss_create;
192   __le64 ss_next;
193   __le32 ss_nblocks;
194   __le32 ss_nfinfo;
195   __le32 ss_sumbytes;
196   __le32 ss_pad;
197   __le64 ss_cno;
198 };
199 #define NILFS_SEGSUM_MAGIC 0x1eaffa11
200 #define NILFS_SS_LOGBGN 0x0001
201 #define NILFS_SS_LOGEND 0x0002
202 #define NILFS_SS_SR 0x0004
203 #define NILFS_SS_SYNDT 0x0008
204 #define NILFS_SS_GC 0x0010
205 struct nilfs_btree_node {
206   __u8 bn_flags;
207   __u8 bn_level;
208   __le16 bn_nchildren;
209   __le32 bn_pad;
210 };
211 #define NILFS_BTREE_NODE_ROOT 0x01
212 #define NILFS_BTREE_LEVEL_DATA 0
213 #define NILFS_BTREE_LEVEL_NODE_MIN (NILFS_BTREE_LEVEL_DATA + 1)
214 #define NILFS_BTREE_LEVEL_MAX 14
215 struct nilfs_direct_node {
216   __u8 dn_flags;
217   __u8 pad[7];
218 };
219 struct nilfs_palloc_group_desc {
220   __le32 pg_nfrees;
221 };
222 struct nilfs_dat_entry {
223   __le64 de_blocknr;
224   __le64 de_start;
225   __le64 de_end;
226   __le64 de_rsv;
227 };
228 #define NILFS_MIN_DAT_ENTRY_SIZE 32
229 struct nilfs_snapshot_list {
230   __le64 ssl_next;
231   __le64 ssl_prev;
232 };
233 struct nilfs_checkpoint {
234   __le32 cp_flags;
235   __le32 cp_checkpoints_count;
236   struct nilfs_snapshot_list cp_snapshot_list;
237   __le64 cp_cno;
238   __le64 cp_create;
239   __le64 cp_nblk_inc;
240   __le64 cp_inodes_count;
241   __le64 cp_blocks_count;
242   struct nilfs_inode cp_ifile_inode;
243 };
244 #define NILFS_MIN_CHECKPOINT_SIZE (64 + NILFS_MIN_INODE_SIZE)
245 enum {
246   NILFS_CHECKPOINT_SNAPSHOT,
247   NILFS_CHECKPOINT_INVALID,
248   NILFS_CHECKPOINT_SKETCH,
249   NILFS_CHECKPOINT_MINOR,
250 };
251 #define NILFS_CHECKPOINT_FNS(flag,name) static inline void nilfs_checkpoint_set_ ##name(struct nilfs_checkpoint * cp) \
252 { cp->cp_flags = __cpu_to_le32(__le32_to_cpu(cp->cp_flags) | (1UL << NILFS_CHECKPOINT_ ##flag)); \
253 } static inline void nilfs_checkpoint_clear_ ##name(struct nilfs_checkpoint * cp) \
254 { cp->cp_flags = __cpu_to_le32(__le32_to_cpu(cp->cp_flags) & ~(1UL << NILFS_CHECKPOINT_ ##flag)); \
255 } static inline int nilfs_checkpoint_ ##name(const struct nilfs_checkpoint * cp) \
256 { return ! ! (__le32_to_cpu(cp->cp_flags) & (1UL << NILFS_CHECKPOINT_ ##flag)); \
257 }
258 struct nilfs_cpfile_header {
259   __le64 ch_ncheckpoints;
260   __le64 ch_nsnapshots;
261   struct nilfs_snapshot_list ch_snapshot_list;
262 };
263 #define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET ((sizeof(struct nilfs_cpfile_header) + sizeof(struct nilfs_checkpoint) - 1) / sizeof(struct nilfs_checkpoint))
264 struct nilfs_segment_usage {
265   __le64 su_lastmod;
266   __le32 su_nblocks;
267   __le32 su_flags;
268 };
269 #define NILFS_MIN_SEGMENT_USAGE_SIZE 16
270 enum {
271   NILFS_SEGMENT_USAGE_ACTIVE,
272   NILFS_SEGMENT_USAGE_DIRTY,
273   NILFS_SEGMENT_USAGE_ERROR,
274 };
275 #define NILFS_SEGMENT_USAGE_FNS(flag,name) static inline void nilfs_segment_usage_set_ ##name(struct nilfs_segment_usage * su) \
276 { su->su_flags = __cpu_to_le32(__le32_to_cpu(su->su_flags) | (1UL << NILFS_SEGMENT_USAGE_ ##flag)); \
277 } static inline void nilfs_segment_usage_clear_ ##name(struct nilfs_segment_usage * su) \
278 { su->su_flags = __cpu_to_le32(__le32_to_cpu(su->su_flags) & ~(1UL << NILFS_SEGMENT_USAGE_ ##flag)); \
279 } static inline int nilfs_segment_usage_ ##name(const struct nilfs_segment_usage * su) \
280 { return ! ! (__le32_to_cpu(su->su_flags) & (1UL << NILFS_SEGMENT_USAGE_ ##flag)); \
281 }
282 struct nilfs_sufile_header {
283   __le64 sh_ncleansegs;
284   __le64 sh_ndirtysegs;
285   __le64 sh_last_alloc;
286 };
287 #define NILFS_SUFILE_FIRST_SEGMENT_USAGE_OFFSET ((sizeof(struct nilfs_sufile_header) + sizeof(struct nilfs_segment_usage) - 1) / sizeof(struct nilfs_segment_usage))
288 #endif
289