summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantine Sapuntzakis <csapuntz@cvs.openbsd.org>1997-10-06 15:22:41 +0000
committerConstantine Sapuntzakis <csapuntz@cvs.openbsd.org>1997-10-06 15:22:41 +0000
commitf6f93dc700727c19153bc3f4580428f927dbfd6e (patch)
treef353031229e9a3357f91794f523e0750d191f2b0
parentba753b42bdeef75b997ea377a0fc9217fbd5ab67 (diff)
VFS Lite2 Changes
-rw-r--r--sys/msdosfs/msdosfs_denode.c21
-rw-r--r--sys/msdosfs/msdosfs_lookup.c31
-rw-r--r--sys/msdosfs/msdosfs_vfsops.c63
-rw-r--r--sys/msdosfs/msdosfs_vnops.c58
-rw-r--r--sys/msdosfs/msdosfsmount.h4
5 files changed, 88 insertions, 89 deletions
diff --git a/sys/msdosfs/msdosfs_denode.c b/sys/msdosfs/msdosfs_denode.c
index 0fcb2580df9..258e5632c71 100644
--- a/sys/msdosfs/msdosfs_denode.c
+++ b/sys/msdosfs/msdosfs_denode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_denode.c,v 1.5 1997/10/04 19:08:12 deraadt Exp $ */
+/* $OpenBSD: msdosfs_denode.c,v 1.6 1997/10/06 15:22:38 csapuntz Exp $ */
/* $NetBSD: msdosfs_denode.c,v 1.22 1996/10/13 04:16:31 christos Exp $ */
/*-
@@ -76,10 +76,13 @@ static struct denode *msdosfs_hashget __P((dev_t, u_long, u_long));
static void msdosfs_hashins __P((struct denode *));
static void msdosfs_hashrem __P((struct denode *));
-void
-msdosfs_init()
+/*ARGSUSED*/
+int
+msdosfs_init(vfsp)
+ struct vfsconf *vfsp;
{
dehashtbl = hashinit(desiredvnodes/2, M_MSDOSFSMNT, &dehash);
+ return (0);
}
static struct denode *
@@ -89,7 +92,8 @@ msdosfs_hashget(dev, dirclust, diroff)
u_long diroff;
{
struct denode *dep;
-
+ struct proc *p = curproc; /* XXX */
+
for (;;)
for (dep = dehashtbl[DEHASH(dev, dirclust, diroff)];;
dep = dep->de_next) {
@@ -104,7 +108,7 @@ msdosfs_hashget(dev, dirclust, diroff)
sleep(dep, PINOD);
break;
}
- if (!vget(DETOV(dep), 1))
+ if (!vget(DETOV(dep), LK_EXCLUSIVE, p))
return (dep);
break;
}
@@ -166,6 +170,7 @@ deget(pmp, dirclust, diroffset, depp)
struct denode *ldep;
struct vnode *nvp;
struct buf *bp;
+ struct proc *p = curproc; /* XXX */
#ifdef MSDOSFS_DEBUG
printf("deget(pmp %08x, dirclust %d, diroffset %x, depp %08x)\n",
@@ -218,7 +223,7 @@ deget(pmp, dirclust, diroffset, depp)
* can't be accessed until we've read it in and have done what we
* need to it.
*/
- VOP_LOCK(nvp);
+ vn_lock(nvp, LK_EXCLUSIVE | LK_RETRY, p);
msdosfs_hashins(ldep);
/*
@@ -562,9 +567,11 @@ msdosfs_inactive(v)
{
struct vop_inactive_args /* {
struct vnode *a_vp;
+ struct proc *a_p;
} */ *ap = v;
struct vnode *vp = ap->a_vp;
struct denode *dep = VTODE(vp);
+ struct proc *p = ap->a_p;
int error;
extern int prtactive;
@@ -608,7 +615,7 @@ msdosfs_inactive(v)
dep->de_Name[0] = SLOT_DELETED;
}
deupdat(dep, 0);
- VOP_UNLOCK(vp);
+ VOP_UNLOCK(vp, 0, p);
/*
* If we are done with the denode, reclaim it
* so that it can be reused immediately.
diff --git a/sys/msdosfs/msdosfs_lookup.c b/sys/msdosfs/msdosfs_lookup.c
index 58e4aa8edb7..42844deb5e3 100644
--- a/sys/msdosfs/msdosfs_lookup.c
+++ b/sys/msdosfs/msdosfs_lookup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_lookup.c,v 1.5 1997/03/02 18:01:57 millert Exp $ */
+/* $OpenBSD: msdosfs_lookup.c,v 1.6 1997/10/06 15:22:39 csapuntz Exp $ */
/* $NetBSD: msdosfs_lookup.c,v 1.30 1996/10/25 23:14:08 cgd Exp $ */
/*-
@@ -89,6 +89,7 @@ msdosfs_lookup(v)
struct vnode *vdp = ap->a_dvp;
struct vnode **vpp = ap->a_vpp;
struct componentname *cnp = ap->a_cnp;
+ struct proc *p = cnp->cn_proc;
daddr_t bn;
int error;
int lockparent;
@@ -161,14 +162,14 @@ msdosfs_lookup(v)
VREF(vdp);
error = 0;
} else if (flags & ISDOTDOT) {
- VOP_UNLOCK(pdp);
- error = vget(vdp, 1);
+ VOP_UNLOCK(pdp, 0, p);
+ error = vget(vdp, LK_EXCLUSIVE, p);
if (!error && lockparent && (flags & ISLASTCN))
- error = VOP_LOCK(pdp);
+ error = vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p);
} else {
- error = vget(vdp, 1);
+ error = vget(vdp, LK_EXCLUSIVE, p);
if (!lockparent || error || !(flags & ISLASTCN))
- VOP_UNLOCK(pdp);
+ VOP_UNLOCK(pdp, 0, p);
}
/*
* Check that the capability number did not change
@@ -184,9 +185,9 @@ msdosfs_lookup(v)
}
vput(vdp);
if (lockparent && pdp != vdp && (flags & ISLASTCN))
- VOP_UNLOCK(pdp);
+ VOP_UNLOCK(pdp, 0, p);
}
- if ((error = VOP_LOCK(pdp)) != 0)
+ if ((error = vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p)) != 0)
return (error);
vdp = pdp;
dp = VTODE(vdp);
@@ -414,7 +415,7 @@ notfound:;
*/
cnp->cn_flags |= SAVENAME;
if (!lockparent)
- VOP_UNLOCK(vdp);
+ VOP_UNLOCK(vdp, 0, p);
return (EJUSTRETURN);
}
/*
@@ -484,7 +485,7 @@ foundroot:;
return (error);
*vpp = DETOV(tdp);
if (!lockparent)
- VOP_UNLOCK(vdp);
+ VOP_UNLOCK(vdp, 0, p);
return (0);
}
@@ -512,7 +513,7 @@ foundroot:;
*vpp = DETOV(tdp);
cnp->cn_flags |= SAVENAME;
if (!lockparent)
- VOP_UNLOCK(vdp);
+ VOP_UNLOCK(vdp, 0, p);
return (0);
}
@@ -537,13 +538,13 @@ foundroot:;
*/
pdp = vdp;
if (flags & ISDOTDOT) {
- VOP_UNLOCK(pdp); /* race to get the inode */
+ VOP_UNLOCK(pdp, 0, p); /* race to get the inode */
if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0) {
- VOP_LOCK(pdp);
+ vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p);
return (error);
}
if (lockparent && (flags & ISLASTCN) &&
- (error = VOP_LOCK(pdp))) {
+ (error = vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p))) {
vput(DETOV(tdp));
return (error);
}
@@ -555,7 +556,7 @@ foundroot:;
if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0)
return (error);
if (!lockparent || !(flags & ISLASTCN))
- VOP_UNLOCK(pdp);
+ VOP_UNLOCK(pdp, 0, p);
*vpp = DETOV(tdp);
}
diff --git a/sys/msdosfs/msdosfs_vfsops.c b/sys/msdosfs/msdosfs_vfsops.c
index b77c0e9a93e..cf2a101328d 100644
--- a/sys/msdosfs/msdosfs_vfsops.c
+++ b/sys/msdosfs/msdosfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_vfsops.c,v 1.7 1997/06/20 14:04:30 kstailey Exp $ */
+/* $OpenBSD: msdosfs_vfsops.c,v 1.8 1997/10/06 15:22:39 csapuntz Exp $ */
/* $NetBSD: msdosfs_vfsops.c,v 1.44 1996/12/22 10:10:32 cgd Exp $ */
/*-
@@ -75,10 +75,8 @@ int msdosfs_mount __P((struct mount *, char *, caddr_t, struct nameidata *,
int msdosfs_start __P((struct mount *, int, struct proc *));
int msdosfs_unmount __P((struct mount *, int, struct proc *));
int msdosfs_root __P((struct mount *, struct vnode **));
-int msdosfs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *));
int msdosfs_statfs __P((struct mount *, struct statfs *, struct proc *));
int msdosfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
-int msdosfs_vget __P((struct mount *, ino_t, struct vnode **));
int msdosfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
struct vnode **, int *, struct ucred **));
int msdosfs_vptofh __P((struct vnode *, struct fid *));
@@ -121,10 +119,10 @@ msdosfs_mount(mp, path, data, ndp, p)
flags = WRITECLOSE;
if (mp->mnt_flag & MNT_FORCE)
flags |= FORCECLOSE;
- if (vfs_busy(mp))
+ if (vfs_busy(mp, 0, 0, p))
return (EBUSY);
error = vflush(mp, NULLVP, flags);
- vfs_unbusy(mp);
+ vfs_unbusy(mp, p);
}
if (!error && (mp->mnt_flag & MNT_RELOAD))
/* not yet implemented */
@@ -138,14 +136,14 @@ msdosfs_mount(mp, path, data, ndp, p)
*/
if (p->p_ucred->cr_uid != 0) {
devvp = pmp->pm_devvp;
- VOP_LOCK(devvp);
+ vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
error = VOP_ACCESS(devvp, VREAD | VWRITE,
p->p_ucred, p);
if (error) {
- VOP_UNLOCK(devvp);
+ VOP_UNLOCK(devvp, 0, p);
return (error);
}
- VOP_UNLOCK(devvp);
+ VOP_UNLOCK(devvp, 0, p);
}
pmp->pm_flags &= ~MSDOSFSMNT_RONLY;
}
@@ -189,13 +187,13 @@ msdosfs_mount(mp, path, data, ndp, p)
accessmode = VREAD;
if ((mp->mnt_flag & MNT_RDONLY) == 0)
accessmode |= VWRITE;
- VOP_LOCK(devvp);
+ vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p);
if (error) {
vput(devvp);
return (error);
}
- VOP_UNLOCK(devvp);
+ VOP_UNLOCK(devvp, 0, p);
}
if ((mp->mnt_flag & MNT_UPDATE) == 0)
error = msdosfs_mountfs(devvp, mp, p, &args);
@@ -514,7 +512,7 @@ msdosfs_mountfs(devvp, mp, p, argp)
* in the directory entry where we could put uid's and gid's.
*/
#endif
- devvp->v_specflags |= SI_MOUNTEDON;
+ devvp->v_specmountpoint = mp;
return (0);
@@ -561,7 +559,7 @@ msdosfs_unmount(mp, mntflags, p)
if ((error = vflush(mp, NULLVP, flags)) != 0)
return (error);
pmp = VFSTOMSDOSFS(mp);
- pmp->pm_devvp->v_specflags &= ~SI_MOUNTEDON;
+ pmp->pm_devvp->v_specmountpoint = NULL;
#ifdef MSDOSFS_DEBUG
printf("msdosfs_umount(): just before calling VOP_CLOSE()\n");
printf("flag %08x, usecount %d, writecount %d, holdcnt %d\n",
@@ -605,22 +603,6 @@ msdosfs_root(mp, vpp)
}
int
-msdosfs_quotactl(mp, cmds, uid, arg, p)
- struct mount *mp;
- int cmds;
- uid_t uid;
- caddr_t arg;
- struct proc *p;
-{
-
-#ifdef QUOTA
- return (EOPNOTSUPP);
-#else
- return (EOPNOTSUPP);
-#endif
-}
-
-int
msdosfs_statfs(mp, sbp, p)
struct mount *mp;
struct statfs *sbp;
@@ -645,7 +627,7 @@ msdosfs_statfs(mp, sbp, p)
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
}
- strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
+ strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
return (0);
}
@@ -689,9 +671,9 @@ loop:
dep = VTODE(vp);
if (((dep->de_flag
& (DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0)
- && (vp->v_dirtyblkhd.lh_first == NULL))
+ && (vp->v_dirtyblkhd.lh_first == NULL || waitfor == MNT_LAZY))
continue;
- if (vget(vp, 1))
+ if (vget(vp, LK_EXCLUSIVE, p))
goto loop;
if ((error = VOP_FSYNC(vp, cred, waitfor, p)) != 0)
allerror = error;
@@ -753,18 +735,16 @@ msdosfs_vptofh(vp, fhp)
return (0);
}
-int
-msdosfs_vget(mp, ino, vpp)
- struct mount *mp;
- ino_t ino;
- struct vnode **vpp;
-{
+#define msdosfs_vget ((int (*) __P((struct mount *, ino_t, struct vnode **))) \
+ eopnotsupp)
- return (EOPNOTSUPP);
-}
+#define msdosfs_quotactl ((int (*) __P((struct mount *, int, uid_t, caddr_t, \
+ struct proc *)))eopnotsupp)
+
+#define msdosfs_sysctl ((int (*) __P((int *, u_int, void *, size_t *, void *, \
+ size_t, struct proc *)))eopnotsupp)
struct vfsops msdosfs_vfsops = {
- MOUNT_MSDOS,
msdosfs_mount,
msdosfs_start,
msdosfs_unmount,
@@ -775,5 +755,6 @@ struct vfsops msdosfs_vfsops = {
msdosfs_vget,
msdosfs_fhtovp,
msdosfs_vptofh,
- msdosfs_init
+ msdosfs_init,
+ msdosfs_sysctl
};
diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c
index e792d1b2201..40ff8591d07 100644
--- a/sys/msdosfs/msdosfs_vnops.c
+++ b/sys/msdosfs/msdosfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_vnops.c,v 1.10 1997/10/04 19:08:13 deraadt Exp $ */
+/* $OpenBSD: msdosfs_vnops.c,v 1.11 1997/10/06 15:22:40 csapuntz Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.48 1996/03/20 00:45:43 thorpej Exp $ */
/*-
@@ -949,6 +949,7 @@ msdosfs_rename(v)
register struct vnode *fdvp = ap->a_fdvp;
register struct componentname *tcnp = ap->a_tcnp;
register struct componentname *fcnp = ap->a_fcnp;
+ struct proc *p = curproc; /* XXX */
register struct denode *ip, *xp, *dp, *zp;
u_char toname[11], oldname[11];
u_long from_diroffset, to_diroffset;
@@ -989,7 +990,7 @@ abortit:
}
/* */
- if ((error = VOP_LOCK(fvp)) != 0)
+ if ((error = vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, p)) != 0)
goto abortit;
dp = VTODE(fdvp);
ip = VTODE(fvp);
@@ -1009,7 +1010,7 @@ abortit:
(fcnp->cn_flags & ISDOTDOT) ||
(tcnp->cn_flags & ISDOTDOT) ||
(ip->de_flag & DE_RENAME)) {
- VOP_UNLOCK(fvp);
+ VOP_UNLOCK(fvp, 0, p);
error = EINVAL;
goto abortit;
}
@@ -1040,7 +1041,7 @@ abortit:
* call to doscheckpath().
*/
error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc);
- VOP_UNLOCK(fvp);
+ VOP_UNLOCK(fvp, 0, p);
if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster)
newparent = 1;
vrele(fdvp);
@@ -1106,7 +1107,7 @@ abortit:
if ((fcnp->cn_flags & SAVESTART) == 0)
panic("msdosfs_rename: lost from startdir");
if (!newparent)
- VOP_UNLOCK(tdvp);
+ VOP_UNLOCK(tdvp, 0, p);
(void) relookup(fdvp, &fvp, fcnp);
if (fvp == NULL) {
/*
@@ -1116,7 +1117,7 @@ abortit:
panic("rename: lost dir entry");
vrele(ap->a_fvp);
if (newparent)
- VOP_UNLOCK(tdvp);
+ VOP_UNLOCK(tdvp, 0, p);
vrele(tdvp);
return 0;
}
@@ -1136,9 +1137,9 @@ abortit:
if (doingdirectory)
panic("rename: lost dir entry");
vrele(ap->a_fvp);
- VOP_UNLOCK(fvp);
+ VOP_UNLOCK(fvp, 0, p);
if (newparent)
- VOP_UNLOCK(fdvp);
+ VOP_UNLOCK(fdvp, 0, p);
xp = NULL;
} else {
vrele(fvp);
@@ -1160,8 +1161,8 @@ abortit:
if (error) {
bcopy(oldname, ip->de_Name, 11);
if (newparent)
- VOP_UNLOCK(fdvp);
- VOP_UNLOCK(fvp);
+ VOP_UNLOCK(fdvp, 0, p);
+ VOP_UNLOCK(fvp, 0, p);
goto bad;
}
ip->de_refcnt++;
@@ -1169,8 +1170,8 @@ abortit:
if ((error = removede(zp, ip)) != 0) {
/* XXX should really panic here, fs is corrupt */
if (newparent)
- VOP_UNLOCK(fdvp);
- VOP_UNLOCK(fvp);
+ VOP_UNLOCK(fdvp, 0, p);
+ VOP_UNLOCK(fvp, 0, p);
goto bad;
}
if (!doingdirectory) {
@@ -1179,8 +1180,8 @@ abortit:
if (error) {
/* XXX should really panic here, fs is corrupt */
if (newparent)
- VOP_UNLOCK(fdvp);
- VOP_UNLOCK(fvp);
+ VOP_UNLOCK(fdvp, 0, p);
+ VOP_UNLOCK(fvp, 0, p);
goto bad;
}
if (ip->de_dirclust != MSDOSFSROOT)
@@ -1188,7 +1189,7 @@ abortit:
}
reinsert(ip);
if (newparent)
- VOP_UNLOCK(fdvp);
+ VOP_UNLOCK(fdvp, 0, p);
}
/*
@@ -1207,19 +1208,19 @@ abortit:
if (error) {
/* XXX should really panic here, fs is corrupt */
brelse(bp);
- VOP_UNLOCK(fvp);
+ VOP_UNLOCK(fvp, 0, p);
goto bad;
}
dotdotp = (struct direntry *)bp->b_data + 1;
putushort(dotdotp->deStartCluster, dp->de_StartCluster);
if ((error = bwrite(bp)) != 0) {
/* XXX should really panic here, fs is corrupt */
- VOP_UNLOCK(fvp);
+ VOP_UNLOCK(fvp, 0, p);
goto bad;
}
}
- VOP_UNLOCK(fvp);
+ VOP_UNLOCK(fvp, 0, p);
bad:
if (xp)
vput(tvp);
@@ -1463,8 +1464,8 @@ msdosfs_readdir(v)
struct uio *a_uio;
struct ucred *a_cred;
int *a_eofflag;
- u_long *a_cookies;
- int a_ncookies;
+ u_long **a_cookies;
+ int *a_ncookies;
} */ *ap = v;
int error = 0;
int diff;
@@ -1483,8 +1484,8 @@ msdosfs_readdir(v)
struct direntry *dentp;
struct dirent dirbuf;
struct uio *uio = ap->a_uio;
- u_long *cookies;
- int ncookies;
+ u_long *cookies = NULL;
+ int ncookies = 0;
off_t offset;
int chksum = -1;
@@ -1520,8 +1521,13 @@ msdosfs_readdir(v)
lost = uio->uio_resid - count;
uio->uio_resid = count;
- cookies = ap->a_cookies;
- ncookies = ap->a_ncookies;
+ if (ap->a_ncookies) {
+ ncookies = uio->uio_resid / sizeof(struct direntry) + 3;
+ MALLOC(cookies, u_long *, ncookies * sizeof(u_long), M_TEMP,
+ M_WAITOK);
+ *ap->a_cookies = cookies;
+ *ap->a_ncookies = ncookies;
+ }
/*
* If they are reading from the root directory then, we simulate
@@ -1681,6 +1687,10 @@ msdosfs_readdir(v)
}
out:
+ /* Subtract unused cookies */
+ if (ap->a_ncookies)
+ *ap->a_ncookies -= ncookies;
+
uio->uio_offset = offset;
uio->uio_resid += lost;
if (dep->de_FileSize - (offset - bias) <= 0)
diff --git a/sys/msdosfs/msdosfsmount.h b/sys/msdosfs/msdosfsmount.h
index 6c3e1a76410..04937d4db84 100644
--- a/sys/msdosfs/msdosfsmount.h
+++ b/sys/msdosfs/msdosfsmount.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfsmount.h,v 1.5 1997/03/02 18:02:02 millert Exp $ */
+/* $OpenBSD: msdosfsmount.h,v 1.6 1997/10/06 15:22:40 csapuntz Exp $ */
/* $NetBSD: msdosfsmount.h,v 1.15 1996/12/22 10:31:41 cgd Exp $ */
/*-
@@ -199,4 +199,4 @@ int msdosfs_statfs __P((struct mount *, struct statfs *, struct proc *));
int msdosfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
int msdosfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, struct vnode **, int *, struct ucred **));
int msdosfs_vptofh __P((struct vnode *, struct fid *));
-void msdosfs_init __P((void));
+int msdosfs_init __P((struct vfsconf *));