18 #ifndef __XFS_DIR2_FORMAT_H__
19 #define __XFS_DIR2_FORMAT_H__
34 #define XFS_DIR2_BLOCK_MAGIC 0x58443242
35 #define XFS_DIR2_DATA_MAGIC 0x58443244
36 #define XFS_DIR2_FREE_MAGIC 0x58443246
42 #define NULLDATAOFF 0xffffU
55 #define XFS_DIR2_MAX_DATAPTR ((xfs_dir2_dataptr_t)0xffffffff)
56 #define XFS_DIR2_NULL_DATAPTR ((xfs_dir2_dataptr_t)0)
84 #define XFS_DIR2_MAX_SHORT_INUM ((xfs_ino_t)0xffffffffULL)
113 static inline int xfs_dir2_sf_hdr_size(
int i8count)
121 xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep)
123 return get_unaligned_be16(&sfep->
offset.i);
129 put_unaligned_be16(off, &sfep->
offset.i);
143 xfs_dir2_sf_firstentry(struct xfs_dir2_sf_hdr *hdr)
146 ((
char *)hdr + xfs_dir2_sf_hdr_size(hdr->
i8count));
154 ((
char *)sfep + xfs_dir2_sf_entsize(hdr, sfep->
namelen));
182 #define XFS_DIR2_DATA_ALIGN_LOG 3
183 #define XFS_DIR2_DATA_ALIGN (1 << XFS_DIR2_DATA_ALIGN_LOG)
184 #define XFS_DIR2_DATA_FREE_TAG 0xffff
185 #define XFS_DIR2_DATA_FD_COUNT 3
191 #define XFS_DIR2_SPACE_SIZE (1ULL << (32 + XFS_DIR2_DATA_ALIGN_LOG))
192 #define XFS_DIR2_DATA_SPACE 0
193 #define XFS_DIR2_DATA_OFFSET (XFS_DIR2_DATA_SPACE * XFS_DIR2_SPACE_SIZE)
194 #define XFS_DIR2_DATA_FIRSTDB(mp) \
195 xfs_dir2_byte_to_db(mp, XFS_DIR2_DATA_OFFSET)
200 #define XFS_DIR2_DATA_DOT_OFFSET \
201 ((xfs_dir2_data_aoff_t)sizeof(struct xfs_dir2_data_hdr))
202 #define XFS_DIR2_DATA_DOTDOT_OFFSET \
203 (XFS_DIR2_DATA_DOT_OFFSET + xfs_dir2_data_entsize(1))
204 #define XFS_DIR2_DATA_FIRST_OFFSET \
205 (XFS_DIR2_DATA_DOTDOT_OFFSET + xfs_dir2_data_entsize(2))
257 static inline int xfs_dir2_data_entsize(
int n)
269 return (
__be16 *)((
char *)dep +
279 return (
__be16 *)((
char *)dup +
318 #define XFS_DIR2_LEAF_SPACE 1
319 #define XFS_DIR2_LEAF_OFFSET (XFS_DIR2_LEAF_SPACE * XFS_DIR2_SPACE_SIZE)
320 #define XFS_DIR2_LEAF_FIRSTDB(mp) \
321 xfs_dir2_byte_to_db(mp, XFS_DIR2_LEAF_OFFSET)
359 static inline int xfs_dir2_max_leaf_ents(
struct xfs_mount *
mp)
372 ((
char *)lp + mp->m_dirblksize -
410 (by >> (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog));
419 return xfs_dir2_byte_to_db(mp, xfs_dir2_dataptr_to_byte(mp, dp));
429 ((1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) - 1));
438 return xfs_dir2_byte_to_off(mp, xfs_dir2_dataptr_to_byte(mp, dp));
445 xfs_dir2_db_off_to_byte(
struct xfs_mount *mp,
xfs_dir2_db_t db,
449 (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) + o;
467 return xfs_dir2_db_to_da(mp, xfs_dir2_byte_to_db(mp, by));
474 xfs_dir2_db_off_to_dataptr(
struct xfs_mount *mp,
xfs_dir2_db_t db,
477 return xfs_dir2_byte_to_dataptr(mp, xfs_dir2_db_off_to_byte(mp, db, o));
493 xfs_dir2_da_to_byte(
struct xfs_mount *mp,
xfs_dablk_t da)
495 return xfs_dir2_db_off_to_byte(mp, xfs_dir2_da_to_db(mp, da), 0);
505 #define XFS_DIR2_FREE_SPACE 2
506 #define XFS_DIR2_FREE_OFFSET (XFS_DIR2_FREE_SPACE * XFS_DIR2_SPACE_SIZE)
507 #define XFS_DIR2_FREE_FIRSTDB(mp) \
508 xfs_dir2_byte_to_db(mp, XFS_DIR2_FREE_OFFSET)
523 static inline int xfs_dir2_free_max_bests(
struct xfs_mount *mp)
542 xfs_dir2_db_to_fdindex(
struct xfs_mount *mp,
xfs_dir2_db_t db)
544 return db % xfs_dir2_free_max_bests(mp);
585 ((
char *)hdr + mp->m_dirblksize)) - 1;