blob: 9df95cb690cba738ff630f3dfe838348301080c3 [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
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 */
Christopher Ferris49f525c2016-12-12 14:55:36 -08007#ifndef _LINUX_NILFS2_ONDISK_H
8#define _LINUX_NILFS2_ONDISK_H
9#include <linux/types.h>
10#include <linux/magic.h>
Christopher Ferrisfa59a102019-08-05 12:58:49 -070011#include <asm/byteorder.h>
Christopher Ferris49f525c2016-12-12 14:55:36 -080012#define NILFS_INODE_BMAP_SIZE 7
13struct nilfs_inode {
14 __le64 i_blocks;
15 __le64 i_size;
Christopher Ferris49f525c2016-12-12 14:55:36 -080016 __le64 i_ctime;
17 __le64 i_mtime;
18 __le32 i_ctime_nsec;
19 __le32 i_mtime_nsec;
Christopher Ferris49f525c2016-12-12 14:55:36 -080020 __le32 i_uid;
21 __le32 i_gid;
22 __le16 i_mode;
23 __le16 i_links_count;
Christopher Ferris49f525c2016-12-12 14:55:36 -080024 __le32 i_flags;
25 __le64 i_bmap[NILFS_INODE_BMAP_SIZE];
26#define i_device_code i_bmap[0]
27 __le64 i_xattr;
Christopher Ferris49f525c2016-12-12 14:55:36 -080028 __le32 i_generation;
29 __le32 i_pad;
30};
31#define NILFS_MIN_INODE_SIZE 128
Christopher Ferris49f525c2016-12-12 14:55:36 -080032struct nilfs_super_root {
33 __le32 sr_sum;
34 __le16 sr_bytes;
35 __le16 sr_flags;
Christopher Ferris49f525c2016-12-12 14:55:36 -080036 __le64 sr_nongc_ctime;
37 struct nilfs_inode sr_dat;
38 struct nilfs_inode sr_cpfile;
39 struct nilfs_inode sr_sufile;
Christopher Ferris49f525c2016-12-12 14:55:36 -080040};
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)
Christopher Ferris49f525c2016-12-12 14:55:36 -080044#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
Christopher Ferris49f525c2016-12-12 14:55:36 -080048#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
Christopher Ferris49f525c2016-12-12 14:55:36 -080052#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
Christopher Ferris49f525c2016-12-12 14:55:36 -080056#define NILFS_MOUNT_NORECOVERY 0x4000
57#define NILFS_MOUNT_DISCARD 0x8000
58struct nilfs_super_block {
59 __le32 s_rev_level;
Christopher Ferris49f525c2016-12-12 14:55:36 -080060 __le16 s_minor_rev_level;
61 __le16 s_magic;
62 __le16 s_bytes;
63 __le16 s_flags;
Christopher Ferris49f525c2016-12-12 14:55:36 -080064 __le32 s_crc_seed;
65 __le32 s_sum;
66 __le32 s_log_block_size;
67 __le64 s_nsegments;
Christopher Ferris49f525c2016-12-12 14:55:36 -080068 __le64 s_dev_size;
69 __le64 s_first_data_block;
70 __le32 s_blocks_per_segment;
71 __le32 s_r_segments_percentage;
Christopher Ferris49f525c2016-12-12 14:55:36 -080072 __le64 s_last_cno;
73 __le64 s_last_pseg;
74 __le64 s_last_seq;
75 __le64 s_free_blocks_count;
Christopher Ferris49f525c2016-12-12 14:55:36 -080076 __le64 s_ctime;
77 __le64 s_mtime;
78 __le64 s_wtime;
79 __le16 s_mnt_count;
Christopher Ferris49f525c2016-12-12 14:55:36 -080080 __le16 s_max_mnt_count;
81 __le16 s_state;
82 __le16 s_errors;
83 __le64 s_lastcheck;
Christopher Ferris49f525c2016-12-12 14:55:36 -080084 __le32 s_checkinterval;
85 __le32 s_creator_os;
86 __le16 s_def_resuid;
87 __le16 s_def_resgid;
Christopher Ferris49f525c2016-12-12 14:55:36 -080088 __le32 s_first_ino;
89 __le16 s_inode_size;
90 __le16 s_dat_entry_size;
91 __le16 s_checkpoint_size;
Christopher Ferris49f525c2016-12-12 14:55:36 -080092 __le16 s_segment_usage_size;
93 __u8 s_uuid[16];
94 char s_volume_name[80];
95 __le32 s_c_interval;
Christopher Ferris49f525c2016-12-12 14:55:36 -080096 __le32 s_c_block_max;
97 __le64 s_feature_compat;
98 __le64 s_feature_compat_ro;
99 __le64 s_feature_incompat;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800100 __u32 s_reserved[186];
101};
102#define NILFS_OS_LINUX 0
103#define NILFS_CURRENT_REV 2
Christopher Ferris49f525c2016-12-12 14:55:36 -0800104#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
Christopher Ferris49f525c2016-12-12 14:55:36 -0800108#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
Christopher Ferris49f525c2016-12-12 14:55:36 -0800112#define NILFS_DAT_INO 3
113#define NILFS_CPFILE_INO 4
114#define NILFS_SUFILE_INO 5
115#define NILFS_IFILE_INO 6
Christopher Ferris49f525c2016-12-12 14:55:36 -0800116#define NILFS_ATIME_INO 7
117#define NILFS_XATTR_INO 8
118#define NILFS_SKETCH_INO 10
119#define NILFS_USER_INO 11
Christopher Ferris49f525c2016-12-12 14:55:36 -0800120#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
Christopher Ferris49f525c2016-12-12 14:55:36 -0800124#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
Christopher Ferris49f525c2016-12-12 14:55:36 -0800128#define NILFS_MIN_BLOCK_SIZE 1024
129#define NILFS_MAX_BLOCK_SIZE 65536
130struct nilfs_dir_entry {
131 __le64 inode;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800132 __le16 rec_len;
133 __u8 name_len;
134 __u8 file_type;
135 char name[NILFS_NAME_LEN];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800136 char pad;
137};
138enum {
139 NILFS_FT_UNKNOWN,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800140 NILFS_FT_REG_FILE,
141 NILFS_FT_DIR,
142 NILFS_FT_CHRDEV,
143 NILFS_FT_BLKDEV,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800144 NILFS_FT_FIFO,
145 NILFS_FT_SOCK,
146 NILFS_FT_SYMLINK,
147 NILFS_FT_MAX
Christopher Ferris49f525c2016-12-12 14:55:36 -0800148};
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)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800152#define NILFS_MAX_REC_LEN ((1 << 16) - 1)
153struct nilfs_finfo {
154 __le64 fi_ino;
155 __le64 fi_cno;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800156 __le32 fi_nblocks;
157 __le32 fi_ndatablk;
158};
159struct nilfs_binfo_v {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800160 __le64 bi_vblocknr;
161 __le64 bi_blkoff;
162};
163struct nilfs_binfo_dat {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800164 __le64 bi_blkoff;
165 __u8 bi_level;
166 __u8 bi_pad[7];
167};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800168union nilfs_binfo {
169 struct nilfs_binfo_v bi_v;
170 struct nilfs_binfo_dat bi_dat;
171};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800172struct nilfs_segment_summary {
173 __le32 ss_datasum;
174 __le32 ss_sumsum;
175 __le32 ss_magic;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800176 __le16 ss_bytes;
177 __le16 ss_flags;
178 __le64 ss_seq;
179 __le64 ss_create;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800180 __le64 ss_next;
181 __le32 ss_nblocks;
182 __le32 ss_nfinfo;
183 __le32 ss_sumbytes;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800184 __le32 ss_pad;
185 __le64 ss_cno;
186};
187#define NILFS_SEGSUM_MAGIC 0x1eaffa11
Christopher Ferris49f525c2016-12-12 14:55:36 -0800188#define NILFS_SS_LOGBGN 0x0001
189#define NILFS_SS_LOGEND 0x0002
190#define NILFS_SS_SR 0x0004
191#define NILFS_SS_SYNDT 0x0008
Christopher Ferris49f525c2016-12-12 14:55:36 -0800192#define NILFS_SS_GC 0x0010
193struct nilfs_btree_node {
194 __u8 bn_flags;
195 __u8 bn_level;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800196 __le16 bn_nchildren;
197 __le32 bn_pad;
198};
199#define NILFS_BTREE_NODE_ROOT 0x01
Christopher Ferris49f525c2016-12-12 14:55:36 -0800200#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
203struct nilfs_direct_node {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800204 __u8 dn_flags;
205 __u8 pad[7];
206};
207struct nilfs_palloc_group_desc {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800208 __le32 pg_nfrees;
209};
210struct nilfs_dat_entry {
211 __le64 de_blocknr;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800212 __le64 de_start;
213 __le64 de_end;
214 __le64 de_rsv;
215};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800216#define NILFS_MIN_DAT_ENTRY_SIZE 32
217struct nilfs_snapshot_list {
218 __le64 ssl_next;
219 __le64 ssl_prev;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800220};
221struct nilfs_checkpoint {
222 __le32 cp_flags;
223 __le32 cp_checkpoints_count;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800224 struct nilfs_snapshot_list cp_snapshot_list;
225 __le64 cp_cno;
226 __le64 cp_create;
227 __le64 cp_nblk_inc;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800228 __le64 cp_inodes_count;
229 __le64 cp_blocks_count;
230 struct nilfs_inode cp_ifile_inode;
231};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800232#define NILFS_MIN_CHECKPOINT_SIZE (64 + NILFS_MIN_INODE_SIZE)
233enum {
234 NILFS_CHECKPOINT_SNAPSHOT,
235 NILFS_CHECKPOINT_INVALID,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800236 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) \
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700240{ cp->cp_flags = __cpu_to_le32(__le32_to_cpu(cp->cp_flags) | (1UL << NILFS_CHECKPOINT_ ##flag)); \
Christopher Ferris49f525c2016-12-12 14:55:36 -0800241} static inline void nilfs_checkpoint_clear_ ##name(struct nilfs_checkpoint * cp) \
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700242{ cp->cp_flags = __cpu_to_le32(__le32_to_cpu(cp->cp_flags) & ~(1UL << NILFS_CHECKPOINT_ ##flag)); \
Christopher Ferris49f525c2016-12-12 14:55:36 -0800243} static inline int nilfs_checkpoint_ ##name(const struct nilfs_checkpoint * cp) \
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700244{ return ! ! (__le32_to_cpu(cp->cp_flags) & (1UL << NILFS_CHECKPOINT_ ##flag)); \
Christopher Ferris49f525c2016-12-12 14:55:36 -0800245}
Christopher Ferris48fe0ae2019-01-10 15:59:33 -0800246struct nilfs_cpfile_header {
247 __le64 ch_ncheckpoints;
248 __le64 ch_nsnapshots;
249 struct nilfs_snapshot_list ch_snapshot_list;
250};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800251#define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET ((sizeof(struct nilfs_cpfile_header) + sizeof(struct nilfs_checkpoint) - 1) / sizeof(struct nilfs_checkpoint))
252struct nilfs_segment_usage {
253 __le64 su_lastmod;
254 __le32 su_nblocks;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800255 __le32 su_flags;
256};
257#define NILFS_MIN_SEGMENT_USAGE_SIZE 16
258enum {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800259 NILFS_SEGMENT_USAGE_ACTIVE,
260 NILFS_SEGMENT_USAGE_DIRTY,
261 NILFS_SEGMENT_USAGE_ERROR,
262};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800263#define NILFS_SEGMENT_USAGE_FNS(flag,name) static inline void nilfs_segment_usage_set_ ##name(struct nilfs_segment_usage * su) \
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700264{ su->su_flags = __cpu_to_le32(__le32_to_cpu(su->su_flags) | (1UL << NILFS_SEGMENT_USAGE_ ##flag)); \
Christopher Ferris49f525c2016-12-12 14:55:36 -0800265} static inline void nilfs_segment_usage_clear_ ##name(struct nilfs_segment_usage * su) \
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700266{ su->su_flags = __cpu_to_le32(__le32_to_cpu(su->su_flags) & ~(1UL << NILFS_SEGMENT_USAGE_ ##flag)); \
Christopher Ferris49f525c2016-12-12 14:55:36 -0800267} static inline int nilfs_segment_usage_ ##name(const struct nilfs_segment_usage * su) \
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700268{ return ! ! (__le32_to_cpu(su->su_flags) & (1UL << NILFS_SEGMENT_USAGE_ ##flag)); \
Christopher Ferris49f525c2016-12-12 14:55:36 -0800269}
270struct nilfs_sufile_header {
271 __le64 sh_ncleansegs;
272 __le64 sh_ndirtysegs;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800273 __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