blob: a05e7b732d21eda5c4d288e4381a849ab7e67799 [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 Ferrisfa59a102019-08-05 12:58:49 -070023#include <asm/byteorder.h>
Christopher Ferris49f525c2016-12-12 14:55:36 -080024#define NILFS_INODE_BMAP_SIZE 7
25struct nilfs_inode {
26 __le64 i_blocks;
27 __le64 i_size;
Christopher Ferris49f525c2016-12-12 14:55:36 -080028 __le64 i_ctime;
29 __le64 i_mtime;
30 __le32 i_ctime_nsec;
31 __le32 i_mtime_nsec;
Christopher Ferris49f525c2016-12-12 14:55:36 -080032 __le32 i_uid;
33 __le32 i_gid;
34 __le16 i_mode;
35 __le16 i_links_count;
Christopher Ferris49f525c2016-12-12 14:55:36 -080036 __le32 i_flags;
37 __le64 i_bmap[NILFS_INODE_BMAP_SIZE];
38#define i_device_code i_bmap[0]
39 __le64 i_xattr;
Christopher Ferris49f525c2016-12-12 14:55:36 -080040 __le32 i_generation;
41 __le32 i_pad;
42};
43#define NILFS_MIN_INODE_SIZE 128
Christopher Ferris49f525c2016-12-12 14:55:36 -080044struct nilfs_super_root {
45 __le32 sr_sum;
46 __le16 sr_bytes;
47 __le16 sr_flags;
Christopher Ferris49f525c2016-12-12 14:55:36 -080048 __le64 sr_nongc_ctime;
49 struct nilfs_inode sr_dat;
50 struct nilfs_inode sr_cpfile;
51 struct nilfs_inode sr_sufile;
Christopher Ferris49f525c2016-12-12 14:55:36 -080052};
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)
Christopher Ferris49f525c2016-12-12 14:55:36 -080056#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
Christopher Ferris49f525c2016-12-12 14:55:36 -080060#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
Christopher Ferris49f525c2016-12-12 14:55:36 -080064#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
Christopher Ferris49f525c2016-12-12 14:55:36 -080068#define NILFS_MOUNT_NORECOVERY 0x4000
69#define NILFS_MOUNT_DISCARD 0x8000
70struct nilfs_super_block {
71 __le32 s_rev_level;
Christopher Ferris49f525c2016-12-12 14:55:36 -080072 __le16 s_minor_rev_level;
73 __le16 s_magic;
74 __le16 s_bytes;
75 __le16 s_flags;
Christopher Ferris49f525c2016-12-12 14:55:36 -080076 __le32 s_crc_seed;
77 __le32 s_sum;
78 __le32 s_log_block_size;
79 __le64 s_nsegments;
Christopher Ferris49f525c2016-12-12 14:55:36 -080080 __le64 s_dev_size;
81 __le64 s_first_data_block;
82 __le32 s_blocks_per_segment;
83 __le32 s_r_segments_percentage;
Christopher Ferris49f525c2016-12-12 14:55:36 -080084 __le64 s_last_cno;
85 __le64 s_last_pseg;
86 __le64 s_last_seq;
87 __le64 s_free_blocks_count;
Christopher Ferris49f525c2016-12-12 14:55:36 -080088 __le64 s_ctime;
89 __le64 s_mtime;
90 __le64 s_wtime;
91 __le16 s_mnt_count;
Christopher Ferris49f525c2016-12-12 14:55:36 -080092 __le16 s_max_mnt_count;
93 __le16 s_state;
94 __le16 s_errors;
95 __le64 s_lastcheck;
Christopher Ferris49f525c2016-12-12 14:55:36 -080096 __le32 s_checkinterval;
97 __le32 s_creator_os;
98 __le16 s_def_resuid;
99 __le16 s_def_resgid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800100 __le32 s_first_ino;
101 __le16 s_inode_size;
102 __le16 s_dat_entry_size;
103 __le16 s_checkpoint_size;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800104 __le16 s_segment_usage_size;
105 __u8 s_uuid[16];
106 char s_volume_name[80];
107 __le32 s_c_interval;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800108 __le32 s_c_block_max;
109 __le64 s_feature_compat;
110 __le64 s_feature_compat_ro;
111 __le64 s_feature_incompat;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800112 __u32 s_reserved[186];
113};
114#define NILFS_OS_LINUX 0
115#define NILFS_CURRENT_REV 2
Christopher Ferris49f525c2016-12-12 14:55:36 -0800116#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
Christopher Ferris49f525c2016-12-12 14:55:36 -0800120#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
Christopher Ferris49f525c2016-12-12 14:55:36 -0800124#define NILFS_DAT_INO 3
125#define NILFS_CPFILE_INO 4
126#define NILFS_SUFILE_INO 5
127#define NILFS_IFILE_INO 6
Christopher Ferris49f525c2016-12-12 14:55:36 -0800128#define NILFS_ATIME_INO 7
129#define NILFS_XATTR_INO 8
130#define NILFS_SKETCH_INO 10
131#define NILFS_USER_INO 11
Christopher Ferris49f525c2016-12-12 14:55:36 -0800132#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
Christopher Ferris49f525c2016-12-12 14:55:36 -0800136#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
Christopher Ferris49f525c2016-12-12 14:55:36 -0800140#define NILFS_MIN_BLOCK_SIZE 1024
141#define NILFS_MAX_BLOCK_SIZE 65536
142struct nilfs_dir_entry {
143 __le64 inode;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800144 __le16 rec_len;
145 __u8 name_len;
146 __u8 file_type;
147 char name[NILFS_NAME_LEN];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800148 char pad;
149};
150enum {
151 NILFS_FT_UNKNOWN,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800152 NILFS_FT_REG_FILE,
153 NILFS_FT_DIR,
154 NILFS_FT_CHRDEV,
155 NILFS_FT_BLKDEV,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800156 NILFS_FT_FIFO,
157 NILFS_FT_SOCK,
158 NILFS_FT_SYMLINK,
159 NILFS_FT_MAX
Christopher Ferris49f525c2016-12-12 14:55:36 -0800160};
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)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800164#define NILFS_MAX_REC_LEN ((1 << 16) - 1)
165struct nilfs_finfo {
166 __le64 fi_ino;
167 __le64 fi_cno;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800168 __le32 fi_nblocks;
169 __le32 fi_ndatablk;
170};
171struct nilfs_binfo_v {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800172 __le64 bi_vblocknr;
173 __le64 bi_blkoff;
174};
175struct nilfs_binfo_dat {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800176 __le64 bi_blkoff;
177 __u8 bi_level;
178 __u8 bi_pad[7];
179};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800180union nilfs_binfo {
181 struct nilfs_binfo_v bi_v;
182 struct nilfs_binfo_dat bi_dat;
183};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800184struct nilfs_segment_summary {
185 __le32 ss_datasum;
186 __le32 ss_sumsum;
187 __le32 ss_magic;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800188 __le16 ss_bytes;
189 __le16 ss_flags;
190 __le64 ss_seq;
191 __le64 ss_create;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800192 __le64 ss_next;
193 __le32 ss_nblocks;
194 __le32 ss_nfinfo;
195 __le32 ss_sumbytes;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800196 __le32 ss_pad;
197 __le64 ss_cno;
198};
199#define NILFS_SEGSUM_MAGIC 0x1eaffa11
Christopher Ferris49f525c2016-12-12 14:55:36 -0800200#define NILFS_SS_LOGBGN 0x0001
201#define NILFS_SS_LOGEND 0x0002
202#define NILFS_SS_SR 0x0004
203#define NILFS_SS_SYNDT 0x0008
Christopher Ferris49f525c2016-12-12 14:55:36 -0800204#define NILFS_SS_GC 0x0010
205struct nilfs_btree_node {
206 __u8 bn_flags;
207 __u8 bn_level;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800208 __le16 bn_nchildren;
209 __le32 bn_pad;
210};
211#define NILFS_BTREE_NODE_ROOT 0x01
Christopher Ferris49f525c2016-12-12 14:55:36 -0800212#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
215struct nilfs_direct_node {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800216 __u8 dn_flags;
217 __u8 pad[7];
218};
219struct nilfs_palloc_group_desc {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800220 __le32 pg_nfrees;
221};
222struct nilfs_dat_entry {
223 __le64 de_blocknr;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800224 __le64 de_start;
225 __le64 de_end;
226 __le64 de_rsv;
227};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800228#define NILFS_MIN_DAT_ENTRY_SIZE 32
229struct nilfs_snapshot_list {
230 __le64 ssl_next;
231 __le64 ssl_prev;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800232};
233struct nilfs_checkpoint {
234 __le32 cp_flags;
235 __le32 cp_checkpoints_count;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800236 struct nilfs_snapshot_list cp_snapshot_list;
237 __le64 cp_cno;
238 __le64 cp_create;
239 __le64 cp_nblk_inc;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800240 __le64 cp_inodes_count;
241 __le64 cp_blocks_count;
242 struct nilfs_inode cp_ifile_inode;
243};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800244#define NILFS_MIN_CHECKPOINT_SIZE (64 + NILFS_MIN_INODE_SIZE)
245enum {
246 NILFS_CHECKPOINT_SNAPSHOT,
247 NILFS_CHECKPOINT_INVALID,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800248 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) \
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700252{ cp->cp_flags = __cpu_to_le32(__le32_to_cpu(cp->cp_flags) | (1UL << NILFS_CHECKPOINT_ ##flag)); \
Christopher Ferris49f525c2016-12-12 14:55:36 -0800253} static inline void nilfs_checkpoint_clear_ ##name(struct nilfs_checkpoint * cp) \
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700254{ cp->cp_flags = __cpu_to_le32(__le32_to_cpu(cp->cp_flags) & ~(1UL << NILFS_CHECKPOINT_ ##flag)); \
Christopher Ferris49f525c2016-12-12 14:55:36 -0800255} static inline int nilfs_checkpoint_ ##name(const struct nilfs_checkpoint * cp) \
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700256{ return ! ! (__le32_to_cpu(cp->cp_flags) & (1UL << NILFS_CHECKPOINT_ ##flag)); \
Christopher Ferris49f525c2016-12-12 14:55:36 -0800257}
Christopher Ferris48fe0ae2019-01-10 15:59:33 -0800258struct nilfs_cpfile_header {
259 __le64 ch_ncheckpoints;
260 __le64 ch_nsnapshots;
261 struct nilfs_snapshot_list ch_snapshot_list;
262};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800263#define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET ((sizeof(struct nilfs_cpfile_header) + sizeof(struct nilfs_checkpoint) - 1) / sizeof(struct nilfs_checkpoint))
264struct nilfs_segment_usage {
265 __le64 su_lastmod;
266 __le32 su_nblocks;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800267 __le32 su_flags;
268};
269#define NILFS_MIN_SEGMENT_USAGE_SIZE 16
270enum {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800271 NILFS_SEGMENT_USAGE_ACTIVE,
272 NILFS_SEGMENT_USAGE_DIRTY,
273 NILFS_SEGMENT_USAGE_ERROR,
274};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800275#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 -0700276{ su->su_flags = __cpu_to_le32(__le32_to_cpu(su->su_flags) | (1UL << NILFS_SEGMENT_USAGE_ ##flag)); \
Christopher Ferris49f525c2016-12-12 14:55:36 -0800277} static inline void nilfs_segment_usage_clear_ ##name(struct nilfs_segment_usage * su) \
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700278{ su->su_flags = __cpu_to_le32(__le32_to_cpu(su->su_flags) & ~(1UL << NILFS_SEGMENT_USAGE_ ##flag)); \
Christopher Ferris49f525c2016-12-12 14:55:36 -0800279} static inline int nilfs_segment_usage_ ##name(const struct nilfs_segment_usage * su) \
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700280{ return ! ! (__le32_to_cpu(su->su_flags) & (1UL << NILFS_SEGMENT_USAGE_ ##flag)); \
Christopher Ferris49f525c2016-12-12 14:55:36 -0800281}
282struct nilfs_sufile_header {
283 __le64 sh_ncleansegs;
284 __le64 sh_ndirtysegs;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800285 __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