xref: /titanic_41/usr/src/uts/common/sys/fs/hsfs_node.h (revision 84b82766376a981b4beff87bdba0efa9e2aa7a39)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5fc1c62b8Sfrankho  * Common Development and Distribution License (the "License").
6fc1c62b8Sfrankho  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
227c478bd9Sstevel@tonic-gate  * High Sierra filesystem structure definitions
23fc1c62b8Sfrankho  */
24fc1c62b8Sfrankho /*
25d10b6702Sfrankho  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
267c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifndef	_SYS_FS_HSFS_NODE_H
307c478bd9Sstevel@tonic-gate #define	_SYS_FS_HSFS_NODE_H
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
38*84b82766Smg147109 #include <sys/taskq.h>
39*84b82766Smg147109 
407c478bd9Sstevel@tonic-gate struct	hs_direntry {
417c478bd9Sstevel@tonic-gate 	uint_t		ext_lbn;	/* LBN of start of extent */
427c478bd9Sstevel@tonic-gate 	uint_t		ext_size;    	/* no. of data bytes in extent */
437c478bd9Sstevel@tonic-gate 	struct timeval	cdate;		/* creation date */
447c478bd9Sstevel@tonic-gate 	struct timeval	mdate;		/* last modification date */
457c478bd9Sstevel@tonic-gate 	struct timeval	adate;		/* last access date */
467c478bd9Sstevel@tonic-gate 	enum vtype	type;		/* file type */
477c478bd9Sstevel@tonic-gate 	mode_t		mode;		/* mode and type of file (UNIX) */
487c478bd9Sstevel@tonic-gate 	uint_t		nlink;		/* no. of links to file */
497c478bd9Sstevel@tonic-gate 	uid_t		uid;		/* owner's user id */
507c478bd9Sstevel@tonic-gate 	gid_t		gid;		/* owner's group id */
51d10b6702Sfrankho 	ino64_t		inode;		/* inode number from rrip data */
527c478bd9Sstevel@tonic-gate 	dev_t		r_dev;		/* major/minor device numbers */
537c478bd9Sstevel@tonic-gate 	uint_t		xar_prot :1;	/* 1 if protection in XAR */
547c478bd9Sstevel@tonic-gate 	uchar_t		xar_len;	/* no. of Logical blocks in XAR */
557c478bd9Sstevel@tonic-gate 	uchar_t		intlf_sz;	/* intleaving size */
567c478bd9Sstevel@tonic-gate 	uchar_t		intlf_sk;	/* intleaving skip factor */
577c478bd9Sstevel@tonic-gate 	ushort_t	sym_link_flag;	/* flags for sym link */
587c478bd9Sstevel@tonic-gate 	char		*sym_link; 	/* path of sym link for readlink() */
597c478bd9Sstevel@tonic-gate };
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate struct	ptable {
627c478bd9Sstevel@tonic-gate 	uchar_t	filler[7];		/* filler */
637c478bd9Sstevel@tonic-gate 	uchar_t	dname_len;		/* length of directory name */
647c478bd9Sstevel@tonic-gate 	uchar_t	dname[HS_DIR_NAMELEN+1];	/* directory name */
657c478bd9Sstevel@tonic-gate };
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate struct ptable_idx {
687c478bd9Sstevel@tonic-gate 	struct ptable_idx *idx_pptbl_idx; /* parent's path table index entry */
697c478bd9Sstevel@tonic-gate 	struct ptable	*idx_mptbl;	/* path table entry for myself */
707c478bd9Sstevel@tonic-gate 	ushort_t idx_nochild;		/* no. of children */
717c478bd9Sstevel@tonic-gate 	ushort_t idx_childid;		/* directory no of first child */
727c478bd9Sstevel@tonic-gate };
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /*
757c478bd9Sstevel@tonic-gate  * hsnode structure:
767c478bd9Sstevel@tonic-gate  *
777c478bd9Sstevel@tonic-gate  * hs_offset, hs_ptbl_idx, base  apply to VDIR type only
787c478bd9Sstevel@tonic-gate  *
797c478bd9Sstevel@tonic-gate  * nodeid uniquely identifies an hsnode, ISO9660 means
807c478bd9Sstevel@tonic-gate  * nodeid can be very big.
817c478bd9Sstevel@tonic-gate  * For directories it is the disk address of
827c478bd9Sstevel@tonic-gate  * the data extent of the dir (the directory itself,
837c478bd9Sstevel@tonic-gate  * ".", and ".." all point to same data extent).
847c478bd9Sstevel@tonic-gate  * For non-directories, it is the disk address of the
857c478bd9Sstevel@tonic-gate  * directory entry for the file; note that this does
867c478bd9Sstevel@tonic-gate  * not permit hard links, as it assumes a single dir
877c478bd9Sstevel@tonic-gate  * entry per file.
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate struct  hsnode {
917c478bd9Sstevel@tonic-gate 	struct hsnode	*hs_hash;	/* next hsnode in hash list */
927c478bd9Sstevel@tonic-gate 	struct hsnode	*hs_freef;	/* next hsnode in free list */
937c478bd9Sstevel@tonic-gate 	struct hsnode	*hs_freeb;	/* previous hsnode in free list */
947c478bd9Sstevel@tonic-gate 	struct vnode	*hs_vnode;	/* the real vnode for the file */
957c478bd9Sstevel@tonic-gate 	struct hs_direntry hs_dirent;	/* the directory entry for this file */
967c478bd9Sstevel@tonic-gate 	ino64_t		hs_nodeid;	/* "inode" number for hsnode */
977c478bd9Sstevel@tonic-gate 	uint_t		hs_dir_lbn;	/* LBN of directory entry */
987c478bd9Sstevel@tonic-gate 	uint_t		hs_dir_off;	/* offset in LBN of directory entry */
997c478bd9Sstevel@tonic-gate 	struct ptable_idx	*hs_ptbl_idx;	/* path table index */
1007c478bd9Sstevel@tonic-gate 	uint_t		hs_offset;	/* start offset in dir for searching */
1017c478bd9Sstevel@tonic-gate 	long		hs_mapcnt;	/* mappings to file pages */
1027c478bd9Sstevel@tonic-gate 	uint_t		hs_seq;		/* sequence number */
1037c478bd9Sstevel@tonic-gate 	uint_t		hs_flags;	/* (see below) */
104*84b82766Smg147109 	u_offset_t	hs_prev_offset; /* Last read end offset (readahead) */
105*84b82766Smg147109 	int		hs_num_contig;  /* Count of contiguous reads */
106*84b82766Smg147109 	int		hs_ra_bytes;    /* Bytes to readahead */
1077c478bd9Sstevel@tonic-gate 	kmutex_t	hs_contents_lock;	/* protects hsnode contents */
1087c478bd9Sstevel@tonic-gate 						/* 	except hs_offset */
1097c478bd9Sstevel@tonic-gate };
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate /* hs_flags */
1127c478bd9Sstevel@tonic-gate #define	HREF	1			/* hsnode is referenced */
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate /* hs_modes */
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate #define	HFDIR	0040000			/* directory */
1177c478bd9Sstevel@tonic-gate #define	HFREG	0100000			/* regular file */
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate struct  hsfid {
1207c478bd9Sstevel@tonic-gate 	ushort_t	hf_len;		/* length of fid */
1217c478bd9Sstevel@tonic-gate 	ushort_t	hf_dir_off;	/* offset in LBN of directory entry */
1227c478bd9Sstevel@tonic-gate 	uint_t		hf_dir_lbn;	/* LBN of directory */
123d10b6702Sfrankho 	uint32_t	hf_ino;		/* The inode number or HS_DUMMY_INO */
1247c478bd9Sstevel@tonic-gate };
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate /*
1287c478bd9Sstevel@tonic-gate  * All of the fields in the hs_volume are read-only once they have been
1297c478bd9Sstevel@tonic-gate  * initialized.
1307c478bd9Sstevel@tonic-gate  */
1317c478bd9Sstevel@tonic-gate struct	hs_volume {
1327c478bd9Sstevel@tonic-gate 	ulong_t		vol_size; 	/* no. of Logical blocks in Volume */
1337c478bd9Sstevel@tonic-gate 	uint_t		lbn_size;	/* no. of bytes in a block */
1347c478bd9Sstevel@tonic-gate 	uint_t		lbn_shift;	/* shift to convert lbn to bytes */
1357c478bd9Sstevel@tonic-gate 	uint_t		lbn_secshift;	/* shift to convert lbn to sec */
1367c478bd9Sstevel@tonic-gate 	uint_t		lbn_maxoffset;	/* max lbn-relative offset and mask */
1377c478bd9Sstevel@tonic-gate 	uchar_t		file_struct_ver; /* version of directory structure */
1387c478bd9Sstevel@tonic-gate 	uid_t		vol_uid;	/* uid of volume */
1397c478bd9Sstevel@tonic-gate 	gid_t		vol_gid;	/* gid of volume */
1407c478bd9Sstevel@tonic-gate 	uint_t		vol_prot;	/* protection (mode) of volume */
1417c478bd9Sstevel@tonic-gate 	struct timeval	cre_date;	/* volume creation time */
1427c478bd9Sstevel@tonic-gate 	struct timeval	mod_date;	/* volume modification time */
1437c478bd9Sstevel@tonic-gate 	struct	hs_direntry root_dir;	/* dir entry for Root Directory */
1447c478bd9Sstevel@tonic-gate 	ushort_t	ptbl_len;	/* number of bytes in Path Table */
1457c478bd9Sstevel@tonic-gate 	uint_t		ptbl_lbn;	/* logical block no of Path Table */
1467c478bd9Sstevel@tonic-gate 	ushort_t	vol_set_size;	/* number of CD in this vol set */
1477c478bd9Sstevel@tonic-gate 	ushort_t	vol_set_seq;	/* the sequence number of this CD */
1487c478bd9Sstevel@tonic-gate 	char		vol_id[32];		/* volume id in PVD */
1497c478bd9Sstevel@tonic-gate };
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  * The hsnode table is no longer fixed in size but grows
1537c478bd9Sstevel@tonic-gate  * and shrinks dynamically. However a cache of nodes is still maintained
1547c478bd9Sstevel@tonic-gate  * for efficiency. This cache size (nhsnode) is a tunable which
1557c478bd9Sstevel@tonic-gate  * is either specified in /etc/system or calculated as the number
1567c478bd9Sstevel@tonic-gate  * that will fit into the number of bytes defined by HS_HSNODESPACE (below).
1577c478bd9Sstevel@tonic-gate  */
1587c478bd9Sstevel@tonic-gate #define	HS_HASHSIZE	32		/* hsnode hash table size */
1597c478bd9Sstevel@tonic-gate #define	HS_HSNODESPACE	16384		/* approx. space used for hsnodes */
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate /*
162d10b6702Sfrankho  * We usually use the starting extent LBA for the inode numbers of files and
163d10b6702Sfrankho  * directories. As this will not work for zero sized files, we assign a dummy
164d10b6702Sfrankho  * inode number to all zero sized files. We use the number 16 as this is the
165d10b6702Sfrankho  * LBA for the PVD, this number cannot be a valid starting extent LBA for a
166d10b6702Sfrankho  * file. In case that the node number is the HS_DUMMY_INO, we use the LBA and
167d10b6702Sfrankho  * offset of the directory entry of this file (which is what we used before
168d10b6702Sfrankho  * we started to support correct hard links).
169d10b6702Sfrankho  */
170d10b6702Sfrankho #define	HS_DUMMY_INO	16	/* dummy inode number for empty files */
171d10b6702Sfrankho 
172d10b6702Sfrankho /*
173*84b82766Smg147109  * Hsfs I/O Scheduling parameters and data structures.
174*84b82766Smg147109  * Deadline for reads is set at 5000 usec.
175*84b82766Smg147109  */
176*84b82766Smg147109 #define	HSFS_READ_DEADLINE 5000
177*84b82766Smg147109 #define	HSFS_NORMAL 0x0
178*84b82766Smg147109 
179*84b82766Smg147109 /*
180*84b82766Smg147109  * This structure holds information for a read request that is enqueued
181*84b82766Smg147109  * for processing by the scheduling function. An AVL tree is used to
182*84b82766Smg147109  * access the read requests in a sorted manner.
183*84b82766Smg147109  */
184*84b82766Smg147109 struct hio {
185*84b82766Smg147109 	struct buf	*bp;		/* The buf for this read */
186*84b82766Smg147109 	struct hio	*contig_chain;  /* Next adjacent read if any */
187*84b82766Smg147109 	offset_t	io_lblkno;	/* Starting disk block of io */
188*84b82766Smg147109 	u_offset_t	nblocks;	/* # disk blocks */
189*84b82766Smg147109 	uint64_t	io_timestamp;	/* usec timestamp for deadline */
190*84b82766Smg147109 	ksema_t		*sema;		/* Completion flag */
191*84b82766Smg147109 	avl_node_t	io_offset_node; /* Avl tree requirements */
192*84b82766Smg147109 	avl_node_t	io_deadline_node;
193*84b82766Smg147109 };
194*84b82766Smg147109 
195*84b82766Smg147109 /*
196*84b82766Smg147109  * This structure holds information about all the read requests issued
197*84b82766Smg147109  * during a read-ahead invocation. This is then enqueued on a task-queue
198*84b82766Smg147109  * for processing by a background thread that takes this read-ahead to
199*84b82766Smg147109  * completion and cleans up.
200*84b82766Smg147109  */
201*84b82766Smg147109 struct hio_info {
202*84b82766Smg147109 	struct buf	*bufs;	/* array of bufs issued for this R/A */
203*84b82766Smg147109 	caddr_t		*vas;	/* The kmem_alloced chunk for the bufs */
204*84b82766Smg147109 	ksema_t		*sema;	/* Semaphores used in the bufs */
205*84b82766Smg147109 	uint_t		bufsused; /* # of bufs actually used */
206*84b82766Smg147109 	uint_t		bufcnt;   /* Tot bufs allocated. */
207*84b82766Smg147109 	struct page	*pp;	  /* The list of I/O locked pages */
208*84b82766Smg147109 	struct hsfs	*fsp; /* The filesystem structure */
209*84b82766Smg147109 };
210*84b82766Smg147109 
211*84b82766Smg147109 /*
212*84b82766Smg147109  * This is per-filesystem structure that stores toplevel data structures for
213*84b82766Smg147109  * the I/O scheduler.
214*84b82766Smg147109  */
215*84b82766Smg147109 struct hsfs_queue {
216*84b82766Smg147109 	/*
217*84b82766Smg147109 	 * A dummy hio holding the LBN of the last read processed. Easy
218*84b82766Smg147109 	 * to use in AVL_NEXT for Circular Look behavior.
219*84b82766Smg147109 	 */
220*84b82766Smg147109 	struct hio	*next;
221*84b82766Smg147109 
222*84b82766Smg147109 	/*
223*84b82766Smg147109 	 * A pre-allocated buf for issuing coalesced reads. The scheduling
224*84b82766Smg147109 	 * function is mostly single threaded by necessity.
225*84b82766Smg147109 	 */
226*84b82766Smg147109 	struct buf	*nbuf;
227*84b82766Smg147109 	kmutex_t	hsfs_queue_lock; /* Protects the AVL trees */
228*84b82766Smg147109 
229*84b82766Smg147109 	/*
230*84b82766Smg147109 	 * Makes most of the scheduling function Single-threaded.
231*84b82766Smg147109 	 */
232*84b82766Smg147109 	kmutex_t	strategy_lock;
233*84b82766Smg147109 	avl_tree_t	read_tree;	 /* Reads ordered by LBN */
234*84b82766Smg147109 	avl_tree_t	deadline_tree;	 /* Reads ordered by timestamp */
235*84b82766Smg147109 	taskq_t		*ra_task;	 /* Read-ahead Q */
236*84b82766Smg147109 	int		max_ra_bytes;	 /* Max read-ahead quantum */
237*84b82766Smg147109 
238*84b82766Smg147109 	/* Device Max Transfer size in DEV_BSIZE */
239*84b82766Smg147109 	uint_t		dev_maxtransfer;
240*84b82766Smg147109 };
241*84b82766Smg147109 
242*84b82766Smg147109 /*
2437c478bd9Sstevel@tonic-gate  * High Sierra filesystem structure.
2447c478bd9Sstevel@tonic-gate  * There is one of these for each mounted High Sierra filesystem.
2457c478bd9Sstevel@tonic-gate  */
2467c478bd9Sstevel@tonic-gate enum hs_vol_type {
247fc1c62b8Sfrankho 	HS_VOL_TYPE_HS = 0, HS_VOL_TYPE_ISO = 1, HS_VOL_TYPE_ISO_V2 = 2,
248fc1c62b8Sfrankho 	HS_VOL_TYPE_JOLIET = 3
2497c478bd9Sstevel@tonic-gate };
2507c478bd9Sstevel@tonic-gate #define	HSFS_MAGIC 0x03095500
2517c478bd9Sstevel@tonic-gate struct hsfs {
2527c478bd9Sstevel@tonic-gate 	struct hsfs	*hsfs_next;	/* ptr to next entry in linked list */
2537c478bd9Sstevel@tonic-gate 	long		hsfs_magic;	/* should be HSFS_MAGIC */
2547c478bd9Sstevel@tonic-gate 	struct vfs	*hsfs_vfs;	/* vfs for this fs */
2557c478bd9Sstevel@tonic-gate 	struct vnode	*hsfs_rootvp;	/* vnode for root of filesystem */
2567c478bd9Sstevel@tonic-gate 	struct vnode	*hsfs_devvp;	/* device mounted on */
257fc1c62b8Sfrankho 	enum hs_vol_type hsfs_vol_type; /* see above */
2587c478bd9Sstevel@tonic-gate 	struct hs_volume hsfs_vol;	/* File Structure Volume Descriptor */
2597c478bd9Sstevel@tonic-gate 	struct ptable	*hsfs_ptbl;	/* pointer to incore Path Table */
2607c478bd9Sstevel@tonic-gate 	int		hsfs_ptbl_size;	/* size of incore path table */
2617c478bd9Sstevel@tonic-gate 	struct ptable_idx *hsfs_ptbl_idx; /* pointer to path table index */
2627c478bd9Sstevel@tonic-gate 	int		hsfs_ptbl_idx_size;	/* no. of path table index */
2637c478bd9Sstevel@tonic-gate 	ulong_t		hsfs_ext_impl;	/* ext. information bits */
2647c478bd9Sstevel@tonic-gate 	ushort_t	hsfs_sua_off;	/* the SUA offset */
2657c478bd9Sstevel@tonic-gate 	ushort_t	hsfs_namemax;	/* maximum file name length */
266fc1c62b8Sfrankho 	ushort_t	hsfs_namelen;	/* "official" max. file name length */
2677c478bd9Sstevel@tonic-gate 	ulong_t		hsfs_err_flags;	/* ways in which fs is non-conformant */
2687c478bd9Sstevel@tonic-gate 	char		*hsfs_fsmnt;	/* name mounted on */
2697c478bd9Sstevel@tonic-gate 	ulong_t		hsfs_flags;	/* hsfs-specific mount flags */
2707c478bd9Sstevel@tonic-gate 	krwlock_t	hsfs_hash_lock;	/* protect hash table & hst_nohsnode */
2717c478bd9Sstevel@tonic-gate 	struct hsnode	*hsfs_hash[HS_HASHSIZE]; /* head of hash lists */
2727c478bd9Sstevel@tonic-gate 	uint32_t	hsfs_nohsnode;	/* no. of allocated hsnodes */
2737c478bd9Sstevel@tonic-gate 	kmutex_t	hsfs_free_lock;	/* protects free list */
2747c478bd9Sstevel@tonic-gate 	struct hsnode	*hsfs_free_f;	/* first entry of free list */
2757c478bd9Sstevel@tonic-gate 	struct hsnode	*hsfs_free_b;	/* last entry of free list */
276*84b82766Smg147109 
277*84b82766Smg147109 	/*
278*84b82766Smg147109 	 * Counters exported through kstats.
279*84b82766Smg147109 	 */
280*84b82766Smg147109 	uint64_t	physical_read_bytes;
281*84b82766Smg147109 	uint64_t	cache_read_pages;
282*84b82766Smg147109 	uint64_t	readahead_bytes;
283*84b82766Smg147109 	uint64_t	coalesced_bytes;
284*84b82766Smg147109 	uint64_t	total_pages_requested;
285*84b82766Smg147109 	kstat_t		*hsfs_kstats;
286*84b82766Smg147109 
287*84b82766Smg147109 	struct hsfs_queue *hqueue;	/* I/O Scheduling parameters */
2887c478bd9Sstevel@tonic-gate };
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate /*
2917c478bd9Sstevel@tonic-gate  * Error types: bit offsets into hsfs_err_flags.
2927c478bd9Sstevel@tonic-gate  * Also serves as index into hsfs_error[], so must be
2937c478bd9Sstevel@tonic-gate  * kept in sync with that data structure.
2947c478bd9Sstevel@tonic-gate  */
2957c478bd9Sstevel@tonic-gate #define	HSFS_ERR_TRAILING_JUNK		0
2967c478bd9Sstevel@tonic-gate #define	HSFS_ERR_LOWER_CASE_NM		1
2977c478bd9Sstevel@tonic-gate #define	HSFS_ERR_BAD_ROOT_DIR		2
2987c478bd9Sstevel@tonic-gate #define	HSFS_ERR_UNSUP_TYPE		3
2997c478bd9Sstevel@tonic-gate #define	HSFS_ERR_BAD_FILE_LEN		4
300fc1c62b8Sfrankho #define	HSFS_ERR_BAD_JOLIET_FILE_LEN	5
301fc1c62b8Sfrankho #define	HSFS_ERR_TRUNC_JOLIET_FILE_LEN	6
302fc1c62b8Sfrankho #define	HSFS_ERR_BAD_DIR_ENTRY		7
303d10b6702Sfrankho #define	HSFS_ERR_NEG_SUA_LEN		8
304d10b6702Sfrankho #define	HSFS_ERR_BAD_SUA_LEN		9
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate #define	HSFS_HAVE_LOWER_CASE(fsp) \
3077c478bd9Sstevel@tonic-gate 	((fsp)->hsfs_err_flags & (1 << HSFS_ERR_LOWER_CASE_NM))
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate /*
3117c478bd9Sstevel@tonic-gate  * File system parameter macros
3127c478bd9Sstevel@tonic-gate  */
3137c478bd9Sstevel@tonic-gate #define	hs_blksize(HSFS, HSP, OFF)	/* file system block size */ \
3147c478bd9Sstevel@tonic-gate 	((HSP)->hs_vn.v_flag & VROOT ? \
3157c478bd9Sstevel@tonic-gate 	    ((OFF) >= \
3167c478bd9Sstevel@tonic-gate 		((HSFS)->hsfs_rdirsec & ~((HSFS)->hsfs_spcl - 1))*HS_SECSIZE ?\
3177c478bd9Sstevel@tonic-gate 		((HSFS)->hsfs_rdirsec & ((HSFS)->hsfs_spcl - 1))*HS_SECSIZE :\
3187c478bd9Sstevel@tonic-gate 		(HSFS)->hsfs_clsize): \
3197c478bd9Sstevel@tonic-gate 	    (HSFS)->hsfs_clsize)
3207c478bd9Sstevel@tonic-gate #define	hs_blkoff(OFF)		/* offset within block */ \
3217c478bd9Sstevel@tonic-gate 	((OFF) & (HS_SECSIZE - 1))
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate /*
3247c478bd9Sstevel@tonic-gate  * Conversion macros
3257c478bd9Sstevel@tonic-gate  */
3267c478bd9Sstevel@tonic-gate #define	VFS_TO_HSFS(VFSP)	((struct hsfs *)(VFSP)->vfs_data)
3277c478bd9Sstevel@tonic-gate #define	HSFS_TO_VFS(FSP)	((FSP)->hsfs_vfs)
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate #define	VTOH(VP)		((struct hsnode *)(VP)->v_data)
3307c478bd9Sstevel@tonic-gate #define	HTOV(HP)		(((HP)->hs_vnode))
3317c478bd9Sstevel@tonic-gate 
3327c478bd9Sstevel@tonic-gate /*
3337c478bd9Sstevel@tonic-gate  * Convert between Logical Block Number and Sector Number.
3347c478bd9Sstevel@tonic-gate  */
3357c478bd9Sstevel@tonic-gate #define	LBN_TO_SEC(lbn, vfsp)	((lbn)>>((struct hsfs *)((vfsp)->vfs_data))->  \
3367c478bd9Sstevel@tonic-gate 				hsfs_vol.lbn_secshift)
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate #define	SEC_TO_LBN(sec, vfsp)	((sec)<<((struct hsfs *)((vfsp)->vfs_data))->  \
3397c478bd9Sstevel@tonic-gate 				hsfs_vol.lbn_secshift)
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate #define	LBN_TO_BYTE(lbn, vfsp)	((lbn)<<((struct hsfs *)((vfsp)->vfs_data))->  \
3427c478bd9Sstevel@tonic-gate 				hsfs_vol.lbn_shift)
3437c478bd9Sstevel@tonic-gate #define	BYTE_TO_LBN(boff, vfsp)	((boff)>>((struct hsfs *)((vfsp)->vfs_data))-> \
3447c478bd9Sstevel@tonic-gate 				hsfs_vol.lbn_shift)
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3477c478bd9Sstevel@tonic-gate }
3487c478bd9Sstevel@tonic-gate #endif
3497c478bd9Sstevel@tonic-gate 
3507c478bd9Sstevel@tonic-gate #endif	/* _SYS_FS_HSFS_NODE_H */
351