blob: e9995a11aa3b64e25a0608775063ec38a98fe78f [file] [log] [blame]
Christopher Ferris49f525c2016-12-12 14:55:36 -08001/****************************************************************************
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>
Christopher Ferris49f525c2016-12-12 14:55:36 -080023#define NILFS_INODE_BMAP_SIZE 7
24struct nilfs_inode {
25 __le64 i_blocks;
26 __le64 i_size;
Christopher Ferris49f525c2016-12-12 14:55:36 -080027 __le64 i_ctime;
28 __le64 i_mtime;
29 __le32 i_ctime_nsec;
30 __le32 i_mtime_nsec;
Christopher Ferris49f525c2016-12-12 14:55:36 -080031 __le32 i_uid;
32 __le32 i_gid;
33 __le16 i_mode;
34 __le16 i_links_count;
Christopher Ferris49f525c2016-12-12 14:55:36 -080035 __le32 i_flags;
36 __le64 i_bmap[NILFS_INODE_BMAP_SIZE];
37#define i_device_code i_bmap[0]
38 __le64 i_xattr;
Christopher Ferris49f525c2016-12-12 14:55:36 -080039 __le32 i_generation;
40 __le32 i_pad;
41};
42#define NILFS_MIN_INODE_SIZE 128
Christopher Ferris49f525c2016-12-12 14:55:36 -080043struct nilfs_super_root {
44 __le32 sr_sum;
45 __le16 sr_bytes;
46 __le16 sr_flags;
Christopher Ferris49f525c2016-12-12 14:55:36 -080047 __le64 sr_nongc_ctime;
48 struct nilfs_inode sr_dat;
49 struct nilfs_inode sr_cpfile;
50 struct nilfs_inode sr_sufile;
Christopher Ferris49f525c2016-12-12 14:55:36 -080051};
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)
Christopher Ferris49f525c2016-12-12 14:55:36 -080055#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
Christopher Ferris49f525c2016-12-12 14:55:36 -080059#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
Christopher Ferris49f525c2016-12-12 14:55:36 -080063#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
Christopher Ferris49f525c2016-12-12 14:55:36 -080067#define NILFS_MOUNT_NORECOVERY 0x4000
68#define NILFS_MOUNT_DISCARD 0x8000
69struct nilfs_super_block {
70 __le32 s_rev_level;
Christopher Ferris49f525c2016-12-12 14:55:36 -080071 __le16 s_minor_rev_level;
72 __le16 s_magic;
73 __le16 s_bytes;
74 __le16 s_flags;
Christopher Ferris49f525c2016-12-12 14:55:36 -080075 __le32 s_crc_seed;
76 __le32 s_sum;
77 __le32 s_log_block_size;
78 __le64 s_nsegments;
Christopher Ferris49f525c2016-12-12 14:55:36 -080079 __le64 s_dev_size;
80 __le64 s_first_data_block;
81 __le32 s_blocks_per_segment;
82 __le32 s_r_segments_percentage;
Christopher Ferris49f525c2016-12-12 14:55:36 -080083 __le64 s_last_cno;
84 __le64 s_last_pseg;
85 __le64 s_last_seq;
86 __le64 s_free_blocks_count;
Christopher Ferris49f525c2016-12-12 14:55:36 -080087 __le64 s_ctime;
88 __le64 s_mtime;
89 __le64 s_wtime;
90 __le16 s_mnt_count;
Christopher Ferris49f525c2016-12-12 14:55:36 -080091 __le16 s_max_mnt_count;
92 __le16 s_state;
93 __le16 s_errors;
94 __le64 s_lastcheck;
Christopher Ferris49f525c2016-12-12 14:55:36 -080095 __le32 s_checkinterval;
96 __le32 s_creator_os;
97 __le16 s_def_resuid;
98 __le16 s_def_resgid;
Christopher Ferris49f525c2016-12-12 14:55:36 -080099 __le32 s_first_ino;
100 __le16 s_inode_size;
101 __le16 s_dat_entry_size;
102 __le16 s_checkpoint_size;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800103 __le16 s_segment_usage_size;
104 __u8 s_uuid[16];
105 char s_volume_name[80];
106 __le32 s_c_interval;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800107 __le32 s_c_block_max;
108 __le64 s_feature_compat;
109 __le64 s_feature_compat_ro;
110 __le64 s_feature_incompat;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800111 __u32 s_reserved[186];
112};
113#define NILFS_OS_LINUX 0
114#define NILFS_CURRENT_REV 2
Christopher Ferris49f525c2016-12-12 14:55:36 -0800115#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
Christopher Ferris49f525c2016-12-12 14:55:36 -0800119#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
Christopher Ferris49f525c2016-12-12 14:55:36 -0800123#define NILFS_DAT_INO 3
124#define NILFS_CPFILE_INO 4
125#define NILFS_SUFILE_INO 5
126#define NILFS_IFILE_INO 6
Christopher Ferris49f525c2016-12-12 14:55:36 -0800127#define NILFS_ATIME_INO 7
128#define NILFS_XATTR_INO 8
129#define NILFS_SKETCH_INO 10
130#define NILFS_USER_INO 11
Christopher Ferris49f525c2016-12-12 14:55:36 -0800131#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
Christopher Ferris49f525c2016-12-12 14:55:36 -0800135#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
Christopher Ferris49f525c2016-12-12 14:55:36 -0800139#define NILFS_MIN_BLOCK_SIZE 1024
140#define NILFS_MAX_BLOCK_SIZE 65536
141struct nilfs_dir_entry {
142 __le64 inode;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800143 __le16 rec_len;
144 __u8 name_len;
145 __u8 file_type;
146 char name[NILFS_NAME_LEN];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800147 char pad;
148};
149enum {
150 NILFS_FT_UNKNOWN,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800151 NILFS_FT_REG_FILE,
152 NILFS_FT_DIR,
153 NILFS_FT_CHRDEV,
154 NILFS_FT_BLKDEV,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800155 NILFS_FT_FIFO,
156 NILFS_FT_SOCK,
157 NILFS_FT_SYMLINK,
158 NILFS_FT_MAX
Christopher Ferris49f525c2016-12-12 14:55:36 -0800159};
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)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800163#define NILFS_MAX_REC_LEN ((1 << 16) - 1)
164struct nilfs_finfo {
165 __le64 fi_ino;
166 __le64 fi_cno;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800167 __le32 fi_nblocks;
168 __le32 fi_ndatablk;
169};
170struct nilfs_binfo_v {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800171 __le64 bi_vblocknr;
172 __le64 bi_blkoff;
173};
174struct nilfs_binfo_dat {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800175 __le64 bi_blkoff;
176 __u8 bi_level;
177 __u8 bi_pad[7];
178};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800179union nilfs_binfo {
180 struct nilfs_binfo_v bi_v;
181 struct nilfs_binfo_dat bi_dat;
182};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800183struct nilfs_segment_summary {
184 __le32 ss_datasum;
185 __le32 ss_sumsum;
186 __le32 ss_magic;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800187 __le16 ss_bytes;
188 __le16 ss_flags;
189 __le64 ss_seq;
190 __le64 ss_create;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800191 __le64 ss_next;
192 __le32 ss_nblocks;
193 __le32 ss_nfinfo;
194 __le32 ss_sumbytes;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800195 __le32 ss_pad;
196 __le64 ss_cno;
197};
198#define NILFS_SEGSUM_MAGIC 0x1eaffa11
Christopher Ferris49f525c2016-12-12 14:55:36 -0800199#define NILFS_SS_LOGBGN 0x0001
200#define NILFS_SS_LOGEND 0x0002
201#define NILFS_SS_SR 0x0004
202#define NILFS_SS_SYNDT 0x0008
Christopher Ferris49f525c2016-12-12 14:55:36 -0800203#define NILFS_SS_GC 0x0010
204struct nilfs_btree_node {
205 __u8 bn_flags;
206 __u8 bn_level;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800207 __le16 bn_nchildren;
208 __le32 bn_pad;
209};
210#define NILFS_BTREE_NODE_ROOT 0x01
Christopher Ferris49f525c2016-12-12 14:55:36 -0800211#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 {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800215 __u8 dn_flags;
216 __u8 pad[7];
217};
218struct nilfs_palloc_group_desc {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800219 __le32 pg_nfrees;
220};
221struct nilfs_dat_entry {
222 __le64 de_blocknr;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800223 __le64 de_start;
224 __le64 de_end;
225 __le64 de_rsv;
226};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800227#define NILFS_MIN_DAT_ENTRY_SIZE 32
228struct nilfs_snapshot_list {
229 __le64 ssl_next;
230 __le64 ssl_prev;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800231};
232struct nilfs_checkpoint {
233 __le32 cp_flags;
234 __le32 cp_checkpoints_count;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800235 struct nilfs_snapshot_list cp_snapshot_list;
236 __le64 cp_cno;
237 __le64 cp_create;
238 __le64 cp_nblk_inc;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800239 __le64 cp_inodes_count;
240 __le64 cp_blocks_count;
241 struct nilfs_inode cp_ifile_inode;
242};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800243#define NILFS_MIN_CHECKPOINT_SIZE (64 + NILFS_MIN_INODE_SIZE)
244enum {
245 NILFS_CHECKPOINT_SNAPSHOT,
246 NILFS_CHECKPOINT_INVALID,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800247 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}
Christopher Ferris48fe0ae2019-01-10 15:59:33 -0800257struct nilfs_cpfile_header {
258 __le64 ch_ncheckpoints;
259 __le64 ch_nsnapshots;
260 struct nilfs_snapshot_list ch_snapshot_list;
261};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800262#define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET ((sizeof(struct nilfs_cpfile_header) + sizeof(struct nilfs_checkpoint) - 1) / sizeof(struct nilfs_checkpoint))
263struct nilfs_segment_usage {
264 __le64 su_lastmod;
265 __le32 su_nblocks;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800266 __le32 su_flags;
267};
268#define NILFS_MIN_SEGMENT_USAGE_SIZE 16
269enum {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800270 NILFS_SEGMENT_USAGE_ACTIVE,
271 NILFS_SEGMENT_USAGE_DIRTY,
272 NILFS_SEGMENT_USAGE_ERROR,
273};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800274#define NILFS_SEGMENT_USAGE_FNS(flag,name) static inline void nilfs_segment_usage_set_ ##name(struct nilfs_segment_usage * su) \
275{ su->su_flags = cpu_to_le32(le32_to_cpu(su->su_flags) | (1UL << NILFS_SEGMENT_USAGE_ ##flag)); \
276} static inline void nilfs_segment_usage_clear_ ##name(struct nilfs_segment_usage * su) \
277{ su->su_flags = cpu_to_le32(le32_to_cpu(su->su_flags) & ~(1UL << NILFS_SEGMENT_USAGE_ ##flag)); \
278} static inline int nilfs_segment_usage_ ##name(const struct nilfs_segment_usage * su) \
279{ return ! ! (le32_to_cpu(su->su_flags) & (1UL << NILFS_SEGMENT_USAGE_ ##flag)); \
280}
281struct nilfs_sufile_header {
282 __le64 sh_ncleansegs;
283 __le64 sh_ndirtysegs;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800284 __le64 sh_last_alloc;
285};
286#define NILFS_SUFILE_FIRST_SEGMENT_USAGE_OFFSET ((sizeof(struct nilfs_sufile_header) + sizeof(struct nilfs_segment_usage) - 1) / sizeof(struct nilfs_segment_usage))
287#endif