123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879 |
- #ifndef __XFS_DA_FORMAT_H__
- #define __XFS_DA_FORMAT_H__
- #define XFS_DA_NODE_MAGIC 0xfebe /* magic number: non-leaf blocks */
- #define XFS_ATTR_LEAF_MAGIC 0xfbee /* magic number: attribute leaf blks */
- #define XFS_DIR2_LEAF1_MAGIC 0xd2f1 /* magic number: v2 dirlf single blks */
- #define XFS_DIR2_LEAFN_MAGIC 0xd2ff /* magic number: v2 dirlf multi blks */
- typedef struct xfs_da_blkinfo {
- __be32 forw;
- __be32 back;
- __be16 magic;
- __be16 pad;
- } xfs_da_blkinfo_t;
- #define XFS_DA3_NODE_MAGIC 0x3ebe /* magic number: non-leaf blocks */
- #define XFS_ATTR3_LEAF_MAGIC 0x3bee /* magic number: attribute leaf blks */
- #define XFS_DIR3_LEAF1_MAGIC 0x3df1 /* magic number: v2 dirlf single blks */
- #define XFS_DIR3_LEAFN_MAGIC 0x3dff /* magic number: v2 dirlf multi blks */
- struct xfs_da3_blkinfo {
-
- struct xfs_da_blkinfo hdr;
- __be32 crc;
- __be64 blkno;
- __be64 lsn;
- uuid_t uuid;
- __be64 owner;
- };
- #define XFS_DA_NODE_MAXDEPTH 5 /* max depth of Btree */
- typedef struct xfs_da_node_hdr {
- struct xfs_da_blkinfo info;
- __be16 __count;
- __be16 __level;
- } xfs_da_node_hdr_t;
- struct xfs_da3_node_hdr {
- struct xfs_da3_blkinfo info;
- __be16 __count;
- __be16 __level;
- __be32 __pad32;
- };
- #define XFS_DA3_NODE_CRC_OFF (offsetof(struct xfs_da3_node_hdr, info.crc))
- typedef struct xfs_da_node_entry {
- __be32 hashval;
- __be32 before;
- } xfs_da_node_entry_t;
- typedef struct xfs_da_intnode {
- struct xfs_da_node_hdr hdr;
- struct xfs_da_node_entry __btree[];
- } xfs_da_intnode_t;
- struct xfs_da3_intnode {
- struct xfs_da3_node_hdr hdr;
- struct xfs_da_node_entry __btree[];
- };
- struct xfs_da3_icnode_hdr {
- __uint32_t forw;
- __uint32_t back;
- __uint16_t magic;
- __uint16_t count;
- __uint16_t level;
- };
- #define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: single block dirs */
- #define XFS_DIR2_DATA_MAGIC 0x58443244 /* XD2D: multiblock dirs */
- #define XFS_DIR2_FREE_MAGIC 0x58443246 /* XD2F: free index blocks */
- #define XFS_DIR3_BLOCK_MAGIC 0x58444233 /* XDB3: single block dirs */
- #define XFS_DIR3_DATA_MAGIC 0x58444433 /* XDD3: multiblock dirs */
- #define XFS_DIR3_FREE_MAGIC 0x58444633 /* XDF3: free index blocks */
- #define XFS_DIR3_FT_UNKNOWN 0
- #define XFS_DIR3_FT_REG_FILE 1
- #define XFS_DIR3_FT_DIR 2
- #define XFS_DIR3_FT_CHRDEV 3
- #define XFS_DIR3_FT_BLKDEV 4
- #define XFS_DIR3_FT_FIFO 5
- #define XFS_DIR3_FT_SOCK 6
- #define XFS_DIR3_FT_SYMLINK 7
- #define XFS_DIR3_FT_WHT 8
- #define XFS_DIR3_FT_MAX 9
- typedef __uint16_t xfs_dir2_data_off_t;
- #define NULLDATAOFF 0xffffU
- typedef uint xfs_dir2_data_aoff_t;
- typedef __uint32_t xfs_dir2_dataptr_t;
- #define XFS_DIR2_MAX_DATAPTR ((xfs_dir2_dataptr_t)0xffffffff)
- #define XFS_DIR2_NULL_DATAPTR ((xfs_dir2_dataptr_t)0)
- typedef xfs_off_t xfs_dir2_off_t;
- typedef __uint32_t xfs_dir2_db_t;
- #define XFS_INO32_SIZE 4
- #define XFS_INO64_SIZE 8
- #define XFS_INO64_DIFF (XFS_INO64_SIZE - XFS_INO32_SIZE)
- #define XFS_DIR2_MAX_SHORT_INUM ((xfs_ino_t)0xffffffffULL)
- typedef struct xfs_dir2_sf_hdr {
- __uint8_t count;
- __uint8_t i8count;
- __uint8_t parent[8];
- } __packed xfs_dir2_sf_hdr_t;
- typedef struct xfs_dir2_sf_entry {
- __u8 namelen;
- __u8 offset[2];
- __u8 name[];
-
- } xfs_dir2_sf_entry_t;
- static inline int xfs_dir2_sf_hdr_size(int i8count)
- {
- return sizeof(struct xfs_dir2_sf_hdr) -
- (i8count == 0) * XFS_INO64_DIFF;
- }
- static inline xfs_dir2_data_aoff_t
- xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep)
- {
- return get_unaligned_be16(sfep->offset);
- }
- static inline void
- xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off)
- {
- put_unaligned_be16(off, sfep->offset);
- }
- static inline struct xfs_dir2_sf_entry *
- xfs_dir2_sf_firstentry(struct xfs_dir2_sf_hdr *hdr)
- {
- return (struct xfs_dir2_sf_entry *)
- ((char *)hdr + xfs_dir2_sf_hdr_size(hdr->i8count));
- }
- #define XFS_DIR2_DATA_ALIGN_LOG 3 /* i.e., 8 bytes */
- #define XFS_DIR2_DATA_ALIGN (1 << XFS_DIR2_DATA_ALIGN_LOG)
- #define XFS_DIR2_DATA_FREE_TAG 0xffff
- #define XFS_DIR2_DATA_FD_COUNT 3
- #define XFS_DIR2_SPACE_SIZE (1ULL << (32 + XFS_DIR2_DATA_ALIGN_LOG))
- #define XFS_DIR2_DATA_SPACE 0
- #define XFS_DIR2_DATA_OFFSET (XFS_DIR2_DATA_SPACE * XFS_DIR2_SPACE_SIZE)
- typedef struct xfs_dir2_data_free {
- __be16 offset;
- __be16 length;
- } xfs_dir2_data_free_t;
- typedef struct xfs_dir2_data_hdr {
- __be32 magic;
-
- xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT];
- } xfs_dir2_data_hdr_t;
- struct xfs_dir3_blk_hdr {
- __be32 magic;
- __be32 crc;
- __be64 blkno;
- __be64 lsn;
- uuid_t uuid;
- __be64 owner;
- };
- struct xfs_dir3_data_hdr {
- struct xfs_dir3_blk_hdr hdr;
- xfs_dir2_data_free_t best_free[XFS_DIR2_DATA_FD_COUNT];
- __be32 pad;
- };
- #define XFS_DIR3_DATA_CRC_OFF offsetof(struct xfs_dir3_data_hdr, hdr.crc)
- typedef struct xfs_dir2_data_entry {
- __be64 inumber;
- __u8 namelen;
- __u8 name[];
-
-
- } xfs_dir2_data_entry_t;
- typedef struct xfs_dir2_data_unused {
- __be16 freetag;
- __be16 length;
-
- __be16 tag;
- } xfs_dir2_data_unused_t;
- static inline __be16 *
- xfs_dir2_data_unused_tag_p(struct xfs_dir2_data_unused *dup)
- {
- return (__be16 *)((char *)dup +
- be16_to_cpu(dup->length) - sizeof(__be16));
- }
- #define XFS_DIR2_LEAF_SPACE 1
- #define XFS_DIR2_LEAF_OFFSET (XFS_DIR2_LEAF_SPACE * XFS_DIR2_SPACE_SIZE)
- typedef struct xfs_dir2_leaf_hdr {
- xfs_da_blkinfo_t info;
- __be16 count;
- __be16 stale;
- } xfs_dir2_leaf_hdr_t;
- struct xfs_dir3_leaf_hdr {
- struct xfs_da3_blkinfo info;
- __be16 count;
- __be16 stale;
- __be32 pad;
- };
- struct xfs_dir3_icleaf_hdr {
- __uint32_t forw;
- __uint32_t back;
- __uint16_t magic;
- __uint16_t count;
- __uint16_t stale;
- };
- typedef struct xfs_dir2_leaf_entry {
- __be32 hashval;
- __be32 address;
- } xfs_dir2_leaf_entry_t;
- typedef struct xfs_dir2_leaf_tail {
- __be32 bestcount;
- } xfs_dir2_leaf_tail_t;
- typedef struct xfs_dir2_leaf {
- xfs_dir2_leaf_hdr_t hdr;
- xfs_dir2_leaf_entry_t __ents[];
- } xfs_dir2_leaf_t;
- struct xfs_dir3_leaf {
- struct xfs_dir3_leaf_hdr hdr;
- struct xfs_dir2_leaf_entry __ents[];
- };
- #define XFS_DIR3_LEAF_CRC_OFF offsetof(struct xfs_dir3_leaf_hdr, info.crc)
- static inline __be16 *
- xfs_dir2_leaf_bests_p(struct xfs_dir2_leaf_tail *ltp)
- {
- return (__be16 *)ltp - be32_to_cpu(ltp->bestcount);
- }
- #define XFS_DIR2_FREE_SPACE 2
- #define XFS_DIR2_FREE_OFFSET (XFS_DIR2_FREE_SPACE * XFS_DIR2_SPACE_SIZE)
- typedef struct xfs_dir2_free_hdr {
- __be32 magic;
- __be32 firstdb;
- __be32 nvalid;
- __be32 nused;
- } xfs_dir2_free_hdr_t;
- typedef struct xfs_dir2_free {
- xfs_dir2_free_hdr_t hdr;
- __be16 bests[];
-
- } xfs_dir2_free_t;
- struct xfs_dir3_free_hdr {
- struct xfs_dir3_blk_hdr hdr;
- __be32 firstdb;
- __be32 nvalid;
- __be32 nused;
- __be32 pad;
- };
- struct xfs_dir3_free {
- struct xfs_dir3_free_hdr hdr;
- __be16 bests[];
-
- };
- #define XFS_DIR3_FREE_CRC_OFF offsetof(struct xfs_dir3_free, hdr.hdr.crc)
- struct xfs_dir3_icfree_hdr {
- __uint32_t magic;
- __uint32_t firstdb;
- __uint32_t nvalid;
- __uint32_t nused;
- };
- typedef struct xfs_dir2_block_tail {
- __be32 count;
- __be32 stale;
- } xfs_dir2_block_tail_t;
- static inline struct xfs_dir2_leaf_entry *
- xfs_dir2_block_leaf_p(struct xfs_dir2_block_tail *btp)
- {
- return ((struct xfs_dir2_leaf_entry *)btp) - be32_to_cpu(btp->count);
- }
- #define XFS_ATTR_LEAF_MAPSIZE 3 /* how many freespace slots */
- typedef struct xfs_attr_shortform {
- struct xfs_attr_sf_hdr {
- __be16 totsize;
- __u8 count;
- __u8 padding;
- } hdr;
- struct xfs_attr_sf_entry {
- __uint8_t namelen;
- __uint8_t valuelen;
- __uint8_t flags;
- __uint8_t nameval[1];
- } list[1];
- } xfs_attr_shortform_t;
- typedef struct xfs_attr_leaf_map {
- __be16 base;
- __be16 size;
- } xfs_attr_leaf_map_t;
- typedef struct xfs_attr_leaf_hdr {
- xfs_da_blkinfo_t info;
- __be16 count;
- __be16 usedbytes;
- __be16 firstused;
- __u8 holes;
- __u8 pad1;
- xfs_attr_leaf_map_t freemap[XFS_ATTR_LEAF_MAPSIZE];
-
- } xfs_attr_leaf_hdr_t;
- typedef struct xfs_attr_leaf_entry {
- __be32 hashval;
- __be16 nameidx;
- __u8 flags;
- __u8 pad2;
- } xfs_attr_leaf_entry_t;
- typedef struct xfs_attr_leaf_name_local {
- __be16 valuelen;
- __u8 namelen;
- __u8 nameval[1];
- } xfs_attr_leaf_name_local_t;
- typedef struct xfs_attr_leaf_name_remote {
- __be32 valueblk;
- __be32 valuelen;
- __u8 namelen;
- __u8 name[1];
- } xfs_attr_leaf_name_remote_t;
- typedef struct xfs_attr_leafblock {
- xfs_attr_leaf_hdr_t hdr;
- xfs_attr_leaf_entry_t entries[1];
-
- } xfs_attr_leafblock_t;
- struct xfs_attr3_leaf_hdr {
- struct xfs_da3_blkinfo info;
- __be16 count;
- __be16 usedbytes;
- __be16 firstused;
- __u8 holes;
- __u8 pad1;
- struct xfs_attr_leaf_map freemap[XFS_ATTR_LEAF_MAPSIZE];
- __be32 pad2;
- };
- #define XFS_ATTR3_LEAF_CRC_OFF (offsetof(struct xfs_attr3_leaf_hdr, info.crc))
- struct xfs_attr3_leafblock {
- struct xfs_attr3_leaf_hdr hdr;
- struct xfs_attr_leaf_entry entries[1];
-
- };
- struct xfs_attr3_icleaf_hdr {
- __uint32_t forw;
- __uint32_t back;
- __uint16_t magic;
- __uint16_t count;
- __uint16_t usedbytes;
-
- __uint32_t firstused;
- __u8 holes;
- struct {
- __uint16_t base;
- __uint16_t size;
- } freemap[XFS_ATTR_LEAF_MAPSIZE];
- };
- #define XFS_ATTR3_LEAF_NULLOFF 0
- #define XFS_ATTR_LOCAL_BIT 0 /* attr is stored locally */
- #define XFS_ATTR_ROOT_BIT 1 /* limit access to trusted attrs */
- #define XFS_ATTR_SECURE_BIT 2 /* limit access to secure attrs */
- #define XFS_ATTR_INCOMPLETE_BIT 7 /* attr in middle of create/delete */
- #define XFS_ATTR_LOCAL (1 << XFS_ATTR_LOCAL_BIT)
- #define XFS_ATTR_ROOT (1 << XFS_ATTR_ROOT_BIT)
- #define XFS_ATTR_SECURE (1 << XFS_ATTR_SECURE_BIT)
- #define XFS_ATTR_INCOMPLETE (1 << XFS_ATTR_INCOMPLETE_BIT)
- #define XFS_ATTR_NSP_ARGS_MASK (ATTR_ROOT | ATTR_SECURE)
- #define XFS_ATTR_NSP_ONDISK_MASK (XFS_ATTR_ROOT | XFS_ATTR_SECURE)
- #define XFS_ATTR_NSP_ONDISK(flags) ((flags) & XFS_ATTR_NSP_ONDISK_MASK)
- #define XFS_ATTR_NSP_ARGS(flags) ((flags) & XFS_ATTR_NSP_ARGS_MASK)
- #define XFS_ATTR_NSP_ARGS_TO_ONDISK(x) (((x) & ATTR_ROOT ? XFS_ATTR_ROOT : 0) |\
- ((x) & ATTR_SECURE ? XFS_ATTR_SECURE : 0))
- #define XFS_ATTR_NSP_ONDISK_TO_ARGS(x) (((x) & XFS_ATTR_ROOT ? ATTR_ROOT : 0) |\
- ((x) & XFS_ATTR_SECURE ? ATTR_SECURE : 0))
- #define XFS_ATTR_LEAF_NAME_ALIGN ((uint)sizeof(xfs_dablk_t))
- static inline int
- xfs_attr3_leaf_hdr_size(struct xfs_attr_leafblock *leafp)
- {
- if (leafp->hdr.info.magic == cpu_to_be16(XFS_ATTR3_LEAF_MAGIC))
- return sizeof(struct xfs_attr3_leaf_hdr);
- return sizeof(struct xfs_attr_leaf_hdr);
- }
- static inline struct xfs_attr_leaf_entry *
- xfs_attr3_leaf_entryp(xfs_attr_leafblock_t *leafp)
- {
- if (leafp->hdr.info.magic == cpu_to_be16(XFS_ATTR3_LEAF_MAGIC))
- return &((struct xfs_attr3_leafblock *)leafp)->entries[0];
- return &leafp->entries[0];
- }
- static inline char *
- xfs_attr3_leaf_name(xfs_attr_leafblock_t *leafp, int idx)
- {
- struct xfs_attr_leaf_entry *entries = xfs_attr3_leaf_entryp(leafp);
- return &((char *)leafp)[be16_to_cpu(entries[idx].nameidx)];
- }
- static inline xfs_attr_leaf_name_remote_t *
- xfs_attr3_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
- {
- return (xfs_attr_leaf_name_remote_t *)xfs_attr3_leaf_name(leafp, idx);
- }
- static inline xfs_attr_leaf_name_local_t *
- xfs_attr3_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
- {
- return (xfs_attr_leaf_name_local_t *)xfs_attr3_leaf_name(leafp, idx);
- }
- static inline int xfs_attr_leaf_entsize_remote(int nlen)
- {
- return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \
- XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
- }
- static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen)
- {
- return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) +
- XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
- }
- static inline int xfs_attr_leaf_entsize_local_max(int bsize)
- {
- return (((bsize) >> 1) + ((bsize) >> 2));
- }
- #define XFS_ATTR3_RMT_MAGIC 0x5841524d /* XARM */
- struct xfs_attr3_rmt_hdr {
- __be32 rm_magic;
- __be32 rm_offset;
- __be32 rm_bytes;
- __be32 rm_crc;
- uuid_t rm_uuid;
- __be64 rm_owner;
- __be64 rm_blkno;
- __be64 rm_lsn;
- };
- #define XFS_ATTR3_RMT_CRC_OFF offsetof(struct xfs_attr3_rmt_hdr, rm_crc)
- #define XFS_ATTR3_RMT_BUF_SPACE(mp, bufsize) \
- ((bufsize) - (xfs_sb_version_hascrc(&(mp)->m_sb) ? \
- sizeof(struct xfs_attr3_rmt_hdr) : 0))
- #endif /* __XFS_DA_FORMAT_H__ */
|