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