1*0b1e987cSChristoph Hellwig /* SPDX-License-Identifier: GPL-2.0-only */ 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * Copyright (c) 2000-2001 Christoph Hellwig. 41da177e4SLinus Torvalds */ 51da177e4SLinus Torvalds #ifndef _VXFS_DIR_H_ 61da177e4SLinus Torvalds #define _VXFS_DIR_H_ 71da177e4SLinus Torvalds 81da177e4SLinus Torvalds /* 91da177e4SLinus Torvalds * Veritas filesystem driver - directory structure. 101da177e4SLinus Torvalds * 111da177e4SLinus Torvalds * This file contains the definition of the vxfs directory format. 121da177e4SLinus Torvalds */ 131da177e4SLinus Torvalds 141da177e4SLinus Torvalds 151da177e4SLinus Torvalds /* 161da177e4SLinus Torvalds * VxFS directory block header. 171da177e4SLinus Torvalds * 181da177e4SLinus Torvalds * This entry is the head of every filesystem block in a directory. 19c78bad11SJoe Perches * It is used for free space management and additionally includes 201da177e4SLinus Torvalds * a hash for speeding up directory search (lookup). 211da177e4SLinus Torvalds * 221da177e4SLinus Torvalds * The hash may be empty and in fact we do not use it all in the 231da177e4SLinus Torvalds * Linux driver for now. 241da177e4SLinus Torvalds */ 251da177e4SLinus Torvalds struct vxfs_dirblk { 260d83f7fcSKrzysztof Błaszkowski __fs16 d_free; /* free space in dirblock */ 270d83f7fcSKrzysztof Błaszkowski __fs16 d_nhash; /* no of hash chains */ 280d83f7fcSKrzysztof Błaszkowski __fs16 d_hash[1]; /* hash chain */ 291da177e4SLinus Torvalds }; 301da177e4SLinus Torvalds 311da177e4SLinus Torvalds /* 321da177e4SLinus Torvalds * VXFS_NAMELEN is the maximum length of the d_name field 331da177e4SLinus Torvalds * of an VxFS directory entry. 341da177e4SLinus Torvalds */ 351da177e4SLinus Torvalds #define VXFS_NAMELEN 256 361da177e4SLinus Torvalds 371da177e4SLinus Torvalds /* 381da177e4SLinus Torvalds * VxFS directory entry. 391da177e4SLinus Torvalds */ 401da177e4SLinus Torvalds struct vxfs_direct { 410d83f7fcSKrzysztof Błaszkowski __fs32 d_ino; /* inode number */ 420d83f7fcSKrzysztof Błaszkowski __fs16 d_reclen; /* record length */ 430d83f7fcSKrzysztof Błaszkowski __fs16 d_namelen; /* d_name length */ 440d83f7fcSKrzysztof Błaszkowski __fs16 d_hashnext; /* next hash entry */ 451da177e4SLinus Torvalds char d_name[VXFS_NAMELEN]; /* name */ 461da177e4SLinus Torvalds }; 471da177e4SLinus Torvalds 481da177e4SLinus Torvalds /* 491da177e4SLinus Torvalds * VXFS_DIRPAD defines the directory entry boundaries, is _must_ be 501da177e4SLinus Torvalds * a multiple of four. 511da177e4SLinus Torvalds * VXFS_NAMEMIN is the length of a directory entry with a NULL d_name. 521da177e4SLinus Torvalds * VXFS_DIRROUND is an internal macros that rounds a length to a value 531da177e4SLinus Torvalds * usable for directory sizes. 541da177e4SLinus Torvalds * VXFS_DIRLEN calculates the directory entry size for an entry with 551da177e4SLinus Torvalds * a d_name with size len. 561da177e4SLinus Torvalds */ 571da177e4SLinus Torvalds #define VXFS_DIRPAD 4 5885420ccaSAndrew Morton #define VXFS_NAMEMIN offsetof(struct vxfs_direct, d_name) 591da177e4SLinus Torvalds #define VXFS_DIRROUND(len) ((VXFS_DIRPAD + (len) - 1) & ~(VXFS_DIRPAD -1)) 601da177e4SLinus Torvalds #define VXFS_DIRLEN(len) (VXFS_DIRROUND(VXFS_NAMEMIN + (len))) 611da177e4SLinus Torvalds 621da177e4SLinus Torvalds /* 631da177e4SLinus Torvalds * VXFS_DIRBLKOV is the overhead of a specific dirblock. 641da177e4SLinus Torvalds */ 650d83f7fcSKrzysztof Błaszkowski #define VXFS_DIRBLKOV(sbi, dbp) \ 660d83f7fcSKrzysztof Błaszkowski ((sizeof(short) * fs16_to_cpu(sbi, dbp->d_nhash)) + 4) 671da177e4SLinus Torvalds 681da177e4SLinus Torvalds #endif /* _VXFS_DIR_H_ */ 69