Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2000-2001 Christoph Hellwig.
0004  */
0005 #ifndef _VXFS_DIR_H_
0006 #define _VXFS_DIR_H_
0007 
0008 /*
0009  * Veritas filesystem driver - directory structure.
0010  *
0011  * This file contains the definition of the vxfs directory format.
0012  */
0013 
0014 
0015 /*
0016  * VxFS directory block header.
0017  *
0018  * This entry is the head of every filesystem block in a directory.
0019  * It is used for free space management and additionally includes
0020  * a hash for speeding up directory search (lookup).
0021  *
0022  * The hash may be empty and in fact we do not use it all in the
0023  * Linux driver for now.
0024  */
0025 struct vxfs_dirblk {
0026     __fs16      d_free;     /* free space in dirblock */
0027     __fs16      d_nhash;    /* no of hash chains */
0028     __fs16      d_hash[1];  /* hash chain */
0029 };
0030 
0031 /*
0032  * VXFS_NAMELEN is the maximum length of the d_name field
0033  *  of an VxFS directory entry.
0034  */
0035 #define VXFS_NAMELEN    256
0036 
0037 /*
0038  * VxFS directory entry.
0039  */
0040 struct vxfs_direct {
0041     __fs32      d_ino;          /* inode number */
0042     __fs16      d_reclen;       /* record length */
0043     __fs16      d_namelen;      /* d_name length */
0044     __fs16      d_hashnext;     /* next hash entry */
0045     char        d_name[VXFS_NAMELEN];   /* name */
0046 };
0047 
0048 /*
0049  * VXFS_DIRPAD defines the directory entry boundaries, is _must_ be
0050  *  a multiple of four.
0051  * VXFS_NAMEMIN is the length of a directory entry with a NULL d_name.
0052  * VXFS_DIRROUND is an internal macros that rounds a length to a value
0053  *  usable for directory sizes.
0054  * VXFS_DIRLEN calculates the directory entry size for an entry with
0055  *  a d_name with size len.
0056  */
0057 #define VXFS_DIRPAD     4
0058 #define VXFS_NAMEMIN        offsetof(struct vxfs_direct, d_name)
0059 #define VXFS_DIRROUND(len)  ((VXFS_DIRPAD + (len) - 1) & ~(VXFS_DIRPAD -1))
0060 #define VXFS_DIRLEN(len)    (VXFS_DIRROUND(VXFS_NAMEMIN + (len)))
0061 
0062 /*
0063  * VXFS_DIRBLKOV is the overhead of a specific dirblock.
0064  */
0065 #define VXFS_DIRBLKOV(sbi, dbp) \
0066     ((sizeof(short) * fs16_to_cpu(sbi, dbp->d_nhash)) + 4)
0067 
0068 #endif /* _VXFS_DIR_H_ */