xref: /freebsd/sys/fs/cd9660/cd9660_vfsops.c (revision 5ebc7e6281887681c3a348a5a4c902e262ccd656)
1 /*-
2  * Copyright (c) 1994
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley
6  * by Pace Willisson (pace@blitz.com).  The Rock Ridge Extension
7  * Support code is derived from software contributed to Berkeley
8  * by Atsushi Murai (amurai@spec.co.jp).
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the University of
21  *	California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  *	@(#)cd9660_vfsops.c	8.3 (Berkeley) 1/31/94
39  * $Id: cd9660_vfsops.c,v 1.11 1995/03/16 20:23:24 wollman Exp $
40  */
41 
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/namei.h>
45 #include <sys/proc.h>
46 #include <sys/kernel.h>
47 #include <sys/vnode.h>
48 #include <miscfs/specfs/specdev.h>
49 #include <sys/mount.h>
50 #include <sys/buf.h>
51 #include <sys/file.h>
52 #include <sys/ioctl.h>
53 #include <sys/errno.h>
54 #include <sys/malloc.h>
55 
56 #include <isofs/cd9660/iso.h>
57 #include <isofs/cd9660/cd9660_node.h>
58 #include <isofs/cd9660/iso_rrip.h>
59 
60 struct vfsops cd9660_vfsops = {
61 	cd9660_mount,
62 	cd9660_start,
63 	cd9660_unmount,
64 	cd9660_root,
65 	cd9660_quotactl,
66 	cd9660_statfs,
67 	cd9660_sync,
68 	cd9660_vget,
69 	cd9660_fhtovp,
70 	cd9660_vptofh,
71 	cd9660_init,
72 };
73 VFS_SET(cd9660_vfsops, cd9660, MOUNT_CD9660, VFCF_READONLY);
74 
75 
76 /*
77  * Called by vfs_mountroot when iso is going to be mounted as root.
78  *
79  * Name is updated by mount(8) after booting.
80  */
81 #define ROOTNAME	"root_device"
82 
83 static int iso_mountfs __P((struct vnode *devvp, struct mount *mp,
84 			    struct proc *p, struct iso_args *argp));
85 
86 int
87 cd9660_mountroot()
88 {
89 	register struct mount *mp;
90 	struct proc *p = curproc;	/* XXX */
91 	struct iso_mnt *imp;
92 	u_int size;
93 	int error;
94 	struct iso_args args;
95 
96 	/*
97 	 * Get vnode for rootdev.
98 	 */
99 	if (bdevvp(rootdev, &rootvp))
100 		panic("cd9660_mountroot: can't setup bdevvp for rootdev");
101 
102 	mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK);
103 	bzero((char *)mp, (u_long)sizeof(struct mount));
104 	mp->mnt_op = &cd9660_vfsops;
105 	mp->mnt_flag = MNT_RDONLY;
106 	args.flags = ISOFSMNT_ROOT;
107 	if ((error = iso_mountfs(rootvp, mp, p, &args))) {
108 		free(mp, M_MOUNT);
109 		return (error);
110 	}
111 	if ((error = vfs_lock(mp))) {
112 		(void)cd9660_unmount(mp, 0, p);
113 		free(mp, M_MOUNT);
114 		return (error);
115 	}
116 	TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list);
117 	mp->mnt_flag |= MNT_ROOTFS;
118 	mp->mnt_vnodecovered = NULLVP;
119 	imp = VFSTOISOFS(mp);
120 	bzero(imp->im_fsmnt, sizeof(imp->im_fsmnt));
121 	imp->im_fsmnt[0] = '/';
122 	bcopy((caddr_t)imp->im_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname,
123 	    MNAMELEN);
124 	(void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
125 	    &size);
126 	bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
127 	(void) cd9660_statfs(mp, &mp->mnt_stat, p);
128 	vfs_unlock(mp);
129 	return (0);
130 }
131 
132 /*
133  * Flag to allow forcible unmounting.
134  */
135 int iso_doforce = 1;
136 
137 /*
138  * VFS Operations.
139  *
140  * mount system call
141  */
142 int
143 cd9660_mount(mp, path, data, ndp, p)
144 	register struct mount *mp;
145 	char *path;
146 	caddr_t data;
147 	struct nameidata *ndp;
148 	struct proc *p;
149 {
150 	struct vnode *devvp;
151 	struct iso_args args;
152 	u_int size;
153 	int error;
154 	struct iso_mnt *imp = 0;
155 
156 	if ((error = copyin(data, (caddr_t)&args, sizeof (struct iso_args))))
157 		return (error);
158 
159 	if ((mp->mnt_flag & MNT_RDONLY) == 0)
160 		return (EROFS);
161 
162 	/*
163 	 * If updating, check whether changing from read-only to
164 	 * read/write; if there is no device name, that's all we do.
165 	 */
166 	if (mp->mnt_flag & MNT_UPDATE) {
167 		imp = VFSTOISOFS(mp);
168 		if (args.fspec == 0)
169 			return (vfs_export(mp, &imp->im_export, &args.export));
170 	}
171 	/*
172 	 * Not an update, or updating the name: look up the name
173 	 * and verify that it refers to a sensible block device.
174 	 */
175 	NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);
176 	if ((error = namei(ndp)))
177 		return (error);
178 	devvp = ndp->ni_vp;
179 
180 	if (devvp->v_type != VBLK) {
181 		vrele(devvp);
182 		return ENOTBLK;
183 	}
184 	if (major(devvp->v_rdev) >= nblkdev) {
185 		vrele(devvp);
186 		return ENXIO;
187 	}
188 	if ((mp->mnt_flag & MNT_UPDATE) == 0)
189 		error = iso_mountfs(devvp, mp, p, &args);
190 	else {
191 		if (devvp != imp->im_devvp)
192 			error = EINVAL;	/* needs translation */
193 		else
194 			vrele(devvp);
195 	}
196 	if (error) {
197 		vrele(devvp);
198 		return error;
199 	}
200 	imp = VFSTOISOFS(mp);
201 	(void) copyinstr(path, imp->im_fsmnt, sizeof(imp->im_fsmnt)-1, &size);
202 	bzero(imp->im_fsmnt + size, sizeof(imp->im_fsmnt) - size);
203 	bcopy((caddr_t)imp->im_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname,
204 	    MNAMELEN);
205 	(void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
206 	    &size);
207 	bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
208 	(void) cd9660_statfs(mp, &mp->mnt_stat, p);
209 	return 0;
210 }
211 
212 /*
213  * Common code for mount and mountroot
214  */
215 static int
216 iso_mountfs(devvp, mp, p, argp)
217 	register struct vnode *devvp;
218 	struct mount *mp;
219 	struct proc *p;
220 	struct iso_args *argp;
221 {
222 	register struct iso_mnt *isomp = (struct iso_mnt *)0;
223 	struct buf *bp = NULL;
224 	dev_t dev = devvp->v_rdev;
225 	int error = EINVAL;
226 	int needclose = 0;
227 	int high_sierra = 0;
228 	int ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
229 	int iso_bsize;
230 	int iso_blknum;
231 	struct iso_volume_descriptor *vdp;
232 	struct iso_primary_descriptor *pri;
233 	struct iso_sierra_primary_descriptor *pri_sierra;
234 	struct iso_directory_record *rootp;
235 	int logical_block_size;
236 
237 	if (!ronly)
238 		return EROFS;
239 
240 	/*
241 	 * Disallow multiple mounts of the same device.
242 	 * Disallow mounting of a device that is currently in use
243 	 * (except for root, which might share swap device for miniroot).
244 	 * Flush out any old buffers remaining from a previous use.
245 	 */
246 	if ((error = vfs_mountedon(devvp)))
247 		return error;
248 	if (vcount(devvp) > 1 && devvp != rootvp)
249 		return EBUSY;
250 	if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0)))
251 		return (error);
252 
253 	if ((error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p)))
254 		return error;
255 	needclose = 1;
256 
257 	/* This is the "logical sector size".  The standard says this
258 	 * should be 2048 or the physical sector size on the device,
259 	 * whichever is greater.  For now, we'll just use a constant.
260 	 */
261 	iso_bsize = ISO_DEFAULT_BLOCK_SIZE;
262 
263 	for (iso_blknum = 16; iso_blknum < 100; iso_blknum++) {
264 		if ((error = bread (devvp, btodb(iso_blknum * iso_bsize),
265 				    iso_bsize, NOCRED, &bp)))
266 			goto out;
267 
268 		vdp = (struct iso_volume_descriptor *)bp->b_un.b_addr;
269 		if (bcmp (vdp->id, ISO_STANDARD_ID, sizeof vdp->id) != 0) {
270 			if (bcmp (vdp->id_sierra, ISO_SIERRA_ID,
271 				  sizeof vdp->id) != 0) {
272 				error = EINVAL;
273 				goto out;
274 			} else
275 				high_sierra = 1;
276 		}
277 
278 		if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) == ISO_VD_END) {
279 			error = EINVAL;
280 			goto out;
281 		}
282 
283 		if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) == ISO_VD_PRIMARY)
284 			break;
285 		brelse(bp);
286 	}
287 
288 	if (isonum_711 (high_sierra? vdp->type_sierra: vdp->type) != ISO_VD_PRIMARY) {
289 		error = EINVAL;
290 		goto out;
291 	}
292 
293 	pri = (struct iso_primary_descriptor *)vdp;
294 	pri_sierra = (struct iso_sierra_primary_descriptor *)vdp;
295 
296 	logical_block_size =
297 		isonum_723 (high_sierra?
298 			    pri_sierra->logical_block_size:
299 			    pri->logical_block_size);
300 
301 	if (logical_block_size < DEV_BSIZE || logical_block_size > MAXBSIZE
302 	    || (logical_block_size & (logical_block_size - 1)) != 0) {
303 		error = EINVAL;
304 		goto out;
305 	}
306 
307 	rootp = (struct iso_directory_record *)
308 		(high_sierra?
309 		 pri_sierra->root_directory_record:
310 		 pri->root_directory_record);
311 
312 	isomp = malloc(sizeof *isomp, M_ISOFSMNT, M_WAITOK);
313 	bzero((caddr_t)isomp, sizeof *isomp);
314 	isomp->logical_block_size = logical_block_size;
315 	isomp->volume_space_size =
316 		isonum_733 (high_sierra?
317 			    pri_sierra->volume_space_size:
318 			    pri->volume_space_size);
319 	bcopy (rootp, isomp->root, sizeof isomp->root);
320 	isomp->root_extent = isonum_733 (rootp->extent);
321 	isomp->root_size = isonum_733 (rootp->size);
322 
323 	isomp->im_bmask = logical_block_size - 1;
324 	isomp->im_bshift = 0;
325 	while ((1 << isomp->im_bshift) < isomp->logical_block_size)
326 		isomp->im_bshift++;
327 
328 	bp->b_flags |= B_AGE;
329 	brelse(bp);
330 	bp = NULL;
331 
332 	mp->mnt_data = (qaddr_t)isomp;
333 	mp->mnt_stat.f_fsid.val[0] = (long)dev;
334 	mp->mnt_stat.f_fsid.val[1] = MOUNT_CD9660;
335 	mp->mnt_maxsymlinklen = 0;
336 	mp->mnt_flag |= MNT_LOCAL;
337 	isomp->im_mountp = mp;
338 	isomp->im_dev = dev;
339 	isomp->im_devvp = devvp;
340 
341 	devvp->v_specflags |= SI_MOUNTEDON;
342 
343 	/* Check the Rock Ridge Extention support */
344 	if (!(argp->flags & ISOFSMNT_NORRIP)) {
345 		if ((error = bread (isomp->im_devvp,
346 				   (isomp->root_extent + isonum_711(rootp->ext_attr_length))
347 				   * isomp->logical_block_size / DEV_BSIZE,
348 				   isomp->logical_block_size,NOCRED,&bp)))
349 		    goto out;
350 
351 		rootp = (struct iso_directory_record *)bp->b_un.b_addr;
352 
353 		if ((isomp->rr_skip = cd9660_rrip_offset(rootp,isomp)) < 0) {
354 		    argp->flags	 |= ISOFSMNT_NORRIP;
355 		} else {
356 		    argp->flags	 &= ~ISOFSMNT_GENS;
357 		}
358 
359 		/*
360 		 * The contents are valid,
361 		 * but they will get reread as part of another vnode, so...
362 		 */
363 		bp->b_flags |= B_AGE;
364 		brelse(bp);
365 		bp = NULL;
366 	}
367 	isomp->im_flags = argp->flags&(ISOFSMNT_NORRIP|ISOFSMNT_GENS|ISOFSMNT_EXTATT);
368 
369 	if(high_sierra)
370 		/* this effectively ignores all the mount flags */
371 		isomp->iso_ftype = ISO_FTYPE_HIGH_SIERRA;
372 	else
373 		switch (isomp->im_flags&(ISOFSMNT_NORRIP|ISOFSMNT_GENS)) {
374 		  default:
375 			  isomp->iso_ftype = ISO_FTYPE_DEFAULT;
376 			  break;
377 		  case ISOFSMNT_GENS|ISOFSMNT_NORRIP:
378 			  isomp->iso_ftype = ISO_FTYPE_9660;
379 			  break;
380 		  case 0:
381 			  isomp->iso_ftype = ISO_FTYPE_RRIP;
382 			  break;
383 		}
384 
385 	return 0;
386 out:
387 	if (bp)
388 		brelse(bp);
389 	if (needclose)
390 		(void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p);
391 	if (isomp) {
392 		free((caddr_t)isomp, M_ISOFSMNT);
393 		mp->mnt_data = (qaddr_t)0;
394 	}
395 	return error;
396 }
397 
398 /*
399  * Make a filesystem operational.
400  * Nothing to do at the moment.
401  */
402 /* ARGSUSED */
403 int
404 cd9660_start(mp, flags, p)
405 	struct mount *mp;
406 	int flags;
407 	struct proc *p;
408 {
409 	return 0;
410 }
411 
412 /*
413  * unmount system call
414  */
415 int
416 cd9660_unmount(mp, mntflags, p)
417 	struct mount *mp;
418 	int mntflags;
419 	struct proc *p;
420 {
421 	register struct iso_mnt *isomp;
422 	int error, flags = 0;
423 
424 	if (mntflags & MNT_FORCE) {
425 		if (!iso_doforce)
426 			return (EINVAL);
427 		flags |= FORCECLOSE;
428 	}
429 #if 0
430 	mntflushbuf(mp, 0);
431 	if (mntinvalbuf(mp))
432 		return EBUSY;
433 #endif
434 	if ((error = vflush(mp, NULLVP, flags)))
435 		return (error);
436 
437 	isomp = VFSTOISOFS(mp);
438 
439 #ifdef	ISODEVMAP
440 	if (isomp->iso_ftype == ISO_FTYPE_RRIP)
441 		iso_dunmap(isomp->im_dev);
442 #endif
443 
444 	isomp->im_devvp->v_specflags &= ~SI_MOUNTEDON;
445 	error = VOP_CLOSE(isomp->im_devvp, FREAD, NOCRED, p);
446 	vrele(isomp->im_devvp);
447 	free((caddr_t)isomp, M_ISOFSMNT);
448 	mp->mnt_data = (qaddr_t)0;
449 	mp->mnt_flag &= ~MNT_LOCAL;
450 	return (error);
451 }
452 
453 /*
454  * Return root of a filesystem
455  */
456 int
457 cd9660_root(mp, vpp)
458 	struct mount *mp;
459 	struct vnode **vpp;
460 {
461 	register struct iso_node *ip;
462 	struct iso_node tip, *nip;
463 	struct vnode tvp;
464 	int error;
465 	struct iso_mnt *imp = VFSTOISOFS (mp);
466 	struct iso_directory_record *dp;
467 
468 	tvp.v_mount = mp;
469 	tvp.v_data = &tip;
470 	ip = VTOI(&tvp);
471 	ip->i_vnode = &tvp;
472 	ip->i_dev = imp->im_dev;
473 	ip->i_diroff = 0;
474 	dp = (struct iso_directory_record *)imp->root;
475 	isodirino(&ip->i_number,dp,imp);
476 
477 	/*
478 	 * With RRIP we must use the `.' entry of the root directory.
479 	 * Simply tell iget, that it's a relocated directory.
480 	 */
481 	error = iso_iget(ip,ip->i_number,
482 			 imp->iso_ftype == ISO_FTYPE_RRIP,
483 			 &nip,dp);
484 	if (error)
485 		return error;
486 	*vpp = ITOV(nip);
487 	return 0;
488 }
489 
490 /*
491  * Do operations associated with quotas, not supported
492  */
493 /* ARGSUSED */
494 int
495 cd9660_quotactl(mp, cmd, uid, arg, p)
496 	struct mount *mp;
497 	int cmd;
498 	uid_t uid;
499 	caddr_t arg;
500 	struct proc *p;
501 {
502 
503 	return (EOPNOTSUPP);
504 }
505 
506 /*
507  * Get file system statistics.
508  */
509 int
510 cd9660_statfs(mp, sbp, p)
511 	struct mount *mp;
512 	register struct statfs *sbp;
513 	struct proc *p;
514 {
515 	register struct iso_mnt *isomp;
516 
517 	isomp = VFSTOISOFS(mp);
518 
519 	sbp->f_type = MOUNT_CD9660;
520 	sbp->f_bsize = isomp->logical_block_size;
521 	sbp->f_iosize = sbp->f_bsize;	/* XXX */
522 	sbp->f_blocks = isomp->volume_space_size;
523 	sbp->f_bfree = 0; /* total free blocks */
524 	sbp->f_bavail = 0; /* blocks free for non superuser */
525 	sbp->f_files =	0; /* total files */
526 	sbp->f_ffree = 0; /* free file nodes */
527 	if (sbp != &mp->mnt_stat) {
528 		bcopy((caddr_t)mp->mnt_stat.f_mntonname,
529 			(caddr_t)&sbp->f_mntonname[0], MNAMELEN);
530 		bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
531 			(caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
532 	}
533 	/* Use the first spare for flags: */
534 	sbp->f_spare[0] = isomp->im_flags;
535 	return 0;
536 }
537 
538 /* ARGSUSED */
539 int
540 cd9660_sync(mp, waitfor, cred, p)
541 	struct mount *mp;
542 	int waitfor;
543 	struct ucred *cred;
544 	struct proc *p;
545 {
546 	return (0);
547 }
548 
549 /*
550  * Flat namespace lookup.
551  * Currently unsupported.
552  */
553 /* ARGSUSED */
554 int
555 cd9660_vget(mp, ino, vpp)
556 	struct mount *mp;
557 	ino_t ino;
558 	struct vnode **vpp;
559 {
560 
561 	return (EOPNOTSUPP);
562 }
563 
564 /*
565  * File handle to vnode
566  *
567  * Have to be really careful about stale file handles:
568  * - check that the inode number is in range
569  * - call iget() to get the locked inode
570  * - check for an unallocated inode (i_mode == 0)
571  * - check that the generation number matches
572  */
573 
574 struct ifid {
575 	ushort	ifid_len;
576 	ushort	ifid_pad;
577 	int	ifid_ino;
578 	long	ifid_start;
579 };
580 
581 /* ARGSUSED */
582 int
583 cd9660_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp)
584 	register struct mount *mp;
585 	struct fid *fhp;
586 	struct mbuf *nam;
587 	struct vnode **vpp;
588 	int *exflagsp;
589 	struct ucred **credanonp;
590 {
591 	struct vnode			tvp;
592 	int				error;
593 	int				lbn, off;
594 	struct ifid			*ifhp;
595 	struct iso_mnt			*imp;
596 	struct buf			*bp;
597 	struct iso_directory_record	*dirp;
598 	struct iso_node			tip, *ip, *nip;
599 	struct netcred			*np;
600 
601 	imp = VFSTOISOFS (mp);
602 	ifhp = (struct ifid *)fhp;
603 
604 #ifdef	ISOFS_DBG
605 	printf("fhtovp: ino %d, start %ld\n",
606 	       ifhp->ifid_ino, ifhp->ifid_start);
607 #endif
608 
609 	np = vfs_export_lookup(mp, &imp->im_export, nam);
610 	if (np == NULL)
611 		return (EACCES);
612 
613 	lbn = iso_lblkno(imp, ifhp->ifid_ino);
614 	if (lbn >= imp->volume_space_size) {
615 		printf("fhtovp: lbn exceed volume space %d\n", lbn);
616 		return (ESTALE);
617 	}
618 
619 	off = iso_blkoff(imp, ifhp->ifid_ino);
620 	if (off + ISO_DIRECTORY_RECORD_SIZE > imp->logical_block_size) {
621 		printf("fhtovp: crosses block boundary %d\n",
622 		       off + ISO_DIRECTORY_RECORD_SIZE);
623 		return (ESTALE);
624 	}
625 
626 	error = bread(imp->im_devvp, btodb(lbn * imp->logical_block_size),
627 		      imp->logical_block_size, NOCRED, &bp);
628 	if (error) {
629 		printf("fhtovp: bread error %d\n",error);
630 		brelse(bp);
631 		return (error);
632 	}
633 
634 	dirp = (struct iso_directory_record *)(bp->b_un.b_addr + off);
635 	if (off + isonum_711(dirp->length) > imp->logical_block_size) {
636 		brelse(bp);
637 		printf("fhtovp: directory crosses block boundary %d[off=%d/len=%d]\n",
638 		       off+isonum_711(dirp->length), off,
639 		       isonum_711(dirp->length));
640 		return (ESTALE);
641 	}
642 
643 	if (isonum_733(dirp->extent) + isonum_711(dirp->ext_attr_length) !=
644 	    ifhp->ifid_start) {
645 		brelse(bp);
646 		printf("fhtovp: file start miss %d vs %ld\n",
647 		       isonum_733(dirp->extent)+isonum_711(dirp->ext_attr_length),
648 		       ifhp->ifid_start);
649 		return (ESTALE);
650 	}
651 	brelse(bp);
652 
653 	ip = &tip;
654 	tvp.v_mount = mp;
655 	tvp.v_data = ip;
656 	ip->i_vnode = &tvp;
657 	ip->i_dev = imp->im_dev;
658 	if ((error = iso_iget(ip, ifhp->ifid_ino, 0, &nip, dirp))) {
659 		*vpp = NULLVP;
660 		printf("fhtovp: failed to get inode\n");
661 		return (error);
662 	}
663 	ip = nip;
664 	/*
665 	 * XXX need generation number?
666 	 */
667 	if (ip->inode.iso_mode == 0) {
668 		iso_iput(ip);
669 		*vpp = NULLVP;
670 		printf("fhtovp: inode mode == 0\n");
671 		return (ESTALE);
672 	}
673 	*vpp = ITOV(ip);
674 	*exflagsp = np->netc_exflags;
675 	*credanonp = &np->netc_anon;
676 	return 0;
677 }
678 
679 /*
680  * Vnode pointer to File handle
681  */
682 /* ARGSUSED */
683 int
684 cd9660_vptofh(vp, fhp)
685 	struct vnode *vp;
686 	struct fid *fhp;
687 {
688 	register struct iso_node *ip = VTOI(vp);
689 	register struct ifid *ifhp;
690 
691 	ifhp = (struct ifid *)fhp;
692 	ifhp->ifid_len = sizeof(struct ifid);
693 
694 	ifhp->ifid_ino = ip->i_number;
695 	ifhp->ifid_start = ip->iso_start;
696 
697 #ifdef	ISOFS_DBG
698 	printf("vptofh: ino %d, start %ld\n",
699 	       ifhp->ifid_ino,ifhp->ifid_start);
700 #endif
701 	return 0;
702 }
703