xref: /kernel/linux/linux-5.10/fs/freevxfs/vxfs_dir.h (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2000-2001 Christoph Hellwig.
38c2ecf20Sopenharmony_ci * All rights reserved.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
68c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions
78c2ecf20Sopenharmony_ci * are met:
88c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
98c2ecf20Sopenharmony_ci *    notice, this list of conditions, and the following disclaimer,
108c2ecf20Sopenharmony_ci *    without modification.
118c2ecf20Sopenharmony_ci * 2. The name of the author may not be used to endorse or promote products
128c2ecf20Sopenharmony_ci *    derived from this software without specific prior written permission.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the
158c2ecf20Sopenharmony_ci * GNU General Public License ("GPL").
168c2ecf20Sopenharmony_ci *
178c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
188c2ecf20Sopenharmony_ci * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
198c2ecf20Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
208c2ecf20Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
218c2ecf20Sopenharmony_ci * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
228c2ecf20Sopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
238c2ecf20Sopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
248c2ecf20Sopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
258c2ecf20Sopenharmony_ci * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
268c2ecf20Sopenharmony_ci * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
278c2ecf20Sopenharmony_ci * SUCH DAMAGE.
288c2ecf20Sopenharmony_ci *
298c2ecf20Sopenharmony_ci */
308c2ecf20Sopenharmony_ci#ifndef _VXFS_DIR_H_
318c2ecf20Sopenharmony_ci#define _VXFS_DIR_H_
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/*
348c2ecf20Sopenharmony_ci * Veritas filesystem driver - directory structure.
358c2ecf20Sopenharmony_ci *
368c2ecf20Sopenharmony_ci * This file contains the definition of the vxfs directory format.
378c2ecf20Sopenharmony_ci */
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/*
418c2ecf20Sopenharmony_ci * VxFS directory block header.
428c2ecf20Sopenharmony_ci *
438c2ecf20Sopenharmony_ci * This entry is the head of every filesystem block in a directory.
448c2ecf20Sopenharmony_ci * It is used for free space management and additionally includes
458c2ecf20Sopenharmony_ci * a hash for speeding up directory search (lookup).
468c2ecf20Sopenharmony_ci *
478c2ecf20Sopenharmony_ci * The hash may be empty and in fact we do not use it all in the
488c2ecf20Sopenharmony_ci * Linux driver for now.
498c2ecf20Sopenharmony_ci */
508c2ecf20Sopenharmony_cistruct vxfs_dirblk {
518c2ecf20Sopenharmony_ci	__fs16		d_free;		/* free space in dirblock */
528c2ecf20Sopenharmony_ci	__fs16		d_nhash;	/* no of hash chains */
538c2ecf20Sopenharmony_ci	__fs16		d_hash[1];	/* hash chain */
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/*
578c2ecf20Sopenharmony_ci * VXFS_NAMELEN is the maximum length of the d_name field
588c2ecf20Sopenharmony_ci *	of an VxFS directory entry.
598c2ecf20Sopenharmony_ci */
608c2ecf20Sopenharmony_ci#define VXFS_NAMELEN	256
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci/*
638c2ecf20Sopenharmony_ci * VxFS directory entry.
648c2ecf20Sopenharmony_ci */
658c2ecf20Sopenharmony_cistruct vxfs_direct {
668c2ecf20Sopenharmony_ci	__fs32		d_ino;			/* inode number */
678c2ecf20Sopenharmony_ci	__fs16		d_reclen;		/* record length */
688c2ecf20Sopenharmony_ci	__fs16		d_namelen;		/* d_name length */
698c2ecf20Sopenharmony_ci	__fs16		d_hashnext;		/* next hash entry */
708c2ecf20Sopenharmony_ci	char		d_name[VXFS_NAMELEN];	/* name */
718c2ecf20Sopenharmony_ci};
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci/*
748c2ecf20Sopenharmony_ci * VXFS_DIRPAD defines the directory entry boundaries, is _must_ be
758c2ecf20Sopenharmony_ci *	a multiple of four.
768c2ecf20Sopenharmony_ci * VXFS_NAMEMIN is the length of a directory entry with a NULL d_name.
778c2ecf20Sopenharmony_ci * VXFS_DIRROUND is an internal macros that rounds a length to a value
788c2ecf20Sopenharmony_ci *	usable for directory sizes.
798c2ecf20Sopenharmony_ci * VXFS_DIRLEN calculates the directory entry size for an entry with
808c2ecf20Sopenharmony_ci *	a d_name with size len.
818c2ecf20Sopenharmony_ci */
828c2ecf20Sopenharmony_ci#define VXFS_DIRPAD		4
838c2ecf20Sopenharmony_ci#define VXFS_NAMEMIN		offsetof(struct vxfs_direct, d_name)
848c2ecf20Sopenharmony_ci#define VXFS_DIRROUND(len)	((VXFS_DIRPAD + (len) - 1) & ~(VXFS_DIRPAD -1))
858c2ecf20Sopenharmony_ci#define VXFS_DIRLEN(len)	(VXFS_DIRROUND(VXFS_NAMEMIN + (len)))
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci/*
888c2ecf20Sopenharmony_ci * VXFS_DIRBLKOV is the overhead of a specific dirblock.
898c2ecf20Sopenharmony_ci */
908c2ecf20Sopenharmony_ci#define VXFS_DIRBLKOV(sbi, dbp)	\
918c2ecf20Sopenharmony_ci	((sizeof(short) * fs16_to_cpu(sbi, dbp->d_nhash)) + 4)
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci#endif /* _VXFS_DIR_H_ */
94