xref: /titanic_50/usr/src/uts/common/sys/fs/udf_inode.h (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	All Rights Reserved */
29 
30 #ifndef	_SYS_FS_UDF_INODE_H
31 #define	_SYS_FS_UDF_INODE_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #include <sys/note.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 #define	SUN_IMPL_ID	"*SUN SOLARIS UDF"
42 #define	SUN_IMPL_ID_LEN	16
43 #define	SUN_OS_CLASS	4
44 #define	SUN_OS_ID	2
45 
46 /*
47  * Size of each cluster
48  * and bits to be shifted
49  */
50 #define	CLSTR_SIZE	8
51 #define	CLSTR_MASK	7
52 
53 
54 /*
55  * enums
56  */
57 enum de_op { DE_CREATE, DE_MKDIR, DE_LINK, DE_RENAME };	/* direnter ops */
58 enum dr_op { DR_REMOVE, DR_RMDIR, DR_RENAME };		/* dirremove ops */
59 
60 /*
61  * The following macros optimize certain frequently calculated
62  * quantities by using shifts and masks in place of divisions
63  * modulos and multiplications.
64  */
65 
66 #define	blkoff(udfvfsp, loc)	/* calculates (loc % udfcfs->udf_lbsize) */ \
67 		((loc) & (udfvfsp)->udf_lbmask)
68 
69 #define	lblkno(udf_vfsp, loc)	\
70 	((int32_t)((loc) / (udf_vfsp)->udf_lbsize))
71 
72 #define	fsbtodb(udf, blk)	\
73 	((blk) << udf->udf_l2d_shift)
74 
75 
76 struct udf_fid {
77 	uint16_t	udfid_len;	/* Length of data */
78 	uint16_t	udfid_prn;	/* the partition number of icb */
79 	uint32_t	udfid_icb_lbn;	/* file entry block no */
80 	uint32_t	udfid_uinq_lo;	/* uniq id to validate the vnode */
81 };
82 
83 
84 
85 
86 #define	MAXNAMLEN	255
87 
88 
89 
90 
91 struct ud_part {
92 	uint16_t	udp_flags;	/* See below */
93 	uint16_t	udp_number;	/* partition Number */
94 	uint32_t	udp_seqno;	/* to find the prevailaing desc */
95 	uint32_t	udp_access;	/* access type */
96 	uint32_t	udp_start;	/* Starting block no of partition */
97 	uint32_t	udp_length;	/* Lenght of the partition */
98 	uint32_t	udp_unall_loc;	/* unall space tbl or bitmap loc */
99 	uint32_t	udp_unall_len;	/* unall space tbl or bitmap length */
100 	uint32_t	udp_freed_loc;	/* freed space tbl or bitmap loc */
101 	uint32_t	udp_freed_len;	/* freed space tbl or bitmap length */
102 					/* From part desc */
103 
104 	uint32_t	udp_nfree;	/* No of free blocks in the partition */
105 	uint32_t	udp_nblocks;	/* Total no of blks in the partition */
106 					/* From lvid */
107 	uint32_t	udp_last_alloc;	/* Last allocated space in bitmap */
108 
109 	int32_t		udp_cache_count;	/* Cache is used for metadata */
110 	daddr_t		udp_cache[CLSTR_SIZE];
111 };
112 
113 /*
114  * udp_flags
115  */
116 #define	UDP_BITMAPS	0x00
117 #define	UDP_SPACETBLS	0x01
118 
119 /*
120  * udp_access
121  */
122 #define	UDP_MT_RO	0x0001		/* ROM */
123 #define	UDP_MT_WO	0x0002		/* WORM */
124 #define	UDP_MT_RW	0x0003		/* RW */
125 #define	UDP_MT_OW	0x0004		/* OW */
126 
127 
128 
129 #define	MAX_SPM		4
130 
131 struct ud_map {
132 	uint32_t	udm_flags;	/* Flags */
133 	uint16_t	udm_vsn;	/* Volume Sequence Number */
134 	uint16_t	udm_pn;		/* Partition Number */
135 	uint32_t	udm_vat_icb;	/* VAT ICB location */
136 	uint32_t	udm_nent;	/* Number of vat entries */
137 	uint32_t	*udm_count;	/* Number of entrues in each table */
138 	struct buf	**udm_bp;	/* VAT translation tables */
139 	uint32_t	**udm_addr;
140 
141 
142 	int32_t		udm_plen;
143 	int32_t		udm_nspm;
144 	uint32_t	udm_spsz;
145 	uint32_t	udm_loc[MAX_SPM];
146 	struct buf	*udm_sbp[MAX_SPM];
147 	caddr_t		udm_spaddr[MAX_SPM];
148 };
149 
150 /*
151  * udm_flags
152  */
153 #define	UDM_MAP_NORM	0x00
154 #define	UDM_MAP_VPM	0x01
155 #define	UDM_MAP_SPM	0x02
156 
157 struct udf_vfs {
158 	struct vfs	*udf_vfs;	/* Back link */
159 	struct udf_vfs	*udf_next;	/* Chain of udf file-system's */
160 	struct udf_vfs	*udf_wnext;	/* work list link */
161 
162 	struct buf	*udf_vds;	/* most of the superblock */
163 	struct buf	*udf_iseq;	/* Integrity of the fs */
164 	struct vnode	*udf_root;	/* Root vnode */
165 	struct vnode	*udf_devvp;	/* Block device vnode */
166 
167 	char		*udf_fsmnt;	/* Path name of directory mouted on */
168 	uint32_t	udf_flags;	/* Flags */
169 	uint32_t	udf_mtype;	/* Media type */
170 
171 	int32_t		udf_rdclustsz;	/* read cluster size */
172 	int32_t		udf_wrclustsz;	/* write cluster size */
173 
174 	uint64_t	udf_maxfsize;	/* Max file size allowed in this fs */
175 	int32_t		udf_maxfbits;	/* No of bit's for max file size */
176 
177 	char		udf_volid[32];	/* volume identifier */
178 					/* from pvd */
179 	uint16_t	udf_tsno;	/* Taken from pvd and */
180 					/* used in making tags */
181 
182 	int32_t		udf_lbsize;	/* Block size */
183 					/* from lvd */
184 	int32_t		udf_lbmask;	/* udf_lbsize - 1 */
185 	int32_t		udf_l2b_shift;	/* lbsize to bytes */
186 	int32_t		udf_l2d_shift;	/* right shift's to */
187 					/* make lbsize to DEV_BSIZE */
188 
189 	int32_t		udf_npart;	/* No. of partition's in the volume */
190 					/* restricted to 1 till udf 1.50 */
191 	struct ud_part	*udf_parts;	/* pointer to array of partitions */
192 					/* from part desc's */
193 
194 	int32_t		udf_nmaps;
195 	struct ud_map	*udf_maps;
196 
197 	int32_t		udf_fragmented;	/* File System fragmented */
198 	int32_t		udf_mark_bad;	/* force fsck at next mount */
199 
200 	/*
201 	 * sum of udp_nfree and udp_nblocks
202 	 * from the array udf_parts[0] to udf_parts[udf_nparts - 1]
203 	 */
204 	uint32_t	udf_freeblks;	/* Total udf_lbsize Free Blocks */
205 	uint32_t	udf_totalblks;	/* Total number of Blocks */
206 				/* udf_parts[0].udp_nfree == udf_freespace */
207 				/* till udf 1.50 (DVD-R?) */
208 	uint64_t	udf_maxuniq;	/* Maximum unique ID on the fs */
209 	uint32_t	udf_nfiles;	/* No of files */
210 	uint32_t	udf_ndirs;	/* No of directories */
211 	uint32_t	udf_miread;	/* minimum read revision */
212 	uint32_t	udf_miwrite;	/* minimum write revision */
213 	uint32_t	udf_mawrite;	/* maximum read revision */
214 					/* from lvid */
215 
216 	time_t		udf_time;	/* Last time super block is written */
217 	uint32_t	udf_mod;	/* file system was modified */
218 	uint32_t	udf_clean;	/* state of the file system */
219 	kmutex_t	udf_lock;	/* protects contents */
220 
221 	kmutex_t	udf_rename_lck;	/* lock for udf_rename */
222 
223 	/*
224 	 * Have them cached here for fast access
225 	 */
226 	struct pri_vol_desc	*udf_pvd;
227 	struct log_vol_desc	*udf_lvd;
228 	struct log_vol_int_desc *udf_lvid;
229 
230 	uint32_t		udf_mvds_loc;
231 	uint32_t		udf_mvds_len;
232 
233 	uint32_t		udf_rvds_loc;
234 	uint32_t		udf_rvds_len;
235 
236 	uint32_t		udf_iseq_loc;
237 	uint32_t		udf_iseq_len;
238 
239 	uint16_t		udf_fsd_prn;
240 	uint32_t		udf_fsd_loc;
241 	uint32_t		udf_fsd_len;
242 
243 	uint16_t		udf_ricb_prn;
244 	uint32_t		udf_ricb_loc;
245 	uint32_t		udf_ricb_len;
246 	daddr_t			udf_root_blkno;
247 };
248 
249 
250 #ifndef	__lint
251 _NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock,
252 		udf_vfs::udf_fragmented))
253 _NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock,
254 		udf_vfs::udf_freeblks udf_vfs::udf_totalblks))
255 _NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock,
256 		udf_vfs::udf_maxuniq udf_vfs::udf_nfiles
257 		udf_vfs::udf_ndirs))
258 _NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock,
259 		udf_vfs::udf_time
260 		udf_vfs::udf_mod udf_vfs::udf_clean))
261 
262 _NOTE(READ_ONLY_DATA(udf_vfs::udf_nmaps udf_vfs::udf_maps))
263 
264 _NOTE(READ_ONLY_DATA(udf_vfs::udf_mtype
265 		udf_vfs::udf_rdclustsz
266 		udf_vfs::udf_wrclustsz
267 		udf_vfs::udf_maxfsize
268 		udf_vfs::udf_maxfbits
269 		udf_vfs::udf_lbsize
270 		udf_vfs::udf_l2b_shift
271 		udf_vfs::udf_lbmask
272 		udf_vfs::udf_l2d_shift))
273 
274 _NOTE(READ_ONLY_DATA(udf_vfs::udf_pvd
275 		udf_vfs::udf_lvd
276 		udf_vfs::udf_lvid))
277 
278 _NOTE(READ_ONLY_DATA(udf_vfs::udf_mvds_loc
279 		udf_vfs::udf_mvds_len
280 		udf_vfs::udf_iseq_loc
281 		udf_vfs::udf_iseq_len
282 		udf_vfs::udf_fsd_prn
283 		udf_vfs::udf_fsd_loc
284 		udf_vfs::udf_fsd_len
285 		udf_vfs::udf_ricb_prn
286 		udf_vfs::udf_ricb_loc
287 		udf_vfs::udf_ricb_len
288 		udf_vfs::udf_root_blkno))
289 
290 _NOTE(READ_ONLY_DATA(ud_part::udp_flags
291 		ud_part::udp_number
292 		ud_part::udp_seqno
293 		ud_part::udp_access
294 		ud_part::udp_start
295 		ud_part::udp_length
296 		ud_part::udp_unall_loc
297 		ud_part::udp_unall_len
298 		ud_part::udp_freed_loc
299 		ud_part::udp_freed_len
300 		ud_part::udp_nblocks))
301 
302 _NOTE(MUTEX_PROTECTS_DATA(udf_vfs::udf_lock,
303 		ud_part::udp_nfree
304 		ud_part::udp_last_alloc
305 		ud_part::udp_cache_count
306 		ud_part::udp_cache))
307 #endif
308 
309 /*
310  * udf_mtype
311  */
312 #define	UDF_MT_RO	UDP_MT_RO		/* ROM */
313 #define	UDF_MT_WO	UDP_MT_OW		/* WORM */
314 #define	UDF_MT_RW	UDP_MT_RW		/* RW */
315 #define	UDF_MT_OW	UDP_MT_OW		/* OW */
316 
317 /*
318  * udf_flags
319  */
320 #define	UDF_FL_RDONLY	0x0001		/* file system is read only */
321 #define	UDF_FL_RW	0x0002		/* file system is read write */
322 
323 /*
324  * udf_clean
325  */
326 #define	UDF_DIRTY	0x00
327 #define	UDF_CLEAN	0x01
328 
329 
330 #define	RD_CLUSTSZ(ip)		((ip)->i_udf->udf_rdclustsz)
331 #define	WR_CLUSTSZ(ip)		((ip)->i_udf->udf_wrclustsz)
332 
333 /*
334  * Size can be a 64-bit value and therefore we sign extend fs_bmask
335  * to a 64-bit value too so that the higher 32 bits are masked
336  * properly. Note that the type of fs_bmask has to be signed. Otherwise
337  * compiler will set the higher 32 bits as zero and we don't want
338  * this to happen.
339  */
340 
341 #ifdef	UNDEF
342 #define	blkroundup(fs, size)	/* calculates roundup(size, fs->fs_bsize) */ \
343 	(((size) + (fs)->udf_lbsize - 1) & (offset_t)(fs)->udf_lbmask)
344 #endif
345 
346 #define	blkroundup(fs, size)	/* calculates roundup(size, fs->fs_bsize) */ \
347 	(((size) + (fs)->udf_lbmask) & (offset_t)(~(fs)->udf_lbmask))
348 
349 #define	blksize(fs)	(fs->udf_lbsize)
350 
351 
352 /*
353  * Convert between inode pointers and vnode pointers
354  */
355 #define	VTOI(VP)	((struct ud_inode *)(VP)->v_data)
356 #define	ITOV(IP)	((IP)->i_vnode)
357 #define	i_vfs		i_vnode->v_vfsp
358 
359 struct icb_ext {
360 	uint16_t	ib_flags;
361 
362 	/* Direct Entry will go here */
363 	uint16_t	ib_prn;		/* partition reference number */
364 	uint32_t	ib_block;	/* block offset into partition */
365 	uint64_t	ib_offset;	/* offset into the file bytes */
366 	int32_t		ib_count;	/* No of bytes in current ext */
367 	uint32_t	ib_marker1;	/* 0xAAAAAAAA */
368 	uint32_t	ib_marker2;	/* 0xBBBBBBBB */
369 };
370 
371 
372 /* ib_flags */
373 #define	IB_UN_REC	0x1		/* The entry is not allocated */
374 #define	IB_UN_RE_AL	0x2		/* The entry is not recorded */
375 					/* and not unallocated */
376 #define	IB_CON		0x3		/* Continuation entry */
377 
378 #define	IB_MASK		0x3
379 
380 #define	IB_ALLOCATED(flags)	\
381 	(((flags) & IB_MASK) != IB_UN_RE_AL)
382 
383 #define	EXT_PER_MALLOC	8
384 
385 
386 struct ud_inode {
387 	struct ud_inode	*i_forw;
388 	struct ud_inode	*i_back;
389 	struct ud_inode	*i_freef;
390 	struct ud_inode	*i_freeb;
391 
392 	struct vnode	*i_vnode;	/* vnode associated with this inode */
393 	struct vnode	*i_devvp;	/* vnode for block I/O */
394 	struct udf_vfs	*i_udf;		/* incore fs associated with inode */
395 	krwlock_t	i_rwlock;	/* serializes write/setattr requests */
396 	krwlock_t	i_contents;	/* protects (most of) inode contents */
397 	dev_t		i_dev;		/* device where inode resides */
398 	u_offset_t	i_diroff;	/* last loc for fast name lookup */
399 
400 	daddr_t		i_icb_lbano;	/* Loc of file icb on disk */
401 	uint16_t	i_icb_prn;	/* partition reference number */
402 	kcondvar_t	i_wrcv;		/* sleep/wakeup for write throttle */
403 	uint32_t	i_flag;
404 	uint32_t	i_icb_block;
405 
406 	int16_t		i_astrat;	/* ICB strategy */
407 	int16_t		i_desc_type;	/* Allocation desc type */
408 	int32_t		i_ext_count;	/* Number of extents allocated */
409 	int32_t		i_ext_used;	/* Number of extents used */
410 	struct icb_ext	*i_ext;		/* array of extents */
411 
412 	kmutex_t	i_con_lock;
413 	struct icb_ext	*i_con;
414 	int32_t		i_con_count;
415 	int32_t		i_con_used;
416 	int32_t		i_con_read;
417 
418 	uint32_t	i_cur_max_ext;
419 	vtype_t		i_type;		/* File type */
420 	uint16_t	i_char;		/* File characteristics */
421 	uint16_t	i_perm;		/* File permissions */
422 
423 	uid_t		i_uid;		/* File owner's uid */
424 	gid_t		i_gid;		/* File owner's gid */
425 	uint32_t	i_nlink;	/* number of links to file */
426 	uint32_t	i_maxent;	/* Max entries that are recorded */
427 	u_offset_t	i_size;		/* File size in bytes */
428 	uint64_t	i_lbr;		/* Logical blocks recorded */
429 	uint64_t	i_uniqid;	/* from the file entry */
430 
431 	timespec32_t	i_atime;
432 	timespec32_t	i_mtime;
433 	timespec32_t	i_ctime;
434 
435 	size_t		i_delaylen;	/* delayed writes, units=bytes */
436 	offset_t	i_delayoff;	/* where we started delaying */
437 	offset_t	i_nextrio;	/* where to start the next clust */
438 	uint64_t	i_writes;	/* remaining bytes in write q */
439 	kmutex_t	i_tlock;	/* protects time fields, i_flag */
440 	major_t		i_major;
441 	minor_t		i_minor;
442 
443 	uint32_t	i_marker1;	/* 0xAAAAAAAA */
444 	uint32_t	i_seq;		/* sequence number attribute */
445 	offset_t	i_nextr;	/* next byte read offset (read-ahead) */
446 	long		i_mapcnt;	/* number of mappings of pages */
447 	int		*i_map;		/* block list for the file */
448 	dev_t		i_rdev;		/* INCORE rdev from */
449 	uint32_t	i_marker2;	/* 0xBBBBBBBB */
450 	uint32_t	i_data_off;	/* Data offset into embedded file */
451 	uint32_t	i_max_emb;
452 	uint32_t	i_marker3;
453 };
454 
455 
456 #ifndef	__lint
457 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_astrat))
458 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_desc_type))
459 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_ext_count))
460 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_ext_used))
461 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_ext))
462 
463 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_type))
464 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_char))
465 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_perm))
466 
467 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_uid))
468 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_gid))
469 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_nlink))
470 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_size))
471 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_lbr))
472 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_uniqid))
473 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_major))
474 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents, ud_inode::i_minor))
475 
476 _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_atime))
477 _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_mtime))
478 _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_ctime))
479 _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_delayoff))
480 _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_delaylen))
481 _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_nextrio))
482 _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_writes))
483 _NOTE(MUTEX_PROTECTS_DATA(ud_inode::i_tlock, ud_inode::i_flag))
484 
485 _NOTE(RWLOCK_PROTECTS_DATA(ud_inode::i_contents,
486 		icb_ext::ib_flags icb_ext::ib_prn
487 		icb_ext::ib_block
488 		icb_ext::ib_count icb_ext::ib_offset))
489 #endif
490 
491 
492 /* i_flag */
493 #define	IUPD		0x0001		/* file has been modified */
494 #define	IACC		0x0002		/* inode access time to be updated */
495 #define	IMOD		0x0004		/* inode has been modified */
496 #define	ICHG		0x0008		/* inode has been changed */
497 #define	INOACC		0x0010		/* no access time update in getpage */
498 #define	IMODTIME	0x0020		/* mod time already set */
499 #define	IREF		0x0040		/* inode is being referenced */
500 #define	ISYNC		0x0080		/* do all allocation synchronously */
501 #define	IMODACC		0x0200		/* only access time changed; */
502 #define	IATTCHG		0x0400		/* only size/blocks have changed */
503 #define	IBDWRITE	0x0800		/* the inode has been scheduled for */
504 					/* write operation asynchrously */
505 
506 /*
507  * i_char
508  * Do not change used by MANDLOCK macro in vnode.h
509  */
510 #define	ISUID		VSUID		/* set user id on execution */
511 #define	ISGID		VSGID		/* set group id on execution */
512 #define	ISVTX		VSVTX		/* save swapped text even after use */
513 /*
514  * Setuid	--S---------
515  * Setgid	-G----------
516  * SaveTXT	T-----------
517  */
518 
519 /* i_perm */
520 #define	IEXEC		0x0400		/* read, write, execute permissions */
521 #define	IWRITE		0x0800
522 #define	IREAD		0x1000
523 #define	IATTR		0x2000
524 #define	IDELE		0x4000
525 
526 #define	UP_MASK		0x1CE7
527 #define	VA2UD_PERM(perm)	\
528 	(((perm) & 0x7) | (((perm) & 0x38) << 2) | (((perm) & 0x1C0) << 4))
529 #define	UD2VA_PERM(perm)	\
530 	(((perm) & 0x7) | (((perm) & 0xE0) >> 2) | (((perm) & 0x1C00) >> 4))
531 
532 /*
533  * Permissions
534  * Other	-----------DARWX
535  * Group	------DARWX-----
536  * Owner	-DARWX----------
537  */
538 #define	UD_DPERM2UPERM(dperm)	((((dperm) >> 4) & 0x1C0) |	\
539 					(((dperm) >> 2) & 0x38) |	\
540 					((dperm) & 0x7))
541 #define	UD_UPERM2DPERM(uperm)	((((uperm) & 0x1C0) << 4) |	\
542 					(((uperm) & 0x38) << 2) |	\
543 					((uperm) & 0x7))
544 
545 
546 /* specify how the inode info is written in ud_syncip() */
547 #define	I_SYNC	1	/* wait for the inode written to disk */
548 #define	I_DSYNC	2	/* wait for the inode written to disk */
549 			/* only if IATTCHG is set */
550 #define	I_ASYNC	0	/* don't wait for the inode written */
551 
552 
553 #define	UD_HASH_SZ	512
554 
555 #if ((UD_HASH_SZ & (UD_HASH_SZ - 1)) == 0)
556 #define	UD_INOHASH(dev, bno)	(hash2ints((int)dev, (int)bno) & UD_HASH_SZ - 1)
557 #else
558 #define	UD_INOHASH(dev, bno)	(hash2ints((int)dev, (int)bno) % UD_HASH_SZ)
559 #endif
560 
561 union ihead {
562 	union	ihead		*ih_head[2];
563 	struct	ud_inode	*ih_chain[2];
564 };
565 
566 
567 #define	IMARK(ip) ud_imark(ip)
568 #define	ITIMES_NOLOCK(ip) ud_itimes_nolock(ip)
569 
570 #define	ITIMES(ip) { \
571 	mutex_enter(&(ip)->i_tlock); \
572 	ITIMES_NOLOCK(ip); \
573 	mutex_exit(&(ip)->i_tlock); \
574 }
575 
576 #define	ESAME	(-1)		/* trying to rename linked files (special) */
577 
578 #define	UDF_HOLE	(daddr32_t)-1	/* value used when no block allocated */
579 
580 
581 extern int32_t ud_trace;
582 #define	ud_printf(xyz)	\
583 		if (ud_trace) {	\
584 			cmn_err(CE_NOTE, xyz);	\
585 		}
586 
587 #ifndef	__lint
588 _NOTE(SCHEME_PROTECTS_DATA("Unshared data",
589 		buf
590 		dirent64
591 		fid
592 		flock64
593 		statvfs64
594 		timespec32
595 		udf_fid
596 		uio
597 		vattr
598 		vfs
599 		vnode))
600 
601 _NOTE(SCHEME_PROTECTS_DATA("Unshared data",
602 		file_entry
603 		file_id
604 		icb_tag
605 		indirect_entry
606 		log_vol_int_desc
607 		long_ad
608 		lvid_iu
609 		regid
610 		short_ad
611 		tag
612 		tstamp))
613 
614 _NOTE(LOCK_ORDER(ud_inode::i_rwlock
615 		ud_inode::i_contents
616 		ud_inode::i_tlock))
617 #endif
618 
619 /*
620  * udf_vfsops.c
621  */
622 void		ud_update_superblock(struct vfs *);
623 
624 
625 /*
626  * udf_vnops.c
627  */
628 int32_t		ud_rdwri(enum uio_rw, int32_t, struct ud_inode *, caddr_t,
629 			int32_t, offset_t, enum uio_seg, int32_t *,
630 			struct cred *cr);
631 int32_t		ud_putapage(struct vnode *, page_t *, u_offset_t *,
632 			size_t *, int32_t, struct cred *);
633 
634 
635 /*
636  * udf_inode.c
637  */
638 int32_t		ud_iget(struct vfs *, uint16_t, uint32_t,
639 			struct ud_inode **, struct buf *, struct cred *);
640 void		ud_iinactive(struct ud_inode *, struct cred *);
641 void		ud_iupdat(struct ud_inode *, int32_t);
642 int32_t		ud_itrunc(struct ud_inode *, u_offset_t, int32_t,
643 			struct cred *);
644 int32_t		ud_iaccess(struct ud_inode *, int32_t, struct cred *);
645 int32_t		ud_iflush(struct vfs *);
646 void		ud_imark(struct ud_inode *);
647 void		ud_itimes_nolock(struct ud_inode *);
648 void		ud_delcache(struct ud_inode *);
649 void		ud_idrop(struct ud_inode *);
650 void		ud_init_inodes(void);
651 
652 
653 /*
654  * udf_alloc.c
655  */
656 int32_t		ud_alloc_space(struct vfs *, uint16_t, uint32_t,
657 			uint32_t, uint32_t *, uint32_t *, int32_t, int32_t);
658 void		ud_free_space(struct vfs *, uint16_t, uint32_t, uint32_t);
659 int32_t		ud_ialloc(struct ud_inode *, struct ud_inode **,
660 			struct vattr *, struct cred *);
661 void		ud_ifree(struct ud_inode *, vtype_t);
662 int32_t		ud_freesp(struct vnode *, struct flock64 *, int32_t,
663 			struct cred *);
664 int32_t		ud_alloc_from_cache(struct udf_vfs *, struct ud_part *,
665 			uint32_t *);
666 int32_t		ud_release_cache(struct udf_vfs *);
667 
668 
669 /*
670  * udf_subr.c
671  */
672 void		ud_vfs_add(struct udf_vfs *);
673 void		ud_vfs_remove(struct udf_vfs *);
674 daddr_t		ud_xlate_to_daddr(struct udf_vfs *, uint16_t,
675 			uint32_t, int32_t, uint32_t *);
676 int32_t		ud_ip_off2bno(struct ud_inode *, uint32_t, uint32_t *);
677 void		ud_dtime2utime(struct timespec32 *, struct tstamp const *);
678 void		ud_utime2dtime(struct timespec32 const *, struct tstamp *);
679 int32_t		ud_syncip(struct ud_inode *, int32_t, int32_t);
680 void		ud_update(int32_t);
681 int32_t		ud_fbwrite(struct fbuf *, struct ud_inode *);
682 void		ud_sbwrite(struct udf_vfs *);
683 int32_t		ud_sync_indir(struct ud_inode *);
684 void		ud_update_regid(struct regid *);
685 int32_t		ud_read_icb_till_off(struct ud_inode *, u_offset_t);
686 void		ud_make_tag(struct udf_vfs *, struct tag *,
687 			uint16_t, uint32_t, uint16_t);
688 int32_t		ud_make_dev_spec_ear(struct dev_spec_ear *, major_t, minor_t);
689 int32_t		ud_make_ftimes_ear(struct ftimes_ear *,
690 			int32_t, struct timespec32 *);
691 int32_t		ud_get_next_fid(struct ud_inode *, struct fbuf **, uint32_t,
692 			struct file_id **, uint8_t **, uint8_t *);
693 int32_t		ud_verify_tag_and_desc(struct tag *, uint16_t, uint32_t,
694 		int32_t, int32_t);
695 uint16_t	ud_crc(uint8_t *, int32_t);
696 int32_t		ud_compressunicode(int32_t, int32_t, uint16_t *, uint8_t *);
697 uint32_t	ud_check_te_unrec(struct udf_vfs *, caddr_t, uint32_t);
698 int32_t		ud_compress(int32_t, int32_t *, uint8_t *, uint8_t *);
699 int32_t		ud_uncompress(int32_t, int32_t *, uint8_t *, uint8_t *);
700 struct buf	*ud_bread(dev_t, daddr_t, long);
701 int		ud_sticky_remove_access(struct ud_inode *, struct ud_inode *,
702 			struct cred *);
703 
704 
705 /*
706  * udf_dir.c
707  */
708 int32_t		ud_dirlook(struct ud_inode *,
709 			char *, struct ud_inode **, struct cred *, int32_t);
710 int32_t		ud_direnter(struct ud_inode *, char *, enum de_op,
711 			struct ud_inode *, struct ud_inode *, struct vattr *,
712 			struct ud_inode **, struct cred *);
713 int32_t		ud_dirremove(struct ud_inode *,
714 			char *, struct ud_inode *, struct vnode *,
715 			enum dr_op, struct cred *);
716 
717 
718 /*
719  * udf_bmap.c
720  */
721 int32_t		ud_bmap_has_holes(struct ud_inode *);
722 int32_t		ud_bmap_write(struct ud_inode *, u_offset_t,
723 			int, int32_t, struct cred *);
724 int32_t		ud_bmap_read(struct ud_inode *, u_offset_t,
725 			daddr_t *, int32_t *);
726 void		ud_insert_new_ext(struct ud_inode *,
727 			int32_t, struct icb_ext *);
728 int32_t		ud_alloc_and_make_ext(struct ud_inode *, int32_t);
729 int32_t		ud_create_new_icb(struct ud_inode *);
730 void		ud_append_new_ext(struct ud_inode *, uint16_t,
731 			u_offset_t, uint32_t, uint16_t, uint32_t);
732 
733 
734 #ifdef	__cplusplus
735 }
736 #endif
737 
738 #endif	/* _SYS_FS_UDF_INODE_H */
739