162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2000-2001 Christoph Hellwig. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci#ifndef _VXFS_DIR_H_ 662306a36Sopenharmony_ci#define _VXFS_DIR_H_ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci/* 962306a36Sopenharmony_ci * Veritas filesystem driver - directory structure. 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * This file contains the definition of the vxfs directory format. 1262306a36Sopenharmony_ci */ 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci/* 1662306a36Sopenharmony_ci * VxFS directory block header. 1762306a36Sopenharmony_ci * 1862306a36Sopenharmony_ci * This entry is the head of every filesystem block in a directory. 1962306a36Sopenharmony_ci * It is used for free space management and additionally includes 2062306a36Sopenharmony_ci * a hash for speeding up directory search (lookup). 2162306a36Sopenharmony_ci * 2262306a36Sopenharmony_ci * The hash may be empty and in fact we do not use it all in the 2362306a36Sopenharmony_ci * Linux driver for now. 2462306a36Sopenharmony_ci */ 2562306a36Sopenharmony_cistruct vxfs_dirblk { 2662306a36Sopenharmony_ci __fs16 d_free; /* free space in dirblock */ 2762306a36Sopenharmony_ci __fs16 d_nhash; /* no of hash chains */ 2862306a36Sopenharmony_ci __fs16 d_hash[1]; /* hash chain */ 2962306a36Sopenharmony_ci}; 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci/* 3262306a36Sopenharmony_ci * VXFS_NAMELEN is the maximum length of the d_name field 3362306a36Sopenharmony_ci * of an VxFS directory entry. 3462306a36Sopenharmony_ci */ 3562306a36Sopenharmony_ci#define VXFS_NAMELEN 256 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci/* 3862306a36Sopenharmony_ci * VxFS directory entry. 3962306a36Sopenharmony_ci */ 4062306a36Sopenharmony_cistruct vxfs_direct { 4162306a36Sopenharmony_ci __fs32 d_ino; /* inode number */ 4262306a36Sopenharmony_ci __fs16 d_reclen; /* record length */ 4362306a36Sopenharmony_ci __fs16 d_namelen; /* d_name length */ 4462306a36Sopenharmony_ci __fs16 d_hashnext; /* next hash entry */ 4562306a36Sopenharmony_ci char d_name[VXFS_NAMELEN]; /* name */ 4662306a36Sopenharmony_ci}; 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci/* 4962306a36Sopenharmony_ci * VXFS_DIRPAD defines the directory entry boundaries, is _must_ be 5062306a36Sopenharmony_ci * a multiple of four. 5162306a36Sopenharmony_ci * VXFS_NAMEMIN is the length of a directory entry with a NULL d_name. 5262306a36Sopenharmony_ci * VXFS_DIRROUND is an internal macros that rounds a length to a value 5362306a36Sopenharmony_ci * usable for directory sizes. 5462306a36Sopenharmony_ci * VXFS_DIRLEN calculates the directory entry size for an entry with 5562306a36Sopenharmony_ci * a d_name with size len. 5662306a36Sopenharmony_ci */ 5762306a36Sopenharmony_ci#define VXFS_DIRPAD 4 5862306a36Sopenharmony_ci#define VXFS_NAMEMIN offsetof(struct vxfs_direct, d_name) 5962306a36Sopenharmony_ci#define VXFS_DIRROUND(len) ((VXFS_DIRPAD + (len) - 1) & ~(VXFS_DIRPAD -1)) 6062306a36Sopenharmony_ci#define VXFS_DIRLEN(len) (VXFS_DIRROUND(VXFS_NAMEMIN + (len))) 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/* 6362306a36Sopenharmony_ci * VXFS_DIRBLKOV is the overhead of a specific dirblock. 6462306a36Sopenharmony_ci */ 6562306a36Sopenharmony_ci#define VXFS_DIRBLKOV(sbi, dbp) \ 6662306a36Sopenharmony_ci ((sizeof(short) * fs16_to_cpu(sbi, dbp->d_nhash)) + 4) 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci#endif /* _VXFS_DIR_H_ */ 69