vxfs_dir.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Copyright (c) 2000-2001 Christoph Hellwig.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions, and the following disclaimer,
  10.  *    without modification.
  11.  * 2. The name of the author may not be used to endorse or promote products
  12.  *    derived from this software without specific prior written permission.
  13.  *
  14.  * Alternatively, this software may be distributed under the terms of the
  15.  * GNU General Public License ("GPL").
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  18.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20.  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
  21.  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27.  * SUCH DAMAGE.
  28.  *
  29.  */
  30. #ifndef _VXFS_DIR_H_
  31. #define _VXFS_DIR_H_
  32. #ident "$Id: vxfs_dir.h,v 1.7 2001/05/21 15:48:26 hch Exp hch $"
  33. /*
  34.  * Veritas filesystem driver - directory structure.
  35.  *
  36.  * This file contains the definition of the vxfs directory format.
  37.  */
  38. /*
  39.  * VxFS directory block header.
  40.  *
  41.  * This entry is the head of every filesystem block in a directory.
  42.  * It is used for free space managment and additionally includes
  43.  * a hash for speeding up directory search (lookup).
  44.  *
  45.  * The hash may be empty and in fact we do not use it all in the
  46.  * Linux driver for now.
  47.  */
  48. struct vxfs_dirblk {
  49. u_int16_t d_free; /* free space in dirblock */
  50. u_int16_t d_nhash; /* no of hash chains */
  51. u_int16_t d_hash[1]; /* hash chain */
  52. };
  53. /*
  54.  * VXFS_NAMELEN is the maximum length of the d_name field
  55.  * of an VxFS directory entry.
  56.  */
  57. #define VXFS_NAMELEN 256
  58. /*
  59.  * VxFS directory entry.
  60.  */
  61. struct vxfs_direct {
  62. vx_ino_t d_ino; /* inode number */
  63. u_int16_t d_reclen; /* record length */
  64. u_int16_t d_namelen; /* d_name length */
  65. u_int16_t d_hashnext; /* next hash entry */
  66. char d_name[VXFS_NAMELEN]; /* name */
  67. };
  68. /*
  69.  * VXFS_DIRPAD defines the directory entry boundaries, is _must_ be
  70.  * a multiple of four.
  71.  * VXFS_NAMEMIN is the length of a directory entry with a NULL d_name.
  72.  * VXFS_DIRROUND is an internal macros that rounds a length to a value
  73.  * usable for directory sizes.
  74.  * VXFS_DIRLEN calculates the directory entry size for an entry with
  75.  * a d_name with size len.
  76.  */
  77. #define VXFS_DIRPAD 4
  78. #define VXFS_NAMEMIN ((int)((struct vxfs_direct *)0)->d_name)
  79. #define VXFS_DIRROUND(len) ((VXFS_DIRPAD + (len) - 1) & ~(VXFS_DIRPAD -1))
  80. #define VXFS_DIRLEN(len) (VXFS_DIRROUND(VXFS_NAMEMIN + (len)))
  81. /*
  82.  * VXFS_DIRBLKOV is the overhead of a specific dirblock.
  83.  */
  84. #define VXFS_DIRBLKOV(dbp) ((sizeof(short) * dbp->d_nhash) + 4)
  85. #endif /* _VXFS_DIR_H_ */