1994-05-24 10:09:53 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1994
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley
|
|
|
|
* by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
|
|
|
|
* Support code is derived from software contributed to Berkeley
|
|
|
|
* by Atsushi Murai (amurai@spec.co.jp).
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1997-02-10 02:22:35 +00:00
|
|
|
* @(#)cd9660_vnops.c 8.19 (Berkeley) 5/27/95
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/stat.h>
|
2000-05-05 09:59:14 +00:00
|
|
|
#include <sys/bio.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/vnode.h>
|
2001-05-23 09:42:29 +00:00
|
|
|
#include <fs/fifofs/fifo.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/malloc.h>
|
1997-04-10 15:05:38 +00:00
|
|
|
#include <sys/dirent.h>
|
1997-02-10 02:22:35 +00:00
|
|
|
#include <sys/unistd.h>
|
1999-12-07 22:25:28 +00:00
|
|
|
#include <sys/filio.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1998-03-06 09:46:52 +00:00
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vnode_pager.h>
|
2002-03-20 10:17:00 +00:00
|
|
|
#include <vm/uma.h>
|
1997-12-27 02:56:39 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <isofs/cd9660/iso.h>
|
|
|
|
#include <isofs/cd9660/cd9660_node.h>
|
|
|
|
#include <isofs/cd9660/iso_rrip.h>
|
|
|
|
|
2002-03-20 07:51:46 +00:00
|
|
|
static int cd9660_setattr(struct vop_setattr_args *);
|
|
|
|
static int cd9660_access(struct vop_access_args *);
|
|
|
|
static int cd9660_getattr(struct vop_getattr_args *);
|
|
|
|
static int cd9660_ioctl(struct vop_ioctl_args *);
|
|
|
|
static int cd9660_pathconf(struct vop_pathconf_args *);
|
|
|
|
static int cd9660_read(struct vop_read_args *);
|
1995-12-03 17:14:38 +00:00
|
|
|
struct isoreaddir;
|
2002-03-20 07:51:46 +00:00
|
|
|
static int iso_uiodir(struct isoreaddir *idp, struct dirent *dp, off_t off);
|
|
|
|
static int iso_shipdir(struct isoreaddir *idp);
|
|
|
|
static int cd9660_readdir(struct vop_readdir_args *);
|
|
|
|
static int cd9660_readlink(struct vop_readlink_args *ap);
|
|
|
|
static int cd9660_strategy(struct vop_strategy_args *);
|
1995-12-03 17:14:38 +00:00
|
|
|
|
1995-11-12 10:36:19 +00:00
|
|
|
/*
|
|
|
|
* Setattr call. Only allowed for block and character special devices.
|
|
|
|
*/
|
2002-09-28 17:15:38 +00:00
|
|
|
static int
|
1995-11-12 10:36:19 +00:00
|
|
|
cd9660_setattr(ap)
|
|
|
|
struct vop_setattr_args /* {
|
|
|
|
struct vnodeop_desc *a_desc;
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct vattr *a_vap;
|
|
|
|
struct ucred *a_cred;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *a_td;
|
1995-11-12 10:36:19 +00:00
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct vattr *vap = ap->a_vap;
|
|
|
|
|
1996-10-20 21:01:46 +00:00
|
|
|
if (vap->va_flags != (u_long)VNOVAL || vap->va_uid != (uid_t)VNOVAL ||
|
1996-09-20 05:51:12 +00:00
|
|
|
vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL ||
|
|
|
|
vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL)
|
1995-11-12 10:36:19 +00:00
|
|
|
return (EROFS);
|
1996-10-20 21:01:46 +00:00
|
|
|
if (vap->va_size != (u_quad_t)VNOVAL) {
|
1995-11-12 10:36:19 +00:00
|
|
|
switch (vp->v_type) {
|
|
|
|
case VDIR:
|
|
|
|
return (EISDIR);
|
|
|
|
case VLNK:
|
|
|
|
case VREG:
|
|
|
|
return (EROFS);
|
|
|
|
case VCHR:
|
|
|
|
case VBLK:
|
|
|
|
case VSOCK:
|
|
|
|
case VFIFO:
|
1999-01-27 21:50:00 +00:00
|
|
|
case VNON:
|
|
|
|
case VBAD:
|
1995-11-12 10:36:19 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
return (0);
|
1995-11-12 10:36:19 +00:00
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Check mode permission on inode pointer. Mode is READ, WRITE or EXEC.
|
|
|
|
* The mode is shifted to select the owner/group/other fields. The
|
|
|
|
* super user is granted all permissions.
|
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
1995-10-31 12:13:49 +00:00
|
|
|
static int
|
1994-05-24 10:09:53 +00:00
|
|
|
cd9660_access(ap)
|
|
|
|
struct vop_access_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_mode;
|
|
|
|
struct ucred *a_cred;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *a_td;
|
1994-05-24 10:09:53 +00:00
|
|
|
} */ *ap;
|
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct iso_node *ip = VTOI(vp);
|
2000-08-20 08:36:26 +00:00
|
|
|
mode_t mode = ap->a_mode;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1995-11-12 10:16:53 +00:00
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Disallow write attempts unless the file is a socket,
|
|
|
|
* fifo, or a block or character device resident on the
|
2002-05-16 21:28:32 +00:00
|
|
|
* filesystem.
|
1995-11-12 10:16:53 +00:00
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
if (mode & VWRITE) {
|
|
|
|
switch (vp->v_type) {
|
1995-11-12 10:16:53 +00:00
|
|
|
case VDIR:
|
|
|
|
case VLNK:
|
|
|
|
case VREG:
|
1997-02-10 02:22:35 +00:00
|
|
|
return (EROFS);
|
1999-01-27 21:50:00 +00:00
|
|
|
/* NOT REACHED */
|
|
|
|
default:
|
|
|
|
break;
|
1995-11-12 10:16:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-20 08:36:26 +00:00
|
|
|
return (vaccess(vp->v_type, ip->inode.iso_mode, ip->inode.iso_uid,
|
2000-08-29 14:45:49 +00:00
|
|
|
ip->inode.iso_gid, ap->a_mode, ap->a_cred, NULL));
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1995-10-31 12:13:49 +00:00
|
|
|
static int
|
1994-05-24 10:09:53 +00:00
|
|
|
cd9660_getattr(ap)
|
|
|
|
struct vop_getattr_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct vattr *a_vap;
|
|
|
|
struct ucred *a_cred;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *a_td;
|
1994-05-24 10:09:53 +00:00
|
|
|
} */ *ap;
|
|
|
|
|
|
|
|
{
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
register struct vattr *vap = ap->a_vap;
|
|
|
|
register struct iso_node *ip = VTOI(vp);
|
|
|
|
|
Divorce "dev_t" from the "major|minor" bitmap, which is now called
udev_t in the kernel but still called dev_t in userland.
Provide functions to manipulate both types:
major() umajor()
minor() uminor()
makedev() umakedev()
dev2udev() udev2dev()
For now they're functions, they will become in-line functions
after one of the next two steps in this process.
Return major/minor/makedev to macro-hood for userland.
Register a name in cdevsw[] for the "filedescriptor" driver.
In the kernel the udev_t appears in places where we have the
major/minor number combination, (ie: a potential device: we
may not have the driver nor the device), like in inodes, vattr,
cdevsw registration and so on, whereas the dev_t appears where
we carry around a reference to a actual device.
In the future the cdevsw and the aliased-from vnode will be hung
directly from the dev_t, along with up to two softc pointers for
the device driver and a few houskeeping bits. This will essentially
replace the current "alias" check code (same buck, bigger bang).
A little stunt has been provided to try to catch places where the
wrong type is being used (dev_t vs udev_t), if you see something
not working, #undef DEVT_FASCIST in kern/kern_conf.c and see if
it makes a difference. If it does, please try to track it down
(many hands make light work) or at least try to reproduce it
as simply as possible, and describe how to do that.
Without DEVT_FASCIST I belive this patch is a no-op.
Stylistic/posixoid comments about the userland view of the <sys/*.h>
files welcome now, from userland they now contain the end result.
Next planned step: make all dev_t's refer to the same devsw[] which
means convert BLK's to CHR's at the perimeter of the vnodes and
other places where they enter the game (bootdev, mknod, sysctl).
1999-05-11 19:55:07 +00:00
|
|
|
vap->va_fsid = dev2udev(ip->i_dev);
|
2002-05-22 08:50:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't use ip->i_ino for this since it is wrong for hard links.
|
|
|
|
* ip->i_ino should be the same as ip->iso_start (or not exist),
|
|
|
|
* but this currently doesn't work since we abuse it to look up
|
|
|
|
* parent directories from inodes.
|
|
|
|
*/
|
|
|
|
vap->va_fileid = ip->iso_start;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
vap->va_mode = ip->inode.iso_mode;
|
|
|
|
vap->va_nlink = ip->inode.iso_links;
|
|
|
|
vap->va_uid = ip->inode.iso_uid;
|
|
|
|
vap->va_gid = ip->inode.iso_gid;
|
|
|
|
vap->va_atime = ip->inode.iso_atime;
|
|
|
|
vap->va_mtime = ip->inode.iso_mtime;
|
|
|
|
vap->va_ctime = ip->inode.iso_ctime;
|
|
|
|
vap->va_rdev = ip->inode.iso_rdev;
|
|
|
|
|
|
|
|
vap->va_size = (u_quad_t) ip->i_size;
|
1997-02-10 02:22:35 +00:00
|
|
|
if (ip->i_size == 0 && (vap->va_mode & S_IFMT) == S_IFLNK) {
|
|
|
|
struct vop_readlink_args rdlnk;
|
|
|
|
struct iovec aiov;
|
|
|
|
struct uio auio;
|
|
|
|
char *cp;
|
|
|
|
|
|
|
|
MALLOC(cp, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
|
|
|
|
aiov.iov_base = cp;
|
|
|
|
aiov.iov_len = MAXPATHLEN;
|
|
|
|
auio.uio_iov = &aiov;
|
|
|
|
auio.uio_iovcnt = 1;
|
|
|
|
auio.uio_offset = 0;
|
|
|
|
auio.uio_rw = UIO_READ;
|
|
|
|
auio.uio_segflg = UIO_SYSSPACE;
|
2001-09-12 08:38:13 +00:00
|
|
|
auio.uio_td = ap->a_td;
|
1997-02-10 02:22:35 +00:00
|
|
|
auio.uio_resid = MAXPATHLEN;
|
|
|
|
rdlnk.a_uio = &auio;
|
|
|
|
rdlnk.a_vp = ap->a_vp;
|
|
|
|
rdlnk.a_cred = ap->a_cred;
|
|
|
|
if (cd9660_readlink(&rdlnk) == 0)
|
|
|
|
vap->va_size = MAXPATHLEN - auio.uio_resid;
|
|
|
|
FREE(cp, M_TEMP);
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
vap->va_flags = 0;
|
|
|
|
vap->va_gen = 1;
|
|
|
|
vap->va_blocksize = ip->i_mnt->logical_block_size;
|
|
|
|
vap->va_bytes = (u_quad_t) ip->i_size;
|
|
|
|
vap->va_type = vp->v_type;
|
1995-08-02 13:00:40 +00:00
|
|
|
vap->va_filerev = 0;
|
1994-05-24 10:09:53 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1999-12-07 22:25:28 +00:00
|
|
|
/*
|
|
|
|
* Vnode op for ioctl.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
cd9660_ioctl(ap)
|
|
|
|
struct vop_ioctl_args /* {
|
|
|
|
struct vnode *a_vp;
|
2002-10-16 08:04:11 +00:00
|
|
|
u_long a_command;
|
1999-12-07 22:25:28 +00:00
|
|
|
caddr_t a_data;
|
|
|
|
int a_fflag;
|
|
|
|
struct ucred *a_cred;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *a_td;
|
1999-12-07 22:25:28 +00:00
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct iso_node *ip = VTOI(vp);
|
|
|
|
|
|
|
|
switch (ap->a_command) {
|
|
|
|
|
|
|
|
case FIOGETLBA:
|
|
|
|
*(int *)(ap->a_data) = ip->iso_start;
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return (ENOTTY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Vnode op for reading.
|
|
|
|
*/
|
1995-10-31 12:13:49 +00:00
|
|
|
static int
|
1994-05-24 10:09:53 +00:00
|
|
|
cd9660_read(ap)
|
|
|
|
struct vop_read_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
int a_ioflag;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
register struct uio *uio = ap->a_uio;
|
|
|
|
register struct iso_node *ip = VTOI(vp);
|
|
|
|
register struct iso_mnt *imp;
|
|
|
|
struct buf *bp;
|
1994-09-26 00:32:59 +00:00
|
|
|
daddr_t lbn, rablock;
|
1994-05-24 10:09:53 +00:00
|
|
|
off_t diff;
|
|
|
|
int rasize, error = 0;
|
1999-09-20 23:27:58 +00:00
|
|
|
int seqcount;
|
1994-05-24 10:09:53 +00:00
|
|
|
long size, n, on;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1999-09-20 23:27:58 +00:00
|
|
|
seqcount = ap->a_ioflag >> 16;
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (uio->uio_resid == 0)
|
|
|
|
return (0);
|
|
|
|
if (uio->uio_offset < 0)
|
|
|
|
return (EINVAL);
|
1997-02-10 02:22:35 +00:00
|
|
|
ip->i_flag |= IN_ACCESS;
|
1994-05-24 10:09:53 +00:00
|
|
|
imp = ip->i_mnt;
|
|
|
|
do {
|
1997-02-10 02:22:35 +00:00
|
|
|
lbn = lblkno(imp, uio->uio_offset);
|
|
|
|
on = blkoff(imp, uio->uio_offset);
|
|
|
|
n = min((u_int)(imp->logical_block_size - on),
|
1994-05-24 10:09:53 +00:00
|
|
|
uio->uio_resid);
|
|
|
|
diff = (off_t)ip->i_size - uio->uio_offset;
|
|
|
|
if (diff <= 0)
|
|
|
|
return (0);
|
|
|
|
if (diff < n)
|
|
|
|
n = diff;
|
1997-02-10 02:22:35 +00:00
|
|
|
size = blksize(imp, ip, lbn);
|
1994-05-24 10:09:53 +00:00
|
|
|
rablock = lbn + 1;
|
1997-09-27 13:40:20 +00:00
|
|
|
if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {
|
1997-10-27 14:55:49 +00:00
|
|
|
if (lblktosize(imp, rablock) < ip->i_size)
|
1997-02-10 02:22:35 +00:00
|
|
|
error = cluster_read(vp, (off_t)ip->i_size,
|
1996-12-29 02:45:28 +00:00
|
|
|
lbn, size, NOCRED, uio->uio_resid,
|
|
|
|
(ap->a_ioflag >> 16), &bp);
|
1995-05-30 08:16:23 +00:00
|
|
|
else
|
1994-05-24 10:09:53 +00:00
|
|
|
error = bread(vp, lbn, size, NOCRED, &bp);
|
|
|
|
} else {
|
1999-09-20 23:27:58 +00:00
|
|
|
if (seqcount > 1 &&
|
1997-02-10 02:22:35 +00:00
|
|
|
lblktosize(imp, rablock) < ip->i_size) {
|
|
|
|
rasize = blksize(imp, ip, rablock);
|
1994-05-24 10:09:53 +00:00
|
|
|
error = breadn(vp, lbn, size, &rablock,
|
|
|
|
&rasize, 1, NOCRED, &bp);
|
|
|
|
} else
|
|
|
|
error = bread(vp, lbn, size, NOCRED, &bp);
|
|
|
|
}
|
|
|
|
n = min(n, size - bp->b_resid);
|
|
|
|
if (error) {
|
|
|
|
brelse(bp);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
error = uiomove(bp->b_data + on, (int)n, uio);
|
1994-05-24 10:09:53 +00:00
|
|
|
brelse(bp);
|
|
|
|
} while (error == 0 && uio->uio_resid > 0 && n != 0);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Structure for reading directories
|
|
|
|
*/
|
|
|
|
struct isoreaddir {
|
|
|
|
struct dirent saveent;
|
|
|
|
struct dirent assocent;
|
|
|
|
struct dirent current;
|
|
|
|
off_t saveoff;
|
|
|
|
off_t assocoff;
|
|
|
|
off_t curroff;
|
|
|
|
struct uio *uio;
|
|
|
|
off_t uio_off;
|
1997-02-10 02:22:35 +00:00
|
|
|
int eofflag;
|
|
|
|
u_long *cookies;
|
1994-05-24 10:09:53 +00:00
|
|
|
int ncookies;
|
|
|
|
};
|
|
|
|
|
2002-09-28 17:15:38 +00:00
|
|
|
static int
|
1994-05-24 10:09:53 +00:00
|
|
|
iso_uiodir(idp,dp,off)
|
|
|
|
struct isoreaddir *idp;
|
|
|
|
struct dirent *dp;
|
|
|
|
off_t off;
|
|
|
|
{
|
|
|
|
int error;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
dp->d_name[dp->d_namlen] = 0;
|
1997-04-10 15:05:38 +00:00
|
|
|
dp->d_reclen = GENERIC_DIRSIZ(dp);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (idp->uio->uio_resid < dp->d_reclen) {
|
1997-02-10 02:22:35 +00:00
|
|
|
idp->eofflag = 0;
|
|
|
|
return (-1);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (idp->cookies) {
|
1994-05-24 10:09:53 +00:00
|
|
|
if (idp->ncookies <= 0) {
|
1997-02-10 02:22:35 +00:00
|
|
|
idp->eofflag = 0;
|
|
|
|
return (-1);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
*idp->cookies++ = off;
|
1994-05-24 10:09:53 +00:00
|
|
|
--idp->ncookies;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1999-01-27 21:50:00 +00:00
|
|
|
if ((error = uiomove((caddr_t) dp,dp->d_reclen,idp->uio)) != 0)
|
1997-02-10 02:22:35 +00:00
|
|
|
return (error);
|
1994-05-24 10:09:53 +00:00
|
|
|
idp->uio_off = off;
|
1997-02-10 02:22:35 +00:00
|
|
|
return (0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2002-09-28 17:15:38 +00:00
|
|
|
static int
|
1994-05-24 10:09:53 +00:00
|
|
|
iso_shipdir(idp)
|
|
|
|
struct isoreaddir *idp;
|
|
|
|
{
|
|
|
|
struct dirent *dp;
|
|
|
|
int cl, sl, assoc;
|
|
|
|
int error;
|
|
|
|
char *cname, *sname;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
cl = idp->current.d_namlen;
|
|
|
|
cname = idp->current.d_name;
|
1994-09-26 00:32:59 +00:00
|
|
|
assoc = (cl > 1) && (*cname == ASSOCCHAR);
|
|
|
|
if (assoc) {
|
1994-05-24 10:09:53 +00:00
|
|
|
cl--;
|
|
|
|
cname++;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
dp = &idp->saveent;
|
|
|
|
sname = dp->d_name;
|
|
|
|
if (!(sl = dp->d_namlen)) {
|
|
|
|
dp = &idp->assocent;
|
|
|
|
sname = dp->d_name + 1;
|
|
|
|
sl = dp->d_namlen - 1;
|
|
|
|
}
|
|
|
|
if (sl > 0) {
|
|
|
|
if (sl != cl
|
|
|
|
|| bcmp(sname,cname,sl)) {
|
|
|
|
if (idp->assocent.d_namlen) {
|
1999-01-27 21:50:00 +00:00
|
|
|
if ((error = iso_uiodir(idp,&idp->assocent,idp->assocoff)) != 0)
|
1997-02-10 02:22:35 +00:00
|
|
|
return (error);
|
1994-05-24 10:09:53 +00:00
|
|
|
idp->assocent.d_namlen = 0;
|
|
|
|
}
|
|
|
|
if (idp->saveent.d_namlen) {
|
1999-01-27 21:50:00 +00:00
|
|
|
if ((error = iso_uiodir(idp,&idp->saveent,idp->saveoff)) != 0)
|
1997-02-10 02:22:35 +00:00
|
|
|
return (error);
|
1994-05-24 10:09:53 +00:00
|
|
|
idp->saveent.d_namlen = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1997-04-10 15:05:38 +00:00
|
|
|
idp->current.d_reclen = GENERIC_DIRSIZ(&idp->current);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (assoc) {
|
|
|
|
idp->assocoff = idp->curroff;
|
|
|
|
bcopy(&idp->current,&idp->assocent,idp->current.d_reclen);
|
|
|
|
} else {
|
|
|
|
idp->saveoff = idp->curroff;
|
|
|
|
bcopy(&idp->current,&idp->saveent,idp->current.d_reclen);
|
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
return (0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Vnode op for readdir
|
|
|
|
*/
|
1995-10-31 12:13:49 +00:00
|
|
|
static int
|
1994-05-24 10:09:53 +00:00
|
|
|
cd9660_readdir(ap)
|
|
|
|
struct vop_readdir_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
struct ucred *a_cred;
|
1997-02-10 02:22:35 +00:00
|
|
|
int *a_eofflag;
|
|
|
|
int *a_ncookies;
|
|
|
|
u_long *a_cookies;
|
1994-05-24 10:09:53 +00:00
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
register struct uio *uio = ap->a_uio;
|
|
|
|
struct isoreaddir *idp;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vnode *vdp = ap->a_vp;
|
|
|
|
struct iso_node *dp;
|
|
|
|
struct iso_mnt *imp;
|
|
|
|
struct buf *bp = NULL;
|
|
|
|
struct iso_directory_record *ep;
|
1994-05-24 10:09:53 +00:00
|
|
|
int entryoffsetinblock;
|
1997-02-10 02:22:35 +00:00
|
|
|
doff_t endsearch;
|
|
|
|
u_long bmask;
|
1994-05-24 10:09:53 +00:00
|
|
|
int error = 0;
|
|
|
|
int reclen;
|
1997-02-10 02:22:35 +00:00
|
|
|
u_short namelen;
|
1994-09-28 16:45:22 +00:00
|
|
|
int ncookies = 0;
|
1997-02-10 02:22:35 +00:00
|
|
|
u_long *cookies = NULL;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
dp = VTOI(vdp);
|
|
|
|
imp = dp->i_mnt;
|
|
|
|
bmask = imp->im_bmask;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
MALLOC(idp, struct isoreaddir *, sizeof(*idp), M_TEMP, M_WAITOK);
|
|
|
|
idp->saveent.d_namlen = idp->assocent.d_namlen = 0;
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* Is it worth trying to figure out the type?
|
|
|
|
*/
|
|
|
|
idp->saveent.d_type = idp->assocent.d_type = idp->current.d_type =
|
|
|
|
DT_UNKNOWN;
|
1994-05-24 10:09:53 +00:00
|
|
|
idp->uio = uio;
|
1997-02-10 02:22:35 +00:00
|
|
|
if (ap->a_ncookies == NULL) {
|
|
|
|
idp->cookies = NULL;
|
|
|
|
} else {
|
1994-09-28 16:45:22 +00:00
|
|
|
/*
|
|
|
|
* Guess the number of cookies needed.
|
|
|
|
*/
|
|
|
|
ncookies = uio->uio_resid / 16;
|
1997-02-10 02:22:35 +00:00
|
|
|
MALLOC(cookies, u_long *, ncookies * sizeof(u_int), M_TEMP,
|
|
|
|
M_WAITOK);
|
|
|
|
idp->cookies = cookies;
|
1994-09-28 16:45:22 +00:00
|
|
|
idp->ncookies = ncookies;
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
|
|
|
idp->eofflag = 1;
|
1994-05-24 10:09:53 +00:00
|
|
|
idp->curroff = uio->uio_offset;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if ((entryoffsetinblock = idp->curroff & bmask) &&
|
VFS mega cleanup commit (x/N)
1. Add new file "sys/kern/vfs_default.c" where default actions for
VOPs go. Implement proper defaults for ABORTOP, BWRITE, LEASE,
POLL, REVOKE and STRATEGY. Various stuff spread over the entire
tree belongs here.
2. Change VOP_BLKATOFF to a normal function in cd9660.
3. Kill VOP_BLKATOFF, VOP_TRUNCATE, VOP_VFREE, VOP_VALLOC. These
are private interface functions between UFS and the underlying
storage manager layer (FFS/LFS/MFS/EXT2FS). The functions now
live in struct ufsmount instead.
4. Remove a kludge of VOP_ functions in all filesystems, that did
nothing but obscure the simplicity and break the expandability.
If a filesystem doesn't implement VOP_FOO, it shouldn't have an
entry for it in its vnops table. The system will try to DTRT
if it is not implemented. There are still some cruft left, but
the bulk of it is done.
5. Fix another VCALL in vfs_cache.c (thanks Bruce!)
1997-10-16 10:50:27 +00:00
|
|
|
(error = cd9660_blkatoff(vdp, (off_t)idp->curroff, NULL, &bp))) {
|
1997-02-10 02:22:35 +00:00
|
|
|
FREE(idp, M_TEMP);
|
|
|
|
return (error);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
endsearch = dp->i_size;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
while (idp->curroff < endsearch) {
|
|
|
|
/*
|
|
|
|
* If offset is on a block boundary,
|
|
|
|
* read the next directory block.
|
|
|
|
* Release previous if it exists.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
if ((idp->curroff & bmask) == 0) {
|
1994-05-24 10:09:53 +00:00
|
|
|
if (bp != NULL)
|
|
|
|
brelse(bp);
|
1999-01-27 21:50:00 +00:00
|
|
|
if ((error =
|
|
|
|
cd9660_blkatoff(vdp, (off_t)idp->curroff, NULL, &bp)) != 0)
|
1994-05-24 10:09:53 +00:00
|
|
|
break;
|
|
|
|
entryoffsetinblock = 0;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Get pointer to next entry.
|
|
|
|
*/
|
|
|
|
ep = (struct iso_directory_record *)
|
1997-02-10 02:22:35 +00:00
|
|
|
((char *)bp->b_data + entryoffsetinblock);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
reclen = isonum_711(ep->length);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (reclen == 0) {
|
|
|
|
/* skip to next block, if any */
|
1997-02-10 02:22:35 +00:00
|
|
|
idp->curroff =
|
|
|
|
(idp->curroff & ~bmask) + imp->logical_block_size;
|
1994-05-24 10:09:53 +00:00
|
|
|
continue;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (reclen < ISO_DIRECTORY_RECORD_SIZE) {
|
|
|
|
error = EINVAL;
|
|
|
|
/* illegal entry, stop */
|
|
|
|
break;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (entryoffsetinblock + reclen > imp->logical_block_size) {
|
|
|
|
error = EINVAL;
|
|
|
|
/* illegal directory, so stop looking */
|
|
|
|
break;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
idp->current.d_namlen = isonum_711(ep->name_len);
|
|
|
|
|
|
|
|
if (reclen < ISO_DIRECTORY_RECORD_SIZE + idp->current.d_namlen) {
|
1996-03-14 21:44:32 +00:00
|
|
|
error = EINVAL;
|
|
|
|
/* illegal entry, stop */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-05-22 08:50:18 +00:00
|
|
|
/*
|
|
|
|
* The "inode number" is iso_start, not i_ino, as in
|
|
|
|
* cd9660_getattr().
|
|
|
|
*/
|
|
|
|
idp->current.d_fileno = isonum_711(ep->ext_attr_length) +
|
|
|
|
isonum_733(ep->extent);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
idp->curroff += reclen;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
switch (imp->iso_ftype) {
|
|
|
|
case ISO_FTYPE_RRIP:
|
1997-02-10 02:22:35 +00:00
|
|
|
cd9660_rrip_getname(ep,idp->current.d_name, &namelen,
|
1994-05-24 10:09:53 +00:00
|
|
|
&idp->current.d_fileno,imp);
|
1997-02-10 02:22:35 +00:00
|
|
|
idp->current.d_namlen = (u_char)namelen;
|
1994-05-24 10:09:53 +00:00
|
|
|
if (idp->current.d_namlen)
|
|
|
|
error = iso_uiodir(idp,&idp->current,idp->curroff);
|
|
|
|
break;
|
1995-01-16 17:03:29 +00:00
|
|
|
default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 || ISO_FTYPE_HIGH_SIERRA*/
|
1994-05-24 10:09:53 +00:00
|
|
|
strcpy(idp->current.d_name,"..");
|
1999-04-18 10:58:03 +00:00
|
|
|
if (idp->current.d_namlen == 1 && ep->name[0] == 0) {
|
1994-05-24 10:09:53 +00:00
|
|
|
idp->current.d_namlen = 1;
|
|
|
|
error = iso_uiodir(idp,&idp->current,idp->curroff);
|
1999-04-18 10:58:03 +00:00
|
|
|
} else if (idp->current.d_namlen == 1 && ep->name[0] == 1) {
|
1994-05-24 10:09:53 +00:00
|
|
|
idp->current.d_namlen = 2;
|
|
|
|
error = iso_uiodir(idp,&idp->current,idp->curroff);
|
1999-04-18 10:58:03 +00:00
|
|
|
} else {
|
1994-05-24 10:09:53 +00:00
|
|
|
isofntrans(ep->name,idp->current.d_namlen,
|
1997-02-10 02:22:35 +00:00
|
|
|
idp->current.d_name, &namelen,
|
1994-05-24 10:09:53 +00:00
|
|
|
imp->iso_ftype == ISO_FTYPE_9660,
|
1999-04-18 10:58:03 +00:00
|
|
|
isonum_711(ep->flags)&4,
|
|
|
|
imp->joliet_level);
|
1997-02-10 02:22:35 +00:00
|
|
|
idp->current.d_namlen = (u_char)namelen;
|
1994-05-24 10:09:53 +00:00
|
|
|
if (imp->iso_ftype == ISO_FTYPE_DEFAULT)
|
|
|
|
error = iso_shipdir(idp);
|
|
|
|
else
|
|
|
|
error = iso_uiodir(idp,&idp->current,idp->curroff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (error)
|
|
|
|
break;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
entryoffsetinblock += reclen;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (!error && imp->iso_ftype == ISO_FTYPE_DEFAULT) {
|
|
|
|
idp->current.d_namlen = 0;
|
|
|
|
error = iso_shipdir(idp);
|
|
|
|
}
|
|
|
|
if (error < 0)
|
|
|
|
error = 0;
|
1994-09-28 16:45:22 +00:00
|
|
|
|
|
|
|
if (ap->a_ncookies != NULL) {
|
|
|
|
if (error)
|
1997-02-10 02:22:35 +00:00
|
|
|
free(cookies, M_TEMP);
|
1994-09-28 16:45:22 +00:00
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Work out the number of cookies actually used.
|
|
|
|
*/
|
|
|
|
*ap->a_ncookies = ncookies - idp->ncookies;
|
|
|
|
*ap->a_cookies = cookies;
|
|
|
|
}
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (bp)
|
|
|
|
brelse (bp);
|
|
|
|
|
|
|
|
uio->uio_offset = idp->uio_off;
|
1997-02-10 02:22:35 +00:00
|
|
|
*ap->a_eofflag = idp->eofflag;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
FREE(idp, M_TEMP);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return target name of a symbolic link
|
|
|
|
* Shouldn't we get the parent vnode and read the data from there?
|
|
|
|
* This could eventually result in deadlocks in cd9660_lookup.
|
|
|
|
* But otherwise the block read here is in the block buffer two times.
|
|
|
|
*/
|
|
|
|
typedef struct iso_directory_record ISODIR;
|
1995-01-16 17:03:29 +00:00
|
|
|
typedef struct iso_node ISONODE;
|
|
|
|
typedef struct iso_mnt ISOMNT;
|
1995-10-31 12:13:49 +00:00
|
|
|
static int
|
1994-05-24 10:09:53 +00:00
|
|
|
cd9660_readlink(ap)
|
|
|
|
struct vop_readlink_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
ISONODE *ip;
|
1995-05-30 08:16:23 +00:00
|
|
|
ISODIR *dirp;
|
1994-05-24 10:09:53 +00:00
|
|
|
ISOMNT *imp;
|
|
|
|
struct buf *bp;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct uio *uio;
|
1994-05-24 10:09:53 +00:00
|
|
|
u_short symlen;
|
|
|
|
int error;
|
|
|
|
char *symname;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
ip = VTOI(ap->a_vp);
|
|
|
|
imp = ip->i_mnt;
|
1997-02-10 02:22:35 +00:00
|
|
|
uio = ap->a_uio;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (imp->iso_ftype != ISO_FTYPE_RRIP)
|
1997-02-10 02:22:35 +00:00
|
|
|
return (EINVAL);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Get parents directory record block that this inode included.
|
|
|
|
*/
|
|
|
|
error = bread(imp->im_devvp,
|
1997-02-10 02:22:35 +00:00
|
|
|
(ip->i_number >> imp->im_bshift) <<
|
|
|
|
(imp->im_bshift - DEV_BSHIFT),
|
|
|
|
imp->logical_block_size, NOCRED, &bp);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (error) {
|
|
|
|
brelse(bp);
|
1997-02-10 02:22:35 +00:00
|
|
|
return (EINVAL);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup the directory pointer for this inode
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
dirp = (ISODIR *)(bp->b_data + (ip->i_number & imp->im_bmask));
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Just make sure, we have a right one....
|
|
|
|
* 1: Check not cross boundary on block
|
|
|
|
*/
|
|
|
|
if ((ip->i_number & imp->im_bmask) + isonum_711(dirp->length)
|
1996-10-20 21:01:46 +00:00
|
|
|
> (unsigned)imp->logical_block_size) {
|
1994-05-24 10:09:53 +00:00
|
|
|
brelse(bp);
|
1997-02-10 02:22:35 +00:00
|
|
|
return (EINVAL);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Now get a buffer
|
|
|
|
* Abuse a namei buffer for now.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
if (uio->uio_segflg == UIO_SYSSPACE)
|
|
|
|
symname = uio->uio_iov->iov_base;
|
|
|
|
else
|
2002-03-20 10:17:00 +00:00
|
|
|
symname = uma_zalloc(namei_zone, M_WAITOK);
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Ok, we just gathering a symbolic name in SL record.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
if (cd9660_rrip_getsymname(dirp, symname, &symlen, imp) == 0) {
|
|
|
|
if (uio->uio_segflg != UIO_SYSSPACE)
|
2002-03-20 10:17:00 +00:00
|
|
|
uma_zfree(namei_zone, symname);
|
1994-05-24 10:09:53 +00:00
|
|
|
brelse(bp);
|
1997-02-10 02:22:35 +00:00
|
|
|
return (EINVAL);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Don't forget before you leave from home ;-)
|
|
|
|
*/
|
|
|
|
brelse(bp);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* return with the symbolic name to caller's.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
if (uio->uio_segflg != UIO_SYSSPACE) {
|
|
|
|
error = uiomove(symname, symlen, uio);
|
2002-03-20 10:17:00 +00:00
|
|
|
uma_zfree(namei_zone, symname);
|
1997-02-10 02:22:35 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
uio->uio_resid -= symlen;
|
2002-10-11 14:58:34 +00:00
|
|
|
uio->uio_iov->iov_base = (char *)uio->uio_iov->iov_base + symlen;
|
1997-02-10 02:22:35 +00:00
|
|
|
uio->uio_iov->iov_len -= symlen;
|
|
|
|
return (0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the logical to physical mapping if not done already,
|
|
|
|
* then call the device strategy routine.
|
|
|
|
*/
|
1995-10-31 12:13:49 +00:00
|
|
|
static int
|
1994-05-24 10:09:53 +00:00
|
|
|
cd9660_strategy(ap)
|
|
|
|
struct vop_strategy_args /* {
|
1998-07-04 20:45:42 +00:00
|
|
|
struct buf *a_vp;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct buf *a_bp;
|
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
register struct buf *bp = ap->a_bp;
|
|
|
|
register struct vnode *vp = bp->b_vp;
|
|
|
|
register struct iso_node *ip;
|
|
|
|
|
|
|
|
ip = VTOI(vp);
|
|
|
|
if (vp->v_type == VBLK || vp->v_type == VCHR)
|
|
|
|
panic("cd9660_strategy: spec");
|
|
|
|
if (bp->b_blkno == bp->b_lblkno) {
|
2001-04-30 21:23:05 +00:00
|
|
|
bp->b_blkno = (ip->iso_start + bp->b_lblkno) <<
|
|
|
|
(ip->i_mnt->im_bshift - DEV_BSHIFT);
|
|
|
|
if ((long)bp->b_blkno == -1) /* XXX: cut&paste junk ? */
|
1994-05-24 10:09:53 +00:00
|
|
|
clrbuf(bp);
|
|
|
|
}
|
2001-04-30 21:23:05 +00:00
|
|
|
if ((long)bp->b_blkno == -1) { /* XXX: cut&paste junk ? */
|
2000-04-15 05:54:02 +00:00
|
|
|
bufdone(bp);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
vp = ip->i_devvp;
|
|
|
|
bp->b_dev = vp->v_rdev;
|
1998-07-04 20:45:42 +00:00
|
|
|
VOP_STRATEGY(vp, bp);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Return POSIX pathconf information applicable to cd9660 filesystems.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1997-11-18 14:40:36 +00:00
|
|
|
static int
|
1997-02-10 02:22:35 +00:00
|
|
|
cd9660_pathconf(ap)
|
|
|
|
struct vop_pathconf_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_name;
|
|
|
|
register_t *a_retval;
|
|
|
|
} */ *ap;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
switch (ap->a_name) {
|
|
|
|
case _PC_LINK_MAX:
|
|
|
|
*ap->a_retval = 1;
|
|
|
|
return (0);
|
|
|
|
case _PC_NAME_MAX:
|
|
|
|
if (VTOI(ap->a_vp)->i_mnt->iso_ftype == ISO_FTYPE_RRIP)
|
|
|
|
*ap->a_retval = NAME_MAX;
|
|
|
|
else
|
|
|
|
*ap->a_retval = 37;
|
|
|
|
return (0);
|
|
|
|
case _PC_PATH_MAX:
|
|
|
|
*ap->a_retval = PATH_MAX;
|
|
|
|
return (0);
|
|
|
|
case _PC_PIPE_BUF:
|
|
|
|
*ap->a_retval = PIPE_BUF;
|
|
|
|
return (0);
|
|
|
|
case _PC_CHOWN_RESTRICTED:
|
|
|
|
*ap->a_retval = 1;
|
|
|
|
return (0);
|
|
|
|
case _PC_NO_TRUNC:
|
|
|
|
*ap->a_retval = 1;
|
|
|
|
return (0);
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Global vfs data structures for cd9660
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1995-11-09 08:17:23 +00:00
|
|
|
vop_t **cd9660_vnodeop_p;
|
1997-11-18 14:40:36 +00:00
|
|
|
static struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = {
|
1997-10-26 20:55:39 +00:00
|
|
|
{ &vop_default_desc, (vop_t *) vop_defaultop },
|
1997-10-15 09:22:02 +00:00
|
|
|
{ &vop_access_desc, (vop_t *) cd9660_access },
|
|
|
|
{ &vop_bmap_desc, (vop_t *) cd9660_bmap },
|
|
|
|
{ &vop_cachedlookup_desc, (vop_t *) cd9660_lookup },
|
|
|
|
{ &vop_getattr_desc, (vop_t *) cd9660_getattr },
|
1997-10-15 10:05:29 +00:00
|
|
|
{ &vop_inactive_desc, (vop_t *) cd9660_inactive },
|
1999-12-07 22:25:28 +00:00
|
|
|
{ &vop_ioctl_desc, (vop_t *) cd9660_ioctl },
|
1997-10-17 12:36:19 +00:00
|
|
|
{ &vop_islocked_desc, (vop_t *) vop_stdislocked },
|
|
|
|
{ &vop_lock_desc, (vop_t *) vop_stdlock },
|
1997-10-15 09:22:02 +00:00
|
|
|
{ &vop_lookup_desc, (vop_t *) vfs_cache_lookup },
|
1997-10-15 10:05:29 +00:00
|
|
|
{ &vop_pathconf_desc, (vop_t *) cd9660_pathconf },
|
2002-09-18 20:42:04 +00:00
|
|
|
{ &vop_print_desc, (vop_t *) vop_null },
|
1997-10-15 09:22:02 +00:00
|
|
|
{ &vop_read_desc, (vop_t *) cd9660_read },
|
|
|
|
{ &vop_readdir_desc, (vop_t *) cd9660_readdir },
|
1997-10-15 10:05:29 +00:00
|
|
|
{ &vop_readlink_desc, (vop_t *) cd9660_readlink },
|
1997-10-15 09:22:02 +00:00
|
|
|
{ &vop_reclaim_desc, (vop_t *) cd9660_reclaim },
|
|
|
|
{ &vop_setattr_desc, (vop_t *) cd9660_setattr },
|
1997-10-15 10:05:29 +00:00
|
|
|
{ &vop_strategy_desc, (vop_t *) cd9660_strategy },
|
1997-10-17 12:36:19 +00:00
|
|
|
{ &vop_unlock_desc, (vop_t *) vop_stdunlock },
|
1995-11-09 08:17:23 +00:00
|
|
|
{ NULL, NULL }
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-10-31 12:13:49 +00:00
|
|
|
static struct vnodeopv_desc cd9660_vnodeop_opv_desc =
|
1994-05-24 10:09:53 +00:00
|
|
|
{ &cd9660_vnodeop_p, cd9660_vnodeop_entries };
|
1994-09-21 03:47:43 +00:00
|
|
|
VNODEOP_SET(cd9660_vnodeop_opv_desc);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Special device vnode ops
|
|
|
|
*/
|
1995-11-09 08:17:23 +00:00
|
|
|
vop_t **cd9660_specop_p;
|
1997-11-18 14:40:36 +00:00
|
|
|
static struct vnodeopv_entry_desc cd9660_specop_entries[] = {
|
1997-10-15 13:24:07 +00:00
|
|
|
{ &vop_default_desc, (vop_t *) spec_vnoperate },
|
1997-10-15 09:22:02 +00:00
|
|
|
{ &vop_access_desc, (vop_t *) cd9660_access },
|
|
|
|
{ &vop_getattr_desc, (vop_t *) cd9660_getattr },
|
1997-10-15 10:05:29 +00:00
|
|
|
{ &vop_inactive_desc, (vop_t *) cd9660_inactive },
|
1997-10-17 12:36:19 +00:00
|
|
|
{ &vop_islocked_desc, (vop_t *) vop_stdislocked },
|
|
|
|
{ &vop_lock_desc, (vop_t *) vop_stdlock },
|
2002-09-18 20:42:04 +00:00
|
|
|
{ &vop_print_desc, (vop_t *) vop_null },
|
1997-10-15 09:22:02 +00:00
|
|
|
{ &vop_reclaim_desc, (vop_t *) cd9660_reclaim },
|
|
|
|
{ &vop_setattr_desc, (vop_t *) cd9660_setattr },
|
1997-10-17 12:36:19 +00:00
|
|
|
{ &vop_unlock_desc, (vop_t *) vop_stdunlock },
|
1995-11-09 08:17:23 +00:00
|
|
|
{ NULL, NULL }
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-10-31 12:13:49 +00:00
|
|
|
static struct vnodeopv_desc cd9660_specop_opv_desc =
|
1994-05-24 10:09:53 +00:00
|
|
|
{ &cd9660_specop_p, cd9660_specop_entries };
|
1994-09-21 03:47:43 +00:00
|
|
|
VNODEOP_SET(cd9660_specop_opv_desc);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1995-11-09 08:17:23 +00:00
|
|
|
vop_t **cd9660_fifoop_p;
|
1997-11-18 14:40:36 +00:00
|
|
|
static struct vnodeopv_entry_desc cd9660_fifoop_entries[] = {
|
1997-10-15 13:24:07 +00:00
|
|
|
{ &vop_default_desc, (vop_t *) fifo_vnoperate },
|
1997-10-15 09:22:02 +00:00
|
|
|
{ &vop_access_desc, (vop_t *) cd9660_access },
|
|
|
|
{ &vop_getattr_desc, (vop_t *) cd9660_getattr },
|
1997-10-15 10:05:29 +00:00
|
|
|
{ &vop_inactive_desc, (vop_t *) cd9660_inactive },
|
1997-10-17 12:36:19 +00:00
|
|
|
{ &vop_islocked_desc, (vop_t *) vop_stdislocked },
|
|
|
|
{ &vop_lock_desc, (vop_t *) vop_stdlock },
|
2002-09-18 20:42:04 +00:00
|
|
|
{ &vop_print_desc, (vop_t *) vop_null },
|
1997-10-15 09:22:02 +00:00
|
|
|
{ &vop_reclaim_desc, (vop_t *) cd9660_reclaim },
|
|
|
|
{ &vop_setattr_desc, (vop_t *) cd9660_setattr },
|
1997-10-17 12:36:19 +00:00
|
|
|
{ &vop_unlock_desc, (vop_t *) vop_stdunlock },
|
1995-11-09 08:17:23 +00:00
|
|
|
{ NULL, NULL }
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-10-31 12:13:49 +00:00
|
|
|
static struct vnodeopv_desc cd9660_fifoop_opv_desc =
|
1994-05-24 10:09:53 +00:00
|
|
|
{ &cd9660_fifoop_p, cd9660_fifoop_entries };
|
1994-09-21 03:47:43 +00:00
|
|
|
|
|
|
|
VNODEOP_SET(cd9660_fifoop_opv_desc);
|