sysv: replace inode uid,gid,mode initialization with helper function
[safe/jmp/linux-2.6] / fs / xfs / xfs_da_btree.h
index 6343c3a..fe9f5a8 100644 (file)
@@ -36,14 +36,10 @@ struct zone;
  * level in the Btree, and to identify which type of block this is.
  */
 #define XFS_DA_NODE_MAGIC      0xfebe  /* magic number: non-leaf blocks */
-#define XFS_DIR_LEAF_MAGIC     0xfeeb  /* magic number: directory leaf blks */
 #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 */
 
-#define        XFS_DIRX_LEAF_MAGIC(mp) \
-       (XFS_DIR_IS_V1(mp) ? XFS_DIR_LEAF_MAGIC : XFS_DIR2_LEAFN_MAGIC)
-
 typedef struct xfs_da_blkinfo {
        __be32          forw;                   /* previous block in list */
        __be32          back;                   /* following block in list */
@@ -65,8 +61,8 @@ typedef struct xfs_da_blkinfo {
 typedef struct xfs_da_intnode {
        struct xfs_da_node_hdr {        /* constant-structure header block */
                xfs_da_blkinfo_t info;  /* block type, links, etc. */
-               __uint16_t count;       /* count of active entries */
-               __uint16_t level;       /* level above leaves (leaf == 0) */
+               __be16  count;          /* count of active entries */
+               __be16  level;          /* level above leaves (leaf == 0) */
        } hdr;
        struct xfs_da_node_entry {
                __be32  hashval;        /* hash value for this descendant */
@@ -76,39 +72,28 @@ typedef struct xfs_da_intnode {
 typedef struct xfs_da_node_hdr xfs_da_node_hdr_t;
 typedef struct xfs_da_node_entry xfs_da_node_entry_t;
 
-#define XFS_DA_MAXHASH ((xfs_dahash_t)-1) /* largest valid hash value */
-
 #define        XFS_LBSIZE(mp)  (mp)->m_sb.sb_blocksize
-#define        XFS_LBLOG(mp)   (mp)->m_sb.sb_blocklog
-
-#define        XFS_DA_MAKE_BNOENTRY(mp,bno,entry)      \
-       (((bno) << (mp)->m_dircook_elog) | (entry))
-#define        XFS_DA_MAKE_COOKIE(mp,bno,entry,hash)   \
-       (((xfs_off_t)XFS_DA_MAKE_BNOENTRY(mp, bno, entry) << 32) | (hash))
-#define        XFS_DA_COOKIE_HASH(mp,cookie)           ((xfs_dahash_t)cookie)
-#define        XFS_DA_COOKIE_BNO(mp,cookie)            \
-       ((((xfs_off_t)(cookie) >> 31) == -1LL ? \
-               (xfs_dablk_t)0 : \
-               (xfs_dablk_t)((xfs_off_t)(cookie) >> \
-                               ((mp)->m_dircook_elog + 32))))
-#define        XFS_DA_COOKIE_ENTRY(mp,cookie)          \
-       ((((xfs_off_t)(cookie) >> 31) == -1LL ? \
-               (xfs_dablk_t)0 : \
-               (xfs_dablk_t)(((xfs_off_t)(cookie) >> 32) & \
-                               ((1 << (mp)->m_dircook_elog) - 1))))
-
 
 /*========================================================================
  * Btree searching and modification structure definitions.
  *========================================================================*/
 
 /*
+ * Search comparison results
+ */
+enum xfs_dacmp {
+       XFS_CMP_DIFFERENT,      /* names are completely different */
+       XFS_CMP_EXACT,          /* names are exactly the same */
+       XFS_CMP_CASE            /* names are same but differ in case */
+};
+
+/*
  * Structure to ease passing around component names.
  */
 typedef struct xfs_da_args {
-       const uchar_t   *name;          /* string (maybe not NULL terminated) */
+       const __uint8_t *name;          /* string (maybe not NULL terminated) */
        int             namelen;        /* length of string (maybe no NULL) */
-       uchar_t         *value;         /* set of bytes (maybe contain NULLs) */
+       __uint8_t       *value;         /* set of bytes (maybe contain NULLs) */
        int             valuelen;       /* length of value */
        int             flags;          /* argument flags (eg: ATTR_NOCREATE) */
        xfs_dahash_t    hashval;        /* hash value of name */
@@ -127,13 +112,27 @@ typedef struct xfs_da_args {
        int             index2;         /* index of 2nd attr in blk */
        xfs_dablk_t     rmtblkno2;      /* remote attr value starting blkno */
        int             rmtblkcnt2;     /* remote attr value block count */
-       unsigned char   justcheck;      /* T/F: check for ok with no space */
-       unsigned char   rename;         /* T/F: this is an atomic rename op */
-       unsigned char   addname;        /* T/F: this is an add operation */
-       unsigned char   oknoent;        /* T/F: ok to return ENOENT, else die */
+       int             op_flags;       /* operation flags */
+       enum xfs_dacmp  cmpresult;      /* name compare result for lookups */
 } xfs_da_args_t;
 
 /*
+ * Operation flags:
+ */
+#define XFS_DA_OP_JUSTCHECK    0x0001  /* check for ok with no space */
+#define XFS_DA_OP_RENAME       0x0002  /* this is an atomic rename op */
+#define XFS_DA_OP_ADDNAME      0x0004  /* this is an add operation */
+#define XFS_DA_OP_OKNOENT      0x0008  /* lookup/add op, ENOENT ok, else die */
+#define XFS_DA_OP_CILOOKUP     0x0010  /* lookup to return CI name if found */
+
+#define XFS_DA_OP_FLAGS \
+       { XFS_DA_OP_JUSTCHECK,  "JUSTCHECK" }, \
+       { XFS_DA_OP_RENAME,     "RENAME" }, \
+       { XFS_DA_OP_ADDNAME,    "ADDNAME" }, \
+       { XFS_DA_OP_OKNOENT,    "OKNOENT" }, \
+       { XFS_DA_OP_CILOOKUP,   "CILOOKUP" }
+
+/*
  * Structure to describe buffer(s) for a block.
  * This is needed in the directory version 2 format case, when
  * multiple non-contiguous fsblocks might be needed to cover one
@@ -193,7 +192,7 @@ typedef struct xfs_da_state {
        unsigned char           inleaf;         /* insert into 1->lf, 0->splf */
        unsigned char           extravalid;     /* T/F: extrablk is in use */
        unsigned char           extraafter;     /* T/F: extrablk is after new */
-       xfs_da_state_blk_t      extrablk;       /* for double-splits on leafs */
+       xfs_da_state_blk_t      extrablk;       /* for double-splits on leaves */
                                                /* for dirv2 extrablk is data */
 } xfs_da_state_t;
 
@@ -205,10 +204,18 @@ typedef struct xfs_da_state {
                (uint)(XFS_DA_LOGOFF(BASE, ADDR)), \
                (uint)(XFS_DA_LOGOFF(BASE, ADDR)+(SIZE)-1)
 
+/*
+ * Name ops for directory and/or attr name operations
+ */
+struct xfs_nameops {
+       xfs_dahash_t    (*hashname)(struct xfs_name *);
+       enum xfs_dacmp  (*compname)(struct xfs_da_args *,
+                                       const unsigned char *, int);
+};
+
 
-#ifdef __KERNEL__
 /*========================================================================
- * Function prototypes for the kernel.
+ * Function prototypes.
  *========================================================================*/
 
 /*
@@ -252,8 +259,11 @@ xfs_daddr_t        xfs_da_reada_buf(struct xfs_trans *trans, struct xfs_inode *dp,
 int    xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
                                          xfs_dabuf_t *dead_buf);
 
-uint xfs_da_hashname(const uchar_t *name_string, int name_length);
-uint xfs_da_log2_roundup(uint i);
+uint xfs_da_hashname(const __uint8_t *name_string, int name_length);
+enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,
+                               const unsigned char *name, int len);
+
+
 xfs_da_state_t *xfs_da_state_alloc(void);
 void xfs_da_state_free(xfs_da_state_t *state);
 
@@ -265,6 +275,7 @@ void xfs_da_binval(struct xfs_trans *tp, xfs_dabuf_t *dabuf);
 xfs_daddr_t xfs_da_blkno(xfs_dabuf_t *dabuf);
 
 extern struct kmem_zone *xfs_da_state_zone;
-#endif /* __KERNEL__ */
+extern struct kmem_zone *xfs_dabuf_zone;
+extern const struct xfs_nameops xfs_default_nameops;
 
 #endif /* __XFS_DA_BTREE_H__ */