| 1 | /*- |
| 2 | * SPDX-License-Identifier: BSD-3-Clause |
| 3 | * |
| 4 | * Copyright (c) 1994 |
| 5 | *	The Regents of the University of California. All rights reserved. |
| 6 | * |
| 7 | * This code is derived from software contributed to Berkeley |
| 8 | * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension |
| 9 | * Support code is derived from software contributed to Berkeley |
| 10 | * by Atsushi Murai (amurai@spec.co.jp). |
| 11 | * |
| 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * 1. Redistributions of source code must retain the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer. |
| 17 | * 2. Redistributions in binary form must reproduce the above copyright |
| 18 | * notice, this list of conditions and the following disclaimer in the |
| 19 | * documentation and/or other materials provided with the distribution. |
| 20 | * 3. Neither the name of the University nor the names of its contributors |
| 21 | * may be used to endorse or promote products derived from this software |
| 22 | * without specific prior written permission. |
| 23 | * |
| 24 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 34 | * SUCH DAMAGE. |
| 35 | */ |
| 36 | |
| 37 | /* |
| 38 | * Theoretically, directories can be more than 2Gb in length, |
| 39 | * however, in practice this seems unlikely. So, we define |
| 40 | * the type doff_t as a long to keep down the cost of doing |
| 41 | * lookup on a 32-bit machine. If you are porting to a 64-bit |
| 42 | * architecture, you should make doff_t the same as off_t. |
| 43 | */ |
| 44 | #define doff_t	long |
| 45 | |
| 46 | typedef	struct	{ |
| 47 | 	struct timespec	iso_atime;	/* time of last access */ |
| 48 | 	struct timespec	iso_mtime;	/* time of last modification */ |
| 49 | 	struct timespec	iso_ctime;	/* time file changed */ |
| 50 | 	u_short		iso_mode;	/* files access mode and type */ |
| 51 | 	uid_t		iso_uid;	/* owner user id */ |
| 52 | 	gid_t		iso_gid;	/* owner group id */ |
| 53 | 	short		iso_links;	/* links of file */ |
| 54 | 	dev_t		iso_rdev;	/* Major/Minor number for special */ |
| 55 | } ISO_RRIP_INODE; |
| 56 | |
| 57 | struct iso_node { |
| 58 | 	struct	vnode *i_vnode;	/* vnode associated with this inode */ |
| 59 | 	ino_t	i_number;	/* the identity of the inode */ |
| 60 | 				/* we use the actual starting block of the file */ |
| 61 | 	struct	iso_mnt *i_mnt;	/* filesystem associated with this inode */ |
| 62 | 	struct	lockf *i_lockf;	/* head of byte-level lock list */ |
| 63 | 	doff_t	i_endoff;	/* end of useful stuff in directory */ |
| 64 | 	doff_t	i_diroff;	/* offset in dir, where we found last entry */ |
| 65 | |
| 66 | 	long iso_extent;	/* extent of file */ |
| 67 | 	unsigned long i_size; |
| 68 | 	long iso_start;		/* actual start of data of file (may be different */ |
| 69 | 				/* from iso_extent, if file has extended attributes) */ |
| 70 | 	ISO_RRIP_INODE	inode; |
| 71 | }; |
| 72 | |
| 73 | #define	i_forw		i_chain[0] |
| 74 | #define	i_back		i_chain[1] |
| 75 | |
| 76 | #define VTOI(vp) ((struct iso_node *)(vp)->v_data) |
| 77 | #define ITOV(ip) ((ip)->i_vnode) |
| 78 | |
| 79 | #ifdef _KERNEL |
| 80 | |
| 81 | #ifdef MALLOC_DECLARE |
| 82 | MALLOC_DECLARE(M_ISOFSMNT); |
| 83 | MALLOC_DECLARE(M_ISOFSNODE); |
| 84 | #endif |
| 85 | |
| 86 | struct buf; |
| 87 | struct vop_bmap_args; |
| 88 | struct vop_cachedlookup_args; |
| 89 | struct vop_inactive_args; |
| 90 | struct vop_reclaim_args; |
| 91 | |
| 92 | /* |
| 93 | * Prototypes for ISOFS vnode operations |
| 94 | */ |
| 95 | int cd9660_lookup(struct vop_cachedlookup_args *); |
| 96 | int cd9660_inactive(struct vop_inactive_args *); |
| 97 | int cd9660_reclaim(struct vop_reclaim_args *); |
| 98 | int cd9660_bmap(struct vop_bmap_args *); |
| 99 | int cd9660_blkatoff(struct vnode *vp, off_t offset, char **res, struct buf **bpp); |
| 100 | |
| 101 | void cd9660_defattr(struct iso_directory_record *, |
| 102 | 			struct iso_node *, struct buf *, enum ISO_FTYPE); |
| 103 | void cd9660_deftstamp(struct iso_directory_record *, |
| 104 | 			struct iso_node *, struct buf *, enum ISO_FTYPE); |
| 105 | int cd9660_tstamp_conv7(u_char *, struct timespec *, enum ISO_FTYPE); |
| 106 | int cd9660_tstamp_conv17(u_char *, struct timespec *); |
| 107 | |
| 108 | #endif /* _KERNEL */ |