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