xref: /illumos-gate/usr/src/uts/common/sys/fs/udf_inode.h (revision b39a0235a975290e229a1bf1de8031578ab2d98d)
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
5da6c28aaSamw  * Common Development and Distribution License (the "License").
6da6c28aaSamw  * 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 /*
22*b39a0235SMilan Cermak  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
267c478bd9Sstevel@tonic-gate /*	All Rights Reserved */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_SYS_FS_UDF_INODE_H
297c478bd9Sstevel@tonic-gate #define	_SYS_FS_UDF_INODE_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/note.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #define	SUN_IMPL_ID	"*SUN SOLARIS UDF"
387c478bd9Sstevel@tonic-gate #define	SUN_IMPL_ID_LEN	16
397c478bd9Sstevel@tonic-gate #define	SUN_OS_CLASS	4
407c478bd9Sstevel@tonic-gate #define	SUN_OS_ID	2
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * Size of each cluster
447c478bd9Sstevel@tonic-gate  * and bits to be shifted
457c478bd9Sstevel@tonic-gate  */
467c478bd9Sstevel@tonic-gate #define	CLSTR_SIZE	8
477c478bd9Sstevel@tonic-gate #define	CLSTR_MASK	7
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /*
517c478bd9Sstevel@tonic-gate  * enums
527c478bd9Sstevel@tonic-gate  */
537c478bd9Sstevel@tonic-gate enum de_op { DE_CREATE, DE_MKDIR, DE_LINK, DE_RENAME };	/* direnter ops */
547c478bd9Sstevel@tonic-gate enum dr_op { DR_REMOVE, DR_RMDIR, DR_RENAME };		/* dirremove ops */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * The following macros optimize certain frequently calculated
587c478bd9Sstevel@tonic-gate  * quantities by using shifts and masks in place of divisions
597c478bd9Sstevel@tonic-gate  * modulos and multiplications.
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate #define	blkoff(udfvfsp, loc)	/* calculates (loc % udfcfs->udf_lbsize) */ \
637c478bd9Sstevel@tonic-gate 		((loc) & (udfvfsp)->udf_lbmask)
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #define	lblkno(udf_vfsp, loc)	\
667c478bd9Sstevel@tonic-gate 	((int32_t)((loc) / (udf_vfsp)->udf_lbsize))
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #define	fsbtodb(udf, blk)	\
697c478bd9Sstevel@tonic-gate 	((blk) << udf->udf_l2d_shift)
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate struct udf_fid {
737c478bd9Sstevel@tonic-gate 	uint16_t	udfid_len;	/* Length of data */
747c478bd9Sstevel@tonic-gate 	uint16_t	udfid_prn;	/* the partition number of icb */
757c478bd9Sstevel@tonic-gate 	uint32_t	udfid_icb_lbn;	/* file entry block no */
767c478bd9Sstevel@tonic-gate 	uint32_t	udfid_uinq_lo;	/* uniq id to validate the vnode */
777c478bd9Sstevel@tonic-gate };
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate #define	MAXNAMLEN	255
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate struct ud_part {
887c478bd9Sstevel@tonic-gate 	uint16_t	udp_flags;	/* See below */
897c478bd9Sstevel@tonic-gate 	uint16_t	udp_number;	/* partition Number */
907c478bd9Sstevel@tonic-gate 	uint32_t	udp_seqno;	/* to find the prevailaing desc */
917c478bd9Sstevel@tonic-gate 	uint32_t	udp_access;	/* access type */
927c478bd9Sstevel@tonic-gate 	uint32_t	udp_start;	/* Starting block no of partition */
937c478bd9Sstevel@tonic-gate 	uint32_t	udp_length;	/* Lenght of the partition */
947c478bd9Sstevel@tonic-gate 	uint32_t	udp_unall_loc;	/* unall space tbl or bitmap loc */
957c478bd9Sstevel@tonic-gate 	uint32_t	udp_unall_len;	/* unall space tbl or bitmap length */
967c478bd9Sstevel@tonic-gate 	uint32_t	udp_freed_loc;	/* freed space tbl or bitmap loc */
977c478bd9Sstevel@tonic-gate 	uint32_t	udp_freed_len;	/* freed space tbl or bitmap length */
987c478bd9Sstevel@tonic-gate 					/* From part desc */
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 	uint32_t	udp_nfree;	/* No of free blocks in the partition */
1017c478bd9Sstevel@tonic-gate 	uint32_t	udp_nblocks;	/* Total no of blks in the partition */
1027c478bd9Sstevel@tonic-gate 					/* From lvid */
1037c478bd9Sstevel@tonic-gate 	uint32_t	udp_last_alloc;	/* Last allocated space in bitmap */
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate 	int32_t		udp_cache_count;	/* Cache is used for metadata */
1067c478bd9Sstevel@tonic-gate 	daddr_t		udp_cache[CLSTR_SIZE];
1077c478bd9Sstevel@tonic-gate };
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate /*
1107c478bd9Sstevel@tonic-gate  * udp_flags
1117c478bd9Sstevel@tonic-gate  */
1127c478bd9Sstevel@tonic-gate #define	UDP_BITMAPS	0x00
1137c478bd9Sstevel@tonic-gate #define	UDP_SPACETBLS	0x01
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /*
1167c478bd9Sstevel@tonic-gate  * udp_access
1177c478bd9Sstevel@tonic-gate  */
1187c478bd9Sstevel@tonic-gate #define	UDP_MT_RO	0x0001		/* ROM */
1197c478bd9Sstevel@tonic-gate #define	UDP_MT_WO	0x0002		/* WORM */
1207c478bd9Sstevel@tonic-gate #define	UDP_MT_RW	0x0003		/* RW */
1217c478bd9Sstevel@tonic-gate #define	UDP_MT_OW	0x0004		/* OW */
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate #define	MAX_SPM		4
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate struct ud_map {
1287c478bd9Sstevel@tonic-gate 	uint32_t	udm_flags;	/* Flags */
1297c478bd9Sstevel@tonic-gate 	uint16_t	udm_vsn;	/* Volume Sequence Number */
1307c478bd9Sstevel@tonic-gate 	uint16_t	udm_pn;		/* Partition Number */
1317c478bd9Sstevel@tonic-gate 	uint32_t	udm_vat_icb;	/* VAT ICB location */
1327c478bd9Sstevel@tonic-gate 	uint32_t	udm_nent;	/* Number of vat entries */
1337c478bd9Sstevel@tonic-gate 	uint32_t	*udm_count;	/* Number of entrues in each table */
1347c478bd9Sstevel@tonic-gate 	struct buf	**udm_bp;	/* VAT translation tables */
1357c478bd9Sstevel@tonic-gate 	uint32_t	**udm_addr;
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate 	int32_t		udm_plen;
1397c478bd9Sstevel@tonic-gate 	int32_t		udm_nspm;
1407c478bd9Sstevel@tonic-gate 	uint32_t	udm_spsz;
1417c478bd9Sstevel@tonic-gate 	uint32_t	udm_loc[MAX_SPM];
1427c478bd9Sstevel@tonic-gate 	struct buf	*udm_sbp[MAX_SPM];
1437c478bd9Sstevel@tonic-gate 	caddr_t		udm_spaddr[MAX_SPM];
1447c478bd9Sstevel@tonic-gate };
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate /*
1477c478bd9Sstevel@tonic-gate  * udm_flags
1487c478bd9Sstevel@tonic-gate  */
1497c478bd9Sstevel@tonic-gate #define	UDM_MAP_NORM	0x00
1507c478bd9Sstevel@tonic-gate #define	UDM_MAP_VPM	0x01
1517c478bd9Sstevel@tonic-gate #define	UDM_MAP_SPM	0x02
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate struct udf_vfs {
1547c478bd9Sstevel@tonic-gate 	struct vfs	*udf_vfs;	/* Back link */
1557c478bd9Sstevel@tonic-gate 	struct udf_vfs	*udf_next;	/* Chain of udf file-system's */
1567c478bd9Sstevel@tonic-gate 	struct udf_vfs	*udf_wnext;	/* work list link */
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate 	struct buf	*udf_vds;	/* most of the superblock */
1597c478bd9Sstevel@tonic-gate 	struct buf	*udf_iseq;	/* Integrity of the fs */
1607c478bd9Sstevel@tonic-gate 	struct vnode	*udf_root;	/* Root vnode */
1617c478bd9Sstevel@tonic-gate 	struct vnode	*udf_devvp;	/* Block device vnode */
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate 	char		*udf_fsmnt;	/* Path name of directory mouted on */
1647c478bd9Sstevel@tonic-gate 	uint32_t	udf_flags;	/* Flags */
1657c478bd9Sstevel@tonic-gate 	uint32_t	udf_mtype;	/* Media type */
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate 	int32_t		udf_rdclustsz;	/* read cluster size */
1687c478bd9Sstevel@tonic-gate 	int32_t		udf_wrclustsz;	/* write cluster size */
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate 	uint64_t	udf_maxfsize;	/* Max file size allowed in this fs */
1717c478bd9Sstevel@tonic-gate 	int32_t		udf_maxfbits;	/* No of bit's for max file size */
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate 	char		udf_volid[32];	/* volume identifier */
1747c478bd9Sstevel@tonic-gate 					/* from pvd */
1757c478bd9Sstevel@tonic-gate 	uint16_t	udf_tsno;	/* Taken from pvd and */
1767c478bd9Sstevel@tonic-gate 					/* used in making tags */
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate 	int32_t		udf_lbsize;	/* Block size */
1797c478bd9Sstevel@tonic-gate 					/* from lvd */
1807c478bd9Sstevel@tonic-gate 	int32_t		udf_lbmask;	/* udf_lbsize - 1 */
1817c478bd9Sstevel@tonic-gate 	int32_t		udf_l2b_shift;	/* lbsize to bytes */
1827c478bd9Sstevel@tonic-gate 	int32_t		udf_l2d_shift;	/* right shift's to */
1837c478bd9Sstevel@tonic-gate 					/* make lbsize to DEV_BSIZE */
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate 	int32_t		udf_npart;	/* No. of partition's in the volume */
1867c478bd9Sstevel@tonic-gate 					/* restricted to 1 till udf 1.50 */
1877c478bd9Sstevel@tonic-gate 	struct ud_part	*udf_parts;	/* pointer to array of partitions */
1887c478bd9Sstevel@tonic-gate 					/* from part desc's */
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate 	int32_t		udf_nmaps;
1917c478bd9Sstevel@tonic-gate 	struct ud_map	*udf_maps;
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate 	int32_t		udf_fragmented;	/* File System fragmented */
1947c478bd9Sstevel@tonic-gate 	int32_t		udf_mark_bad;	/* force fsck at next mount */
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate 	/*
1977c478bd9Sstevel@tonic-gate 	 * sum of udp_nfree and udp_nblocks
1987c478bd9Sstevel@tonic-gate 	 * from the array udf_parts[0] to udf_parts[udf_nparts - 1]
1997c478bd9Sstevel@tonic-gate 	 */
2007c478bd9Sstevel@tonic-gate 	uint32_t	udf_freeblks;	/* Total udf_lbsize Free Blocks */
2017c478bd9Sstevel@tonic-gate 	uint32_t	udf_totalblks;	/* Total number of Blocks */
2027c478bd9Sstevel@tonic-gate 				/* udf_parts[0].udp_nfree == udf_freespace */
2037c478bd9Sstevel@tonic-gate 				/* till udf 1.50 (DVD-R?) */
2047c478bd9Sstevel@tonic-gate 	uint64_t	udf_maxuniq;	/* Maximum unique ID on the fs */
2057c478bd9Sstevel@tonic-gate 	uint32_t	udf_nfiles;	/* No of files */
2067c478bd9Sstevel@tonic-gate 	uint32_t	udf_ndirs;	/* No of directories */
2077c478bd9Sstevel@tonic-gate 	uint32_t	udf_miread;	/* minimum read revision */
2087c478bd9Sstevel@tonic-gate 	uint32_t	udf_miwrite;	/* minimum write revision */
2097c478bd9Sstevel@tonic-gate 	uint32_t	udf_mawrite;	/* maximum read revision */
2107c478bd9Sstevel@tonic-gate 					/* from lvid */
2117c478bd9Sstevel@tonic-gate 
2127c478bd9Sstevel@tonic-gate 	time_t		udf_time;	/* Last time super block is written */
2137c478bd9Sstevel@tonic-gate 	uint32_t	udf_mod;	/* file system was modified */
2147c478bd9Sstevel@tonic-gate 	uint32_t	udf_clean;	/* state of the file system */
2157c478bd9Sstevel@tonic-gate 	kmutex_t	udf_lock;	/* protects contents */
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate 	kmutex_t	udf_rename_lck;	/* lock for udf_rename */
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate 	/*
2207c478bd9Sstevel@tonic-gate 	 * Have them cached here for fast access
2217c478bd9Sstevel@tonic-gate 	 */
2227c478bd9Sstevel@tonic-gate 	struct pri_vol_desc	*udf_pvd;
2237c478bd9Sstevel@tonic-gate 	struct log_vol_desc	*udf_lvd;
2247c478bd9Sstevel@tonic-gate 	struct log_vol_int_desc *udf_lvid;
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate 	uint32_t		udf_mvds_loc;
2277c478bd9Sstevel@tonic-gate 	uint32_t		udf_mvds_len;
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate 	uint32_t		udf_rvds_loc;
2307c478bd9Sstevel@tonic-gate 	uint32_t		udf_rvds_len;
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate 	uint32_t		udf_iseq_loc;
2337c478bd9Sstevel@tonic-gate 	uint32_t		udf_iseq_len;
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate 	uint16_t		udf_fsd_prn;
2367c478bd9Sstevel@tonic-gate 	uint32_t		udf_fsd_loc;
2377c478bd9Sstevel@tonic-gate 	uint32_t		udf_fsd_len;
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate 	uint16_t		udf_ricb_prn;
2407c478bd9Sstevel@tonic-gate 	uint32_t		udf_ricb_loc;
2417c478bd9Sstevel@tonic-gate 	uint32_t		udf_ricb_len;
2427c478bd9Sstevel@tonic-gate 	daddr_t			udf_root_blkno;
2437c478bd9Sstevel@tonic-gate };
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate #ifndef	__lint
2477c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock,
2487c478bd9Sstevel@tonic-gate 		udf_vfs::udf_fragmented))
2497c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock,
2507c478bd9Sstevel@tonic-gate 		udf_vfs::udf_freeblks udf_vfs::udf_totalblks))
2517c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock,
2527c478bd9Sstevel@tonic-gate 		udf_vfs::udf_maxuniq udf_vfs::udf_nfiles
2537c478bd9Sstevel@tonic-gate 		udf_vfs::udf_ndirs))
2547c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock,
2557c478bd9Sstevel@tonic-gate 		udf_vfs::udf_time
2567c478bd9Sstevel@tonic-gate 		udf_vfs::udf_mod udf_vfs::udf_clean))
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(udf_vfs::udf_nmaps udf_vfs::udf_maps))
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(udf_vfs::udf_mtype
2617c478bd9Sstevel@tonic-gate 		udf_vfs::udf_rdclustsz
2627c478bd9Sstevel@tonic-gate 		udf_vfs::udf_wrclustsz
2637c478bd9Sstevel@tonic-gate 		udf_vfs::udf_maxfsize
2647c478bd9Sstevel@tonic-gate 		udf_vfs::udf_maxfbits
2657c478bd9Sstevel@tonic-gate 		udf_vfs::udf_lbsize
2667c478bd9Sstevel@tonic-gate 		udf_vfs::udf_l2b_shift
2677c478bd9Sstevel@tonic-gate 		udf_vfs::udf_lbmask
2687c478bd9Sstevel@tonic-gate 		udf_vfs::udf_l2d_shift))
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(udf_vfs::udf_pvd
2717c478bd9Sstevel@tonic-gate 		udf_vfs::udf_lvd
2727c478bd9Sstevel@tonic-gate 		udf_vfs::udf_lvid))
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(udf_vfs::udf_mvds_loc
2757c478bd9Sstevel@tonic-gate 		udf_vfs::udf_mvds_len
2767c478bd9Sstevel@tonic-gate 		udf_vfs::udf_iseq_loc
2777c478bd9Sstevel@tonic-gate 		udf_vfs::udf_iseq_len
2787c478bd9Sstevel@tonic-gate 		udf_vfs::udf_fsd_prn
2797c478bd9Sstevel@tonic-gate 		udf_vfs::udf_fsd_loc
2807c478bd9Sstevel@tonic-gate 		udf_vfs::udf_fsd_len
2817c478bd9Sstevel@tonic-gate 		udf_vfs::udf_ricb_prn
2827c478bd9Sstevel@tonic-gate 		udf_vfs::udf_ricb_loc
2837c478bd9Sstevel@tonic-gate 		udf_vfs::udf_ricb_len
2847c478bd9Sstevel@tonic-gate 		udf_vfs::udf_root_blkno))
2857c478bd9Sstevel@tonic-gate 
2867c478bd9Sstevel@tonic-gate _NOTE(READ_ONLY_DATA(ud_part::udp_flags
2877c478bd9Sstevel@tonic-gate 		ud_part::udp_number
2887c478bd9Sstevel@tonic-gate 		ud_part::udp_seqno
2897c478bd9Sstevel@tonic-gate 		ud_part::udp_access
2907c478bd9Sstevel@tonic-gate 		ud_part::udp_start
2917c478bd9Sstevel@tonic-gate 		ud_part::udp_length
2927c478bd9Sstevel@tonic-gate 		ud_part::udp_unall_loc
2937c478bd9Sstevel@tonic-gate 		ud_part::udp_unall_len
2947c478bd9Sstevel@tonic-gate 		ud_part::udp_freed_loc
2957c478bd9Sstevel@tonic-gate 		ud_part::udp_freed_len
2967c478bd9Sstevel@tonic-gate 		ud_part::udp_nblocks))
2977c478bd9Sstevel@tonic-gate 
2987c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock,
2997c478bd9Sstevel@tonic-gate 		ud_part::udp_nfree
3007c478bd9Sstevel@tonic-gate 		ud_part::udp_last_alloc
3017c478bd9Sstevel@tonic-gate 		ud_part::udp_cache_count
3027c478bd9Sstevel@tonic-gate 		ud_part::udp_cache))
3037c478bd9Sstevel@tonic-gate #endif
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate /*
3067c478bd9Sstevel@tonic-gate  * udf_mtype
3077c478bd9Sstevel@tonic-gate  */
3087c478bd9Sstevel@tonic-gate #define	UDF_MT_RO	UDP_MT_RO		/* ROM */
3097c478bd9Sstevel@tonic-gate #define	UDF_MT_WO	UDP_MT_OW		/* WORM */
3107c478bd9Sstevel@tonic-gate #define	UDF_MT_RW	UDP_MT_RW		/* RW */
3117c478bd9Sstevel@tonic-gate #define	UDF_MT_OW	UDP_MT_OW		/* OW */
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate /*
3147c478bd9Sstevel@tonic-gate  * udf_flags
3157c478bd9Sstevel@tonic-gate  */
3167c478bd9Sstevel@tonic-gate #define	UDF_FL_RDONLY	0x0001		/* file system is read only */
3177c478bd9Sstevel@tonic-gate #define	UDF_FL_RW	0x0002		/* file system is read write */
3187c478bd9Sstevel@tonic-gate 
3197c478bd9Sstevel@tonic-gate /*
3207c478bd9Sstevel@tonic-gate  * udf_clean
3217c478bd9Sstevel@tonic-gate  */
3227c478bd9Sstevel@tonic-gate #define	UDF_DIRTY	0x00
3237c478bd9Sstevel@tonic-gate #define	UDF_CLEAN	0x01
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate #define	RD_CLUSTSZ(ip)		((ip)->i_udf->udf_rdclustsz)
3277c478bd9Sstevel@tonic-gate #define	WR_CLUSTSZ(ip)		((ip)->i_udf->udf_wrclustsz)
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate /*
3307c478bd9Sstevel@tonic-gate  * Size can be a 64-bit value and therefore we sign extend fs_bmask
3317c478bd9Sstevel@tonic-gate  * to a 64-bit value too so that the higher 32 bits are masked
3327c478bd9Sstevel@tonic-gate  * properly. Note that the type of fs_bmask has to be signed. Otherwise
3337c478bd9Sstevel@tonic-gate  * compiler will set the higher 32 bits as zero and we don't want
3347c478bd9Sstevel@tonic-gate  * this to happen.
3357c478bd9Sstevel@tonic-gate  */
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate #ifdef	UNDEF
3387c478bd9Sstevel@tonic-gate #define	blkroundup(fs, size)	/* calculates roundup(size, fs->fs_bsize) */ \
3397c478bd9Sstevel@tonic-gate 	(((size) + (fs)->udf_lbsize - 1) & (offset_t)(fs)->udf_lbmask)
3407c478bd9Sstevel@tonic-gate #endif
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate #define	blkroundup(fs, size)	/* calculates roundup(size, fs->fs_bsize) */ \
3437c478bd9Sstevel@tonic-gate 	(((size) + (fs)->udf_lbmask) & (offset_t)(~(fs)->udf_lbmask))
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate #define	blksize(fs)	(fs->udf_lbsize)
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate /*
3497c478bd9Sstevel@tonic-gate  * Convert between inode pointers and vnode pointers
3507c478bd9Sstevel@tonic-gate  */
3517c478bd9Sstevel@tonic-gate #define	VTOI(VP)	((struct ud_inode *)(VP)->v_data)
3527c478bd9Sstevel@tonic-gate #define	ITOV(IP)	((IP)->i_vnode)
3537c478bd9Sstevel@tonic-gate #define	i_vfs		i_vnode->v_vfsp
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate struct icb_ext {
3567c478bd9Sstevel@tonic-gate 	uint16_t	ib_flags;
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate 	/* Direct Entry will go here */
3597c478bd9Sstevel@tonic-gate 	uint16_t	ib_prn;		/* partition reference number */
3607c478bd9Sstevel@tonic-gate 	uint32_t	ib_block;	/* block offset into partition */
3617c478bd9Sstevel@tonic-gate 	uint64_t	ib_offset;	/* offset into the file bytes */
3627c478bd9Sstevel@tonic-gate 	int32_t		ib_count;	/* No of bytes in current ext */
3637c478bd9Sstevel@tonic-gate 	uint32_t	ib_marker1;	/* 0xAAAAAAAA */
3647c478bd9Sstevel@tonic-gate 	uint32_t	ib_marker2;	/* 0xBBBBBBBB */
3657c478bd9Sstevel@tonic-gate };
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate /* ib_flags */
3697c478bd9Sstevel@tonic-gate #define	IB_UN_REC	0x1		/* The entry is not allocated */
3707c478bd9Sstevel@tonic-gate #define	IB_UN_RE_AL	0x2		/* The entry is not recorded */
3717c478bd9Sstevel@tonic-gate 					/* and not unallocated */
3727c478bd9Sstevel@tonic-gate #define	IB_CON		0x3		/* Continuation entry */
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate #define	IB_MASK		0x3
3757c478bd9Sstevel@tonic-gate 
3767c478bd9Sstevel@tonic-gate #define	IB_ALLOCATED(flags)	\
3777c478bd9Sstevel@tonic-gate 	(((flags) & IB_MASK) != IB_UN_RE_AL)
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate #define	EXT_PER_MALLOC	8
3807c478bd9Sstevel@tonic-gate 
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate struct ud_inode {
3837c478bd9Sstevel@tonic-gate 	struct ud_inode	*i_forw;
3847c478bd9Sstevel@tonic-gate 	struct ud_inode	*i_back;
3857c478bd9Sstevel@tonic-gate 	struct ud_inode	*i_freef;
3867c478bd9Sstevel@tonic-gate 	struct ud_inode	*i_freeb;
3877c478bd9Sstevel@tonic-gate 
3887c478bd9Sstevel@tonic-gate 	struct vnode	*i_vnode;	/* vnode associated with this inode */
3897c478bd9Sstevel@tonic-gate 	struct vnode	*i_devvp;	/* vnode for block I/O */
3907c478bd9Sstevel@tonic-gate 	struct udf_vfs	*i_udf;		/* incore fs associated with inode */
3917c478bd9Sstevel@tonic-gate 	krwlock_t	i_rwlock;	/* serializes write/setattr requests */
3927c478bd9Sstevel@tonic-gate 	krwlock_t	i_contents;	/* protects (most of) inode contents */
3937c478bd9Sstevel@tonic-gate 	dev_t		i_dev;		/* device where inode resides */
3947c478bd9Sstevel@tonic-gate 	u_offset_t	i_diroff;	/* last loc for fast name lookup */
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate 	daddr_t		i_icb_lbano;	/* Loc of file icb on disk */
3977c478bd9Sstevel@tonic-gate 	uint16_t	i_icb_prn;	/* partition reference number */
3987c478bd9Sstevel@tonic-gate 	kcondvar_t	i_wrcv;		/* sleep/wakeup for write throttle */
3997c478bd9Sstevel@tonic-gate 	uint32_t	i_flag;
4007c478bd9Sstevel@tonic-gate 	uint32_t	i_icb_block;
4017c478bd9Sstevel@tonic-gate 
4027c478bd9Sstevel@tonic-gate 	int16_t		i_astrat;	/* ICB strategy */
4037c478bd9Sstevel@tonic-gate 	int16_t		i_desc_type;	/* Allocation desc type */
4047c478bd9Sstevel@tonic-gate 	int32_t		i_ext_count;	/* Number of extents allocated */
4057c478bd9Sstevel@tonic-gate 	int32_t		i_ext_used;	/* Number of extents used */
4067c478bd9Sstevel@tonic-gate 	struct icb_ext	*i_ext;		/* array of extents */
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate 	kmutex_t	i_con_lock;
4097c478bd9Sstevel@tonic-gate 	struct icb_ext	*i_con;
4107c478bd9Sstevel@tonic-gate 	int32_t		i_con_count;
4117c478bd9Sstevel@tonic-gate 	int32_t		i_con_used;
4127c478bd9Sstevel@tonic-gate 	int32_t		i_con_read;
4137c478bd9Sstevel@tonic-gate 
4147c478bd9Sstevel@tonic-gate 	uint32_t	i_cur_max_ext;
4157c478bd9Sstevel@tonic-gate 	vtype_t		i_type;		/* File type */
4167c478bd9Sstevel@tonic-gate 	uint16_t	i_char;		/* File characteristics */
4177c478bd9Sstevel@tonic-gate 	uint16_t	i_perm;		/* File permissions */
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate 	uid_t		i_uid;		/* File owner's uid */
4207c478bd9Sstevel@tonic-gate 	gid_t		i_gid;		/* File owner's gid */
4217c478bd9Sstevel@tonic-gate 	uint32_t	i_nlink;	/* number of links to file */
4227c478bd9Sstevel@tonic-gate 	uint32_t	i_maxent;	/* Max entries that are recorded */
4237c478bd9Sstevel@tonic-gate 	u_offset_t	i_size;		/* File size in bytes */
4247c478bd9Sstevel@tonic-gate 	uint64_t	i_lbr;		/* Logical blocks recorded */
4257c478bd9Sstevel@tonic-gate 	uint64_t	i_uniqid;	/* from the file entry */
4267c478bd9Sstevel@tonic-gate 
4277c478bd9Sstevel@tonic-gate 	timespec32_t	i_atime;
4287c478bd9Sstevel@tonic-gate 	timespec32_t	i_mtime;
4297c478bd9Sstevel@tonic-gate 	timespec32_t	i_ctime;
4307c478bd9Sstevel@tonic-gate 
4317c478bd9Sstevel@tonic-gate 	size_t		i_delaylen;	/* delayed writes, units=bytes */
4327c478bd9Sstevel@tonic-gate 	offset_t	i_delayoff;	/* where we started delaying */
4337c478bd9Sstevel@tonic-gate 	offset_t	i_nextrio;	/* where to start the next clust */
4347c478bd9Sstevel@tonic-gate 	uint64_t	i_writes;	/* remaining bytes in write q */
4357c478bd9Sstevel@tonic-gate 	kmutex_t	i_tlock;	/* protects time fields, i_flag */
4367c478bd9Sstevel@tonic-gate 	major_t		i_major;
4377c478bd9Sstevel@tonic-gate 	minor_t		i_minor;
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate 	uint32_t	i_marker1;	/* 0xAAAAAAAA */
4407c478bd9Sstevel@tonic-gate 	uint32_t	i_seq;		/* sequence number attribute */
4417c478bd9Sstevel@tonic-gate 	offset_t	i_nextr;	/* next byte read offset (read-ahead) */
4427c478bd9Sstevel@tonic-gate 	long		i_mapcnt;	/* number of mappings of pages */
4437c478bd9Sstevel@tonic-gate 	int		*i_map;		/* block list for the file */
4447c478bd9Sstevel@tonic-gate 	dev_t		i_rdev;		/* INCORE rdev from */
4457c478bd9Sstevel@tonic-gate 	uint32_t	i_marker2;	/* 0xBBBBBBBB */
4467c478bd9Sstevel@tonic-gate 	uint32_t	i_data_off;	/* Data offset into embedded file */
4477c478bd9Sstevel@tonic-gate 	uint32_t	i_max_emb;
4487c478bd9Sstevel@tonic-gate 	uint32_t	i_marker3;
4497c478bd9Sstevel@tonic-gate };
4507c478bd9Sstevel@tonic-gate 
4517c478bd9Sstevel@tonic-gate 
4527c478bd9Sstevel@tonic-gate #ifndef	__lint
4537c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_astrat))
4547c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_desc_type))
4557c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_ext_count))
4567c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_ext_used))
4577c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_ext))
4587c478bd9Sstevel@tonic-gate 
4597c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_type))
4607c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_char))
4617c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_perm))
4627c478bd9Sstevel@tonic-gate 
4637c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_uid))
4647c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_gid))
4657c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_nlink))
4667c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_size))
4677c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_lbr))
4687c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_uniqid))
4697c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_major))
4707c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_minor))
4717c478bd9Sstevel@tonic-gate 
4727c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_atime))
4737c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_mtime))
4747c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_ctime))
4757c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_delayoff))
4767c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_delaylen))
4777c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_nextrio))
4787c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_writes))
4797c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_flag))
4807c478bd9Sstevel@tonic-gate 
4817c478bd9Sstevel@tonic-gate _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents,
4827c478bd9Sstevel@tonic-gate 		icb_ext::ib_flags icb_ext::ib_prn
4837c478bd9Sstevel@tonic-gate 		icb_ext::ib_block
4847c478bd9Sstevel@tonic-gate 		icb_ext::ib_count icb_ext::ib_offset))
4857c478bd9Sstevel@tonic-gate #endif
4867c478bd9Sstevel@tonic-gate 
4877c478bd9Sstevel@tonic-gate 
4887c478bd9Sstevel@tonic-gate /* i_flag */
4897c478bd9Sstevel@tonic-gate #define	IUPD		0x0001		/* file has been modified */
4907c478bd9Sstevel@tonic-gate #define	IACC		0x0002		/* inode access time to be updated */
4917c478bd9Sstevel@tonic-gate #define	IMOD		0x0004		/* inode has been modified */
4927c478bd9Sstevel@tonic-gate #define	ICHG		0x0008		/* inode has been changed */
4937c478bd9Sstevel@tonic-gate #define	INOACC		0x0010		/* no access time update in getpage */
4947c478bd9Sstevel@tonic-gate #define	IMODTIME	0x0020		/* mod time already set */
4957c478bd9Sstevel@tonic-gate #define	IREF		0x0040		/* inode is being referenced */
4967c478bd9Sstevel@tonic-gate #define	ISYNC		0x0080		/* do all allocation synchronously */
4977c478bd9Sstevel@tonic-gate #define	IMODACC		0x0200		/* only access time changed; */
4987c478bd9Sstevel@tonic-gate #define	IATTCHG		0x0400		/* only size/blocks have changed */
4997c478bd9Sstevel@tonic-gate #define	IBDWRITE	0x0800		/* the inode has been scheduled for */
5007c478bd9Sstevel@tonic-gate 					/* write operation asynchrously */
5017c478bd9Sstevel@tonic-gate 
5027c478bd9Sstevel@tonic-gate /*
5037c478bd9Sstevel@tonic-gate  * i_char
5047c478bd9Sstevel@tonic-gate  * Do not change used by MANDLOCK macro in vnode.h
5057c478bd9Sstevel@tonic-gate  */
5067c478bd9Sstevel@tonic-gate #define	ISUID		VSUID		/* set user id on execution */
5077c478bd9Sstevel@tonic-gate #define	ISGID		VSGID		/* set group id on execution */
5087c478bd9Sstevel@tonic-gate #define	ISVTX		VSVTX		/* save swapped text even after use */
5097c478bd9Sstevel@tonic-gate /*
5107c478bd9Sstevel@tonic-gate  * Setuid	--S---------
5117c478bd9Sstevel@tonic-gate  * Setgid	-G----------
5127c478bd9Sstevel@tonic-gate  * SaveTXT	T-----------
5137c478bd9Sstevel@tonic-gate  */
5147c478bd9Sstevel@tonic-gate 
5157c478bd9Sstevel@tonic-gate /* i_perm */
5167c478bd9Sstevel@tonic-gate #define	IEXEC		0x0400		/* read, write, execute permissions */
5177c478bd9Sstevel@tonic-gate #define	IWRITE		0x0800
5187c478bd9Sstevel@tonic-gate #define	IREAD		0x1000
5197c478bd9Sstevel@tonic-gate #define	IATTR		0x2000
5207c478bd9Sstevel@tonic-gate #define	IDELE		0x4000
5217c478bd9Sstevel@tonic-gate 
5227c478bd9Sstevel@tonic-gate #define	UP_MASK		0x1CE7
5237c478bd9Sstevel@tonic-gate #define	VA2UD_PERM(perm)	\
5247c478bd9Sstevel@tonic-gate 	(((perm) & 0x7) | (((perm) & 0x38) << 2) | (((perm) & 0x1C0) << 4))
5257c478bd9Sstevel@tonic-gate #define	UD2VA_PERM(perm)	\
5267c478bd9Sstevel@tonic-gate 	(((perm) & 0x7) | (((perm) & 0xE0) >> 2) | (((perm) & 0x1C00) >> 4))
5277c478bd9Sstevel@tonic-gate 
5287c478bd9Sstevel@tonic-gate /*
5297c478bd9Sstevel@tonic-gate  * Permissions
5307c478bd9Sstevel@tonic-gate  * Other	-----------DARWX
5317c478bd9Sstevel@tonic-gate  * Group	------DARWX-----
5327c478bd9Sstevel@tonic-gate  * Owner	-DARWX----------
5337c478bd9Sstevel@tonic-gate  */
5347c478bd9Sstevel@tonic-gate #define	UD_DPERM2UPERM(dperm)	((((dperm) >> 4) & 0x1C0) |	\
5357c478bd9Sstevel@tonic-gate 					(((dperm) >> 2) & 0x38) |	\
5367c478bd9Sstevel@tonic-gate 					((dperm) & 0x7))
5377c478bd9Sstevel@tonic-gate #define	UD_UPERM2DPERM(uperm)	((((uperm) & 0x1C0) << 4) |	\
5387c478bd9Sstevel@tonic-gate 					(((uperm) & 0x38) << 2) |	\
5397c478bd9Sstevel@tonic-gate 					((uperm) & 0x7))
5407c478bd9Sstevel@tonic-gate 
5417c478bd9Sstevel@tonic-gate 
5427c478bd9Sstevel@tonic-gate /* specify how the inode info is written in ud_syncip() */
5437c478bd9Sstevel@tonic-gate #define	I_SYNC	1	/* wait for the inode written to disk */
5447c478bd9Sstevel@tonic-gate #define	I_DSYNC	2	/* wait for the inode written to disk */
5457c478bd9Sstevel@tonic-gate 			/* only if IATTCHG is set */
5467c478bd9Sstevel@tonic-gate #define	I_ASYNC	0	/* don't wait for the inode written */
5477c478bd9Sstevel@tonic-gate 
5487c478bd9Sstevel@tonic-gate 
5497c478bd9Sstevel@tonic-gate #define	UD_HASH_SZ	512
5507c478bd9Sstevel@tonic-gate 
5517c478bd9Sstevel@tonic-gate #if ((UD_HASH_SZ & (UD_HASH_SZ - 1)) == 0)
5527c478bd9Sstevel@tonic-gate #define	UD_INOHASH(dev, bno)	(hash2ints((int)dev, (int)bno) & UD_HASH_SZ - 1)
5537c478bd9Sstevel@tonic-gate #else
5547c478bd9Sstevel@tonic-gate #define	UD_INOHASH(dev, bno)	(hash2ints((int)dev, (int)bno) % UD_HASH_SZ)
5557c478bd9Sstevel@tonic-gate #endif
5567c478bd9Sstevel@tonic-gate 
5577c478bd9Sstevel@tonic-gate union ihead {
5587c478bd9Sstevel@tonic-gate 	union	ihead		*ih_head[2];
5597c478bd9Sstevel@tonic-gate 	struct	ud_inode	*ih_chain[2];
5607c478bd9Sstevel@tonic-gate };
5617c478bd9Sstevel@tonic-gate 
5627c478bd9Sstevel@tonic-gate 
5637c478bd9Sstevel@tonic-gate #define	IMARK(ip) ud_imark(ip)
5647c478bd9Sstevel@tonic-gate #define	ITIMES_NOLOCK(ip) ud_itimes_nolock(ip)
5657c478bd9Sstevel@tonic-gate 
5667c478bd9Sstevel@tonic-gate #define	ITIMES(ip) { \
5677c478bd9Sstevel@tonic-gate 	mutex_enter(&(ip)->i_tlock); \
5687c478bd9Sstevel@tonic-gate 	ITIMES_NOLOCK(ip); \
5697c478bd9Sstevel@tonic-gate 	mutex_exit(&(ip)->i_tlock); \
5707c478bd9Sstevel@tonic-gate }
5717c478bd9Sstevel@tonic-gate 
5727c478bd9Sstevel@tonic-gate #define	ESAME	(-1)		/* trying to rename linked files (special) */
5737c478bd9Sstevel@tonic-gate 
5747c478bd9Sstevel@tonic-gate #define	UDF_HOLE	(daddr32_t)-1	/* value used when no block allocated */
5757c478bd9Sstevel@tonic-gate 
5767c478bd9Sstevel@tonic-gate 
5777c478bd9Sstevel@tonic-gate extern int32_t ud_trace;
5787c478bd9Sstevel@tonic-gate #define	ud_printf(xyz)	\
5797c478bd9Sstevel@tonic-gate 		if (ud_trace) {	\
5807c478bd9Sstevel@tonic-gate 			cmn_err(CE_NOTE, xyz);	\
5817c478bd9Sstevel@tonic-gate 		}
5827c478bd9Sstevel@tonic-gate 
5837c478bd9Sstevel@tonic-gate #ifndef	__lint
5847c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Unshared data",
5857c478bd9Sstevel@tonic-gate 		buf
5867c478bd9Sstevel@tonic-gate 		dirent64
5877c478bd9Sstevel@tonic-gate 		fid
5887c478bd9Sstevel@tonic-gate 		flock64
5897c478bd9Sstevel@tonic-gate 		statvfs64
5907c478bd9Sstevel@tonic-gate 		timespec32
5917c478bd9Sstevel@tonic-gate 		udf_fid
5927c478bd9Sstevel@tonic-gate 		uio
5937c478bd9Sstevel@tonic-gate 		vattr
5947c478bd9Sstevel@tonic-gate 		vfs
5957c478bd9Sstevel@tonic-gate 		vnode))
5967c478bd9Sstevel@tonic-gate 
5977c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Unshared data",
5987c478bd9Sstevel@tonic-gate 		file_entry
5997c478bd9Sstevel@tonic-gate 		file_id
6007c478bd9Sstevel@tonic-gate 		icb_tag
6017c478bd9Sstevel@tonic-gate 		indirect_entry
6027c478bd9Sstevel@tonic-gate 		log_vol_int_desc
6037c478bd9Sstevel@tonic-gate 		long_ad
6047c478bd9Sstevel@tonic-gate 		lvid_iu
6057c478bd9Sstevel@tonic-gate 		regid
6067c478bd9Sstevel@tonic-gate 		short_ad
6077c478bd9Sstevel@tonic-gate 		tag
6087c478bd9Sstevel@tonic-gate 		tstamp))
6097c478bd9Sstevel@tonic-gate 
6107c478bd9Sstevel@tonic-gate _NOTE(LOCK_ORDER(ud_inode::i_rwlock
6117c478bd9Sstevel@tonic-gate 		ud_inode::i_contents
6127c478bd9Sstevel@tonic-gate 		ud_inode::i_tlock))
6137c478bd9Sstevel@tonic-gate #endif
6147c478bd9Sstevel@tonic-gate 
6157c478bd9Sstevel@tonic-gate /*
6167c478bd9Sstevel@tonic-gate  * udf_vfsops.c
6177c478bd9Sstevel@tonic-gate  */
6187c478bd9Sstevel@tonic-gate void		ud_update_superblock(struct vfs *);
6197c478bd9Sstevel@tonic-gate 
6207c478bd9Sstevel@tonic-gate 
6217c478bd9Sstevel@tonic-gate /*
6227c478bd9Sstevel@tonic-gate  * udf_vnops.c
6237c478bd9Sstevel@tonic-gate  */
6247c478bd9Sstevel@tonic-gate int32_t		ud_rdwri(enum uio_rw, int32_t, struct ud_inode *, caddr_t,
6257c478bd9Sstevel@tonic-gate 			int32_t, offset_t, enum uio_seg, int32_t *,
6267c478bd9Sstevel@tonic-gate 			struct cred *cr);
6277c478bd9Sstevel@tonic-gate int32_t		ud_putapage(struct vnode *, page_t *, u_offset_t *,
6287c478bd9Sstevel@tonic-gate 			size_t *, int32_t, struct cred *);
6297c478bd9Sstevel@tonic-gate 
6307c478bd9Sstevel@tonic-gate 
6317c478bd9Sstevel@tonic-gate /*
6327c478bd9Sstevel@tonic-gate  * udf_inode.c
6337c478bd9Sstevel@tonic-gate  */
634*b39a0235SMilan Cermak int32_t	ud_iget(struct vfs *, uint16_t, uint32_t, struct ud_inode **,
635*b39a0235SMilan Cermak     struct buf *, struct cred *);
6367c478bd9Sstevel@tonic-gate void	ud_iinactive(struct ud_inode *, struct cred *);
6377c478bd9Sstevel@tonic-gate void	ud_iupdat(struct ud_inode *, int32_t);
638*b39a0235SMilan Cermak int32_t	ud_itrunc(struct ud_inode *, u_offset_t, int32_t, struct cred *);
639*b39a0235SMilan Cermak int32_t	ud_iaccess(struct ud_inode *, int32_t, struct cred *, int dolock);
6407c478bd9Sstevel@tonic-gate int32_t	ud_iflush(struct vfs *);
6417c478bd9Sstevel@tonic-gate void	ud_imark(struct ud_inode *);
6427c478bd9Sstevel@tonic-gate void	ud_itimes_nolock(struct ud_inode *);
6437c478bd9Sstevel@tonic-gate void	ud_delcache(struct ud_inode *);
6447c478bd9Sstevel@tonic-gate void	ud_idrop(struct ud_inode *);
6457c478bd9Sstevel@tonic-gate void	ud_init_inodes(void);
6467c478bd9Sstevel@tonic-gate 
6477c478bd9Sstevel@tonic-gate 
6487c478bd9Sstevel@tonic-gate /*
6497c478bd9Sstevel@tonic-gate  * udf_alloc.c
6507c478bd9Sstevel@tonic-gate  */
6517c478bd9Sstevel@tonic-gate int32_t		ud_alloc_space(struct vfs *, uint16_t, uint32_t,
6527c478bd9Sstevel@tonic-gate 			uint32_t, uint32_t *, uint32_t *, int32_t, int32_t);
6537c478bd9Sstevel@tonic-gate void		ud_free_space(struct vfs *, uint16_t, uint32_t, uint32_t);
6547c478bd9Sstevel@tonic-gate int32_t		ud_ialloc(struct ud_inode *, struct ud_inode **,
6557c478bd9Sstevel@tonic-gate 			struct vattr *, struct cred *);
6567c478bd9Sstevel@tonic-gate void		ud_ifree(struct ud_inode *, vtype_t);
6577c478bd9Sstevel@tonic-gate int32_t		ud_freesp(struct vnode *, struct flock64 *, int32_t,
6587c478bd9Sstevel@tonic-gate 			struct cred *);
6597c478bd9Sstevel@tonic-gate int32_t		ud_alloc_from_cache(struct udf_vfs *, struct ud_part *,
6607c478bd9Sstevel@tonic-gate 			uint32_t *);
6617c478bd9Sstevel@tonic-gate int32_t		ud_release_cache(struct udf_vfs *);
6627c478bd9Sstevel@tonic-gate 
6637c478bd9Sstevel@tonic-gate 
6647c478bd9Sstevel@tonic-gate /*
6657c478bd9Sstevel@tonic-gate  * udf_subr.c
6667c478bd9Sstevel@tonic-gate  */
6677c478bd9Sstevel@tonic-gate void		ud_vfs_add(struct udf_vfs *);
6687c478bd9Sstevel@tonic-gate void		ud_vfs_remove(struct udf_vfs *);
6697c478bd9Sstevel@tonic-gate daddr_t		ud_xlate_to_daddr(struct udf_vfs *, uint16_t,
6707c478bd9Sstevel@tonic-gate 			uint32_t, int32_t, uint32_t *);
6717c478bd9Sstevel@tonic-gate int32_t		ud_ip_off2bno(struct ud_inode *, uint32_t, uint32_t *);
6727c478bd9Sstevel@tonic-gate void		ud_dtime2utime(struct timespec32 *, struct tstamp const *);
6737c478bd9Sstevel@tonic-gate void		ud_utime2dtime(struct timespec32 const *, struct tstamp *);
6747c478bd9Sstevel@tonic-gate int32_t		ud_syncip(struct ud_inode *, int32_t, int32_t);
6757c478bd9Sstevel@tonic-gate void		ud_update(int32_t);
6767c478bd9Sstevel@tonic-gate int32_t		ud_fbwrite(struct fbuf *, struct ud_inode *);
6777c478bd9Sstevel@tonic-gate void		ud_sbwrite(struct udf_vfs *);
6787c478bd9Sstevel@tonic-gate int32_t		ud_sync_indir(struct ud_inode *);
6797c478bd9Sstevel@tonic-gate void		ud_update_regid(struct regid *);
6807c478bd9Sstevel@tonic-gate int32_t		ud_read_icb_till_off(struct ud_inode *, u_offset_t);
6817c478bd9Sstevel@tonic-gate void		ud_make_tag(struct udf_vfs *, struct tag *,
6827c478bd9Sstevel@tonic-gate 			uint16_t, uint32_t, uint16_t);
6837c478bd9Sstevel@tonic-gate int32_t		ud_make_dev_spec_ear(struct dev_spec_ear *, major_t, minor_t);
6847c478bd9Sstevel@tonic-gate int32_t		ud_make_ftimes_ear(struct ftimes_ear *,
6857c478bd9Sstevel@tonic-gate 			int32_t, struct timespec32 *);
6867c478bd9Sstevel@tonic-gate int32_t		ud_get_next_fid(struct ud_inode *, struct fbuf **, uint32_t,
6877c478bd9Sstevel@tonic-gate 			struct file_id **, uint8_t **, uint8_t *);
6887c478bd9Sstevel@tonic-gate int32_t		ud_verify_tag_and_desc(struct tag *, uint16_t, uint32_t,
6897c478bd9Sstevel@tonic-gate 		int32_t, int32_t);
6907c478bd9Sstevel@tonic-gate uint16_t	ud_crc(uint8_t *, int32_t);
6917c478bd9Sstevel@tonic-gate int32_t		ud_compressunicode(int32_t, int32_t, uint16_t *, uint8_t *);
6927c478bd9Sstevel@tonic-gate uint32_t	ud_check_te_unrec(struct udf_vfs *, caddr_t, uint32_t);
6937c478bd9Sstevel@tonic-gate int32_t		ud_compress(int32_t, int32_t *, uint8_t *, uint8_t *);
6947c478bd9Sstevel@tonic-gate int32_t		ud_uncompress(int32_t, int32_t *, uint8_t *, uint8_t *);
6957c478bd9Sstevel@tonic-gate struct buf	*ud_bread(dev_t, daddr_t, long);
6967c478bd9Sstevel@tonic-gate int		ud_sticky_remove_access(struct ud_inode *, struct ud_inode *,
6977c478bd9Sstevel@tonic-gate 			struct cred *);
6987c478bd9Sstevel@tonic-gate 
6997c478bd9Sstevel@tonic-gate 
7007c478bd9Sstevel@tonic-gate /*
7017c478bd9Sstevel@tonic-gate  * udf_dir.c
7027c478bd9Sstevel@tonic-gate  */
7037c478bd9Sstevel@tonic-gate int32_t		ud_dirlook(struct ud_inode *,
7047c478bd9Sstevel@tonic-gate 			char *, struct ud_inode **, struct cred *, int32_t);
7057c478bd9Sstevel@tonic-gate int32_t		ud_direnter(struct ud_inode *, char *, enum de_op,
7067c478bd9Sstevel@tonic-gate 			struct ud_inode *, struct ud_inode *, struct vattr *,
707da6c28aaSamw 			struct ud_inode **, struct cred *, caller_context_t *);
7087c478bd9Sstevel@tonic-gate int32_t		ud_dirremove(struct ud_inode *,
7097c478bd9Sstevel@tonic-gate 			char *, struct ud_inode *, struct vnode *,
710da6c28aaSamw 			enum dr_op, struct cred *, caller_context_t *);
7117c478bd9Sstevel@tonic-gate 
7127c478bd9Sstevel@tonic-gate 
7137c478bd9Sstevel@tonic-gate /*
7147c478bd9Sstevel@tonic-gate  * udf_bmap.c
7157c478bd9Sstevel@tonic-gate  */
7167c478bd9Sstevel@tonic-gate int32_t		ud_bmap_has_holes(struct ud_inode *);
7177c478bd9Sstevel@tonic-gate int32_t		ud_bmap_write(struct ud_inode *, u_offset_t,
7187c478bd9Sstevel@tonic-gate 			int, int32_t, struct cred *);
7197c478bd9Sstevel@tonic-gate int32_t		ud_bmap_read(struct ud_inode *, u_offset_t,
7207c478bd9Sstevel@tonic-gate 			daddr_t *, int32_t *);
7217c478bd9Sstevel@tonic-gate void		ud_insert_new_ext(struct ud_inode *,
7227c478bd9Sstevel@tonic-gate 			int32_t, struct icb_ext *);
7237c478bd9Sstevel@tonic-gate int32_t		ud_alloc_and_make_ext(struct ud_inode *, int32_t);
7247c478bd9Sstevel@tonic-gate int32_t		ud_create_new_icb(struct ud_inode *);
7257c478bd9Sstevel@tonic-gate void		ud_append_new_ext(struct ud_inode *, uint16_t,
7267c478bd9Sstevel@tonic-gate 			u_offset_t, uint32_t, uint16_t, uint32_t);
7277c478bd9Sstevel@tonic-gate 
7287c478bd9Sstevel@tonic-gate 
7297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
7307c478bd9Sstevel@tonic-gate }
7317c478bd9Sstevel@tonic-gate #endif
7327c478bd9Sstevel@tonic-gate 
7337c478bd9Sstevel@tonic-gate #endif	/* _SYS_FS_UDF_INODE_H */
734