Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 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> |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 23 | #define NILFS_INODE_BMAP_SIZE 7 |
| 24 | struct nilfs_inode { |
| 25 | __le64 i_blocks; |
| 26 | __le64 i_size; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 27 | __le64 i_ctime; |
| 28 | __le64 i_mtime; |
| 29 | __le32 i_ctime_nsec; |
| 30 | __le32 i_mtime_nsec; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 31 | __le32 i_uid; |
| 32 | __le32 i_gid; |
| 33 | __le16 i_mode; |
| 34 | __le16 i_links_count; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 35 | __le32 i_flags; |
| 36 | __le64 i_bmap[NILFS_INODE_BMAP_SIZE]; |
| 37 | #define i_device_code i_bmap[0] |
| 38 | __le64 i_xattr; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 39 | __le32 i_generation; |
| 40 | __le32 i_pad; |
| 41 | }; |
| 42 | #define NILFS_MIN_INODE_SIZE 128 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 43 | struct nilfs_super_root { |
| 44 | __le32 sr_sum; |
| 45 | __le16 sr_bytes; |
| 46 | __le16 sr_flags; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 47 | __le64 sr_nongc_ctime; |
| 48 | struct nilfs_inode sr_dat; |
| 49 | struct nilfs_inode sr_cpfile; |
| 50 | struct nilfs_inode sr_sufile; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 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) |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 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 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 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 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 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 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 67 | #define NILFS_MOUNT_NORECOVERY 0x4000 |
| 68 | #define NILFS_MOUNT_DISCARD 0x8000 |
| 69 | struct nilfs_super_block { |
| 70 | __le32 s_rev_level; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 71 | __le16 s_minor_rev_level; |
| 72 | __le16 s_magic; |
| 73 | __le16 s_bytes; |
| 74 | __le16 s_flags; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 75 | __le32 s_crc_seed; |
| 76 | __le32 s_sum; |
| 77 | __le32 s_log_block_size; |
| 78 | __le64 s_nsegments; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 79 | __le64 s_dev_size; |
| 80 | __le64 s_first_data_block; |
| 81 | __le32 s_blocks_per_segment; |
| 82 | __le32 s_r_segments_percentage; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 83 | __le64 s_last_cno; |
| 84 | __le64 s_last_pseg; |
| 85 | __le64 s_last_seq; |
| 86 | __le64 s_free_blocks_count; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 87 | __le64 s_ctime; |
| 88 | __le64 s_mtime; |
| 89 | __le64 s_wtime; |
| 90 | __le16 s_mnt_count; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 91 | __le16 s_max_mnt_count; |
| 92 | __le16 s_state; |
| 93 | __le16 s_errors; |
| 94 | __le64 s_lastcheck; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 95 | __le32 s_checkinterval; |
| 96 | __le32 s_creator_os; |
| 97 | __le16 s_def_resuid; |
| 98 | __le16 s_def_resgid; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 99 | __le32 s_first_ino; |
| 100 | __le16 s_inode_size; |
| 101 | __le16 s_dat_entry_size; |
| 102 | __le16 s_checkpoint_size; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 103 | __le16 s_segment_usage_size; |
| 104 | __u8 s_uuid[16]; |
| 105 | char s_volume_name[80]; |
| 106 | __le32 s_c_interval; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 107 | __le32 s_c_block_max; |
| 108 | __le64 s_feature_compat; |
| 109 | __le64 s_feature_compat_ro; |
| 110 | __le64 s_feature_incompat; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 111 | __u32 s_reserved[186]; |
| 112 | }; |
| 113 | #define NILFS_OS_LINUX 0 |
| 114 | #define NILFS_CURRENT_REV 2 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 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 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 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 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 123 | #define NILFS_DAT_INO 3 |
| 124 | #define NILFS_CPFILE_INO 4 |
| 125 | #define NILFS_SUFILE_INO 5 |
| 126 | #define NILFS_IFILE_INO 6 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 127 | #define NILFS_ATIME_INO 7 |
| 128 | #define NILFS_XATTR_INO 8 |
| 129 | #define NILFS_SKETCH_INO 10 |
| 130 | #define NILFS_USER_INO 11 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 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 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 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 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 139 | #define NILFS_MIN_BLOCK_SIZE 1024 |
| 140 | #define NILFS_MAX_BLOCK_SIZE 65536 |
| 141 | struct nilfs_dir_entry { |
| 142 | __le64 inode; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 143 | __le16 rec_len; |
| 144 | __u8 name_len; |
| 145 | __u8 file_type; |
| 146 | char name[NILFS_NAME_LEN]; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 147 | char pad; |
| 148 | }; |
| 149 | enum { |
| 150 | NILFS_FT_UNKNOWN, |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 151 | NILFS_FT_REG_FILE, |
| 152 | NILFS_FT_DIR, |
| 153 | NILFS_FT_CHRDEV, |
| 154 | NILFS_FT_BLKDEV, |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 155 | NILFS_FT_FIFO, |
| 156 | NILFS_FT_SOCK, |
| 157 | NILFS_FT_SYMLINK, |
| 158 | NILFS_FT_MAX |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 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) |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 163 | #define NILFS_MAX_REC_LEN ((1 << 16) - 1) |
| 164 | struct nilfs_finfo { |
| 165 | __le64 fi_ino; |
| 166 | __le64 fi_cno; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 167 | __le32 fi_nblocks; |
| 168 | __le32 fi_ndatablk; |
| 169 | }; |
| 170 | struct nilfs_binfo_v { |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 171 | __le64 bi_vblocknr; |
| 172 | __le64 bi_blkoff; |
| 173 | }; |
| 174 | struct nilfs_binfo_dat { |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 175 | __le64 bi_blkoff; |
| 176 | __u8 bi_level; |
| 177 | __u8 bi_pad[7]; |
| 178 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 179 | union nilfs_binfo { |
| 180 | struct nilfs_binfo_v bi_v; |
| 181 | struct nilfs_binfo_dat bi_dat; |
| 182 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 183 | struct nilfs_segment_summary { |
| 184 | __le32 ss_datasum; |
| 185 | __le32 ss_sumsum; |
| 186 | __le32 ss_magic; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 187 | __le16 ss_bytes; |
| 188 | __le16 ss_flags; |
| 189 | __le64 ss_seq; |
| 190 | __le64 ss_create; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 191 | __le64 ss_next; |
| 192 | __le32 ss_nblocks; |
| 193 | __le32 ss_nfinfo; |
| 194 | __le32 ss_sumbytes; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 195 | __le32 ss_pad; |
| 196 | __le64 ss_cno; |
| 197 | }; |
| 198 | #define NILFS_SEGSUM_MAGIC 0x1eaffa11 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 199 | #define NILFS_SS_LOGBGN 0x0001 |
| 200 | #define NILFS_SS_LOGEND 0x0002 |
| 201 | #define NILFS_SS_SR 0x0004 |
| 202 | #define NILFS_SS_SYNDT 0x0008 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 203 | #define NILFS_SS_GC 0x0010 |
| 204 | struct nilfs_btree_node { |
| 205 | __u8 bn_flags; |
| 206 | __u8 bn_level; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 207 | __le16 bn_nchildren; |
| 208 | __le32 bn_pad; |
| 209 | }; |
| 210 | #define NILFS_BTREE_NODE_ROOT 0x01 |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 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 |
| 214 | struct nilfs_direct_node { |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 215 | __u8 dn_flags; |
| 216 | __u8 pad[7]; |
| 217 | }; |
| 218 | struct nilfs_palloc_group_desc { |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 219 | __le32 pg_nfrees; |
| 220 | }; |
| 221 | struct nilfs_dat_entry { |
| 222 | __le64 de_blocknr; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 223 | __le64 de_start; |
| 224 | __le64 de_end; |
| 225 | __le64 de_rsv; |
| 226 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 227 | #define NILFS_MIN_DAT_ENTRY_SIZE 32 |
| 228 | struct nilfs_snapshot_list { |
| 229 | __le64 ssl_next; |
| 230 | __le64 ssl_prev; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 231 | }; |
| 232 | struct nilfs_checkpoint { |
| 233 | __le32 cp_flags; |
| 234 | __le32 cp_checkpoints_count; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 235 | struct nilfs_snapshot_list cp_snapshot_list; |
| 236 | __le64 cp_cno; |
| 237 | __le64 cp_create; |
| 238 | __le64 cp_nblk_inc; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 239 | __le64 cp_inodes_count; |
| 240 | __le64 cp_blocks_count; |
| 241 | struct nilfs_inode cp_ifile_inode; |
| 242 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 243 | #define NILFS_MIN_CHECKPOINT_SIZE (64 + NILFS_MIN_INODE_SIZE) |
| 244 | enum { |
| 245 | NILFS_CHECKPOINT_SNAPSHOT, |
| 246 | NILFS_CHECKPOINT_INVALID, |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 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 | } |
Christopher Ferris | 48fe0ae | 2019-01-10 15:59:33 -0800 | [diff] [blame^] | 257 | struct nilfs_cpfile_header { |
| 258 | __le64 ch_ncheckpoints; |
| 259 | __le64 ch_nsnapshots; |
| 260 | struct nilfs_snapshot_list ch_snapshot_list; |
| 261 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 262 | #define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET ((sizeof(struct nilfs_cpfile_header) + sizeof(struct nilfs_checkpoint) - 1) / sizeof(struct nilfs_checkpoint)) |
| 263 | struct nilfs_segment_usage { |
| 264 | __le64 su_lastmod; |
| 265 | __le32 su_nblocks; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 266 | __le32 su_flags; |
| 267 | }; |
| 268 | #define NILFS_MIN_SEGMENT_USAGE_SIZE 16 |
| 269 | enum { |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 270 | NILFS_SEGMENT_USAGE_ACTIVE, |
| 271 | NILFS_SEGMENT_USAGE_DIRTY, |
| 272 | NILFS_SEGMENT_USAGE_ERROR, |
| 273 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 274 | #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 | } |
| 281 | struct nilfs_sufile_header { |
| 282 | __le64 sh_ncleansegs; |
| 283 | __le64 sh_ndirtysegs; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 284 | __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 |