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