Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
0004  * All Rights Reserved.
0005  */
0006 #ifndef __XFS_TYPES_H__
0007 #define __XFS_TYPES_H__
0008 
0009 typedef uint32_t    prid_t;     /* project ID */
0010 
0011 typedef uint32_t    xfs_agblock_t;  /* blockno in alloc. group */
0012 typedef uint32_t    xfs_agino_t;    /* inode # within allocation grp */
0013 typedef uint32_t    xfs_extlen_t;   /* extent length in blocks */
0014 typedef uint32_t    xfs_agnumber_t; /* allocation group number */
0015 typedef uint64_t    xfs_extnum_t;   /* # of extents in a file */
0016 typedef uint32_t    xfs_aextnum_t;  /* # extents in an attribute fork */
0017 typedef int64_t     xfs_fsize_t;    /* bytes in a file */
0018 typedef uint64_t    xfs_ufsize_t;   /* unsigned bytes in a file */
0019 
0020 typedef int32_t     xfs_suminfo_t;  /* type of bitmap summary info */
0021 typedef uint32_t    xfs_rtword_t;   /* word type for bitmap manipulations */
0022 
0023 typedef int64_t     xfs_lsn_t;  /* log sequence number */
0024 typedef int64_t     xfs_csn_t;  /* CIL sequence number */
0025 
0026 typedef uint32_t    xfs_dablk_t;    /* dir/attr block number (in file) */
0027 typedef uint32_t    xfs_dahash_t;   /* dir/attr hash value */
0028 
0029 typedef uint64_t    xfs_fsblock_t;  /* blockno in filesystem (agno|agbno) */
0030 typedef uint64_t    xfs_rfsblock_t; /* blockno in filesystem (raw) */
0031 typedef uint64_t    xfs_rtblock_t;  /* extent (block) in realtime area */
0032 typedef uint64_t    xfs_fileoff_t;  /* block number in a file */
0033 typedef uint64_t    xfs_filblks_t;  /* number of blocks in a file */
0034 
0035 typedef int64_t     xfs_srtblock_t; /* signed version of xfs_rtblock_t */
0036 
0037 /*
0038  * New verifiers will return the instruction address of the failing check.
0039  * NULL means everything is ok.
0040  */
0041 typedef void *      xfs_failaddr_t;
0042 
0043 /*
0044  * Null values for the types.
0045  */
0046 #define NULLFSBLOCK ((xfs_fsblock_t)-1)
0047 #define NULLRFSBLOCK    ((xfs_rfsblock_t)-1)
0048 #define NULLRTBLOCK ((xfs_rtblock_t)-1)
0049 #define NULLFILEOFF ((xfs_fileoff_t)-1)
0050 
0051 #define NULLAGBLOCK ((xfs_agblock_t)-1)
0052 #define NULLAGNUMBER    ((xfs_agnumber_t)-1)
0053 
0054 #define NULLCOMMITLSN   ((xfs_lsn_t)-1)
0055 
0056 #define NULLFSINO   ((xfs_ino_t)-1)
0057 #define NULLAGINO   ((xfs_agino_t)-1)
0058 
0059 /*
0060  * Minimum and maximum blocksize and sectorsize.
0061  * The blocksize upper limit is pretty much arbitrary.
0062  * The sectorsize upper limit is due to sizeof(sb_sectsize).
0063  * CRC enable filesystems use 512 byte inodes, meaning 512 byte block sizes
0064  * cannot be used.
0065  */
0066 #define XFS_MIN_BLOCKSIZE_LOG   9   /* i.e. 512 bytes */
0067 #define XFS_MAX_BLOCKSIZE_LOG   16  /* i.e. 65536 bytes */
0068 #define XFS_MIN_BLOCKSIZE   (1 << XFS_MIN_BLOCKSIZE_LOG)
0069 #define XFS_MAX_BLOCKSIZE   (1 << XFS_MAX_BLOCKSIZE_LOG)
0070 #define XFS_MIN_CRC_BLOCKSIZE   (1 << (XFS_MIN_BLOCKSIZE_LOG + 1))
0071 #define XFS_MIN_SECTORSIZE_LOG  9   /* i.e. 512 bytes */
0072 #define XFS_MAX_SECTORSIZE_LOG  15  /* i.e. 32768 bytes */
0073 #define XFS_MIN_SECTORSIZE  (1 << XFS_MIN_SECTORSIZE_LOG)
0074 #define XFS_MAX_SECTORSIZE  (1 << XFS_MAX_SECTORSIZE_LOG)
0075 
0076 /*
0077  * Inode fork identifiers.
0078  */
0079 #define XFS_DATA_FORK   0
0080 #define XFS_ATTR_FORK   1
0081 #define XFS_COW_FORK    2
0082 
0083 #define XFS_WHICHFORK_STRINGS \
0084     { XFS_DATA_FORK,    "data" }, \
0085     { XFS_ATTR_FORK,    "attr" }, \
0086     { XFS_COW_FORK,     "cow" }
0087 
0088 /*
0089  * Min numbers of data/attr fork btree root pointers.
0090  */
0091 #define MINDBTPTRS  3
0092 #define MINABTPTRS  2
0093 
0094 /*
0095  * MAXNAMELEN is the length (including the terminating null) of
0096  * the longest permissible file (component) name.
0097  */
0098 #define MAXNAMELEN  256
0099 
0100 /*
0101  * This enum is used in string mapping in xfs_trace.h; please keep the
0102  * TRACE_DEFINE_ENUMs for it up to date.
0103  */
0104 typedef enum {
0105     XFS_LOOKUP_EQi, XFS_LOOKUP_LEi, XFS_LOOKUP_GEi
0106 } xfs_lookup_t;
0107 
0108 #define XFS_AG_BTREE_CMP_FORMAT_STR \
0109     { XFS_LOOKUP_EQi,   "eq" }, \
0110     { XFS_LOOKUP_LEi,   "le" }, \
0111     { XFS_LOOKUP_GEi,   "ge" }
0112 
0113 /*
0114  * This enum is used in string mapping in xfs_trace.h and scrub/trace.h;
0115  * please keep the TRACE_DEFINE_ENUMs for it up to date.
0116  */
0117 typedef enum {
0118     XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_RMAPi, XFS_BTNUM_BMAPi,
0119     XFS_BTNUM_INOi, XFS_BTNUM_FINOi, XFS_BTNUM_REFCi, XFS_BTNUM_MAX
0120 } xfs_btnum_t;
0121 
0122 #define XFS_BTNUM_STRINGS \
0123     { XFS_BTNUM_BNOi,   "bnobt" }, \
0124     { XFS_BTNUM_CNTi,   "cntbt" }, \
0125     { XFS_BTNUM_RMAPi,  "rmapbt" }, \
0126     { XFS_BTNUM_BMAPi,  "bmbt" }, \
0127     { XFS_BTNUM_INOi,   "inobt" }, \
0128     { XFS_BTNUM_FINOi,  "finobt" }, \
0129     { XFS_BTNUM_REFCi,  "refcbt" }
0130 
0131 struct xfs_name {
0132     const unsigned char *name;
0133     int         len;
0134     int         type;
0135 };
0136 
0137 /*
0138  * uid_t and gid_t are hard-coded to 32 bits in the inode.
0139  * Hence, an 'id' in a dquot is 32 bits..
0140  */
0141 typedef uint32_t    xfs_dqid_t;
0142 
0143 /*
0144  * Constants for bit manipulations.
0145  */
0146 #define XFS_NBBYLOG 3       /* log2(NBBY) */
0147 #define XFS_WORDLOG 2       /* log2(sizeof(xfs_rtword_t)) */
0148 #define XFS_NBWORDLOG   (XFS_NBBYLOG + XFS_WORDLOG)
0149 #define XFS_NBWORD  (1 << XFS_NBWORDLOG)
0150 #define XFS_WORDMASK    ((1 << XFS_WORDLOG) - 1)
0151 
0152 struct xfs_iext_cursor {
0153     struct xfs_iext_leaf    *leaf;
0154     int         pos;
0155 };
0156 
0157 typedef enum {
0158     XFS_EXT_NORM, XFS_EXT_UNWRITTEN,
0159 } xfs_exntst_t;
0160 
0161 typedef struct xfs_bmbt_irec
0162 {
0163     xfs_fileoff_t   br_startoff;    /* starting file offset */
0164     xfs_fsblock_t   br_startblock;  /* starting block number */
0165     xfs_filblks_t   br_blockcount;  /* number of blocks */
0166     xfs_exntst_t    br_state;   /* extent state */
0167 } xfs_bmbt_irec_t;
0168 
0169 /* per-AG block reservation types */
0170 enum xfs_ag_resv_type {
0171     XFS_AG_RESV_NONE = 0,
0172     XFS_AG_RESV_AGFL,
0173     XFS_AG_RESV_METADATA,
0174     XFS_AG_RESV_RMAPBT,
0175 };
0176 
0177 /*
0178  * Type verifier functions
0179  */
0180 struct xfs_mount;
0181 
0182 bool xfs_verify_fsbno(struct xfs_mount *mp, xfs_fsblock_t fsbno);
0183 bool xfs_verify_fsbext(struct xfs_mount *mp, xfs_fsblock_t fsbno,
0184         xfs_fsblock_t len);
0185 
0186 bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino);
0187 bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino);
0188 bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino);
0189 bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno);
0190 bool xfs_verify_rtext(struct xfs_mount *mp, xfs_rtblock_t rtbno,
0191         xfs_rtblock_t len);
0192 bool xfs_verify_icount(struct xfs_mount *mp, unsigned long long icount);
0193 bool xfs_verify_dablk(struct xfs_mount *mp, xfs_fileoff_t off);
0194 void xfs_icount_range(struct xfs_mount *mp, unsigned long long *min,
0195         unsigned long long *max);
0196 bool xfs_verify_fileoff(struct xfs_mount *mp, xfs_fileoff_t off);
0197 bool xfs_verify_fileext(struct xfs_mount *mp, xfs_fileoff_t off,
0198         xfs_fileoff_t len);
0199 
0200 #endif  /* __XFS_TYPES_H__ */