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