Move HPFS to GEOM backing instead of DEVFS.

For details, please see src/sys/ufs/ffs/ffs_vfsops.c 1.250.
This commit is contained in:
Poul-Henning Kamp 2004-10-29 10:43:07 +00:00
parent 48b67bb7fd
commit a96d2ea768
3 changed files with 26 additions and 33 deletions

View File

@ -312,6 +312,8 @@ struct hpfsmount {
struct spblock hpm_sp;
struct mount * hpm_mp;
struct vnode * hpm_devvp;
struct g_consumer *hpm_cp;
struct bufobj *hpm_bo;
struct cdev *hpm_dev;
uid_t hpm_uid;
gid_t hpm_gid;

View File

@ -40,6 +40,9 @@
#include <sys/fcntl.h>
#include <sys/malloc.h>
#include <geom/geom.h>
#include <geom/geom_vfs.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
@ -212,48 +215,41 @@ hpfs_mountfs(devvp, mp, argsp, td)
struct hpfs_args *argsp;
struct thread *td;
{
int error, ncount, ronly;
int error, ronly;
struct sublock *sup;
struct spblock *spp;
struct hpfsmount *hpmp;
struct buf *bp = NULL;
struct vnode *vp;
struct cdev *dev = devvp->v_rdev;
struct g_consumer *cp;
struct bufobj *bo;
dprintf(("hpfs_mountfs():\n"));
/*
* Disallow multiple mounts of the same device.
* Disallow mounting of a device that is currently in use
* (except for root, which might share swap device for miniroot).
* Flush out any old buffers remaining from a previous use.
*/
error = vfs_mountedon(devvp);
if (error)
return (error);
ncount = vcount(devvp);
if (devvp->v_object)
ncount -= 1;
if (ncount > 1)
return (EBUSY);
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);
error = vinvalbuf(devvp, V_SAVE, td->td_ucred, td, 0, 0);
VOP_UNLOCK(devvp, 0, td);
if (error)
return (error);
ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);
error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td, -1);
/* XXX: use VOP_ACCESS to check FS perms */
DROP_GIANT();
g_topology_lock();
error = g_vfs_open(devvp, &cp, "hpfs", ronly ? 0 : 1);
g_topology_unlock();
PICKUP_GIANT();
VOP_UNLOCK(devvp, 0, td);
if (error)
return (error);
bo = &devvp->v_bufobj;
bo->bo_private = cp;
bo->bo_ops = g_vfs_bufops;
/*
* Do actual mount
*/
hpmp = malloc(sizeof(struct hpfsmount), M_HPFSMNT, M_WAITOK | M_ZERO);
hpmp->hpm_cp = cp;
hpmp->hpm_bo = bo;
/* Read in SuperBlock */
error = bread(devvp, SUBLOCK, SUSIZE, NOCRED, &bp);
if (error)
@ -314,15 +310,13 @@ hpfs_mountfs(devvp, mp, argsp, td)
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
mp->mnt_maxsymlinklen = 0;
mp->mnt_flag |= MNT_LOCAL;
devvp->v_rdev->si_mountpoint = mp;
return (0);
failed:
if (bp)
brelse (bp);
mp->mnt_data = (qaddr_t)NULL;
devvp->v_rdev->si_mountpoint = NULL;
(void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td);
g_wither_geom_close(cp->geom, ENXIO);
return (error);
}
@ -351,12 +345,8 @@ hpfs_unmount(
return (error);
}
hpmp->hpm_devvp->v_rdev->si_mountpoint = NULL;
vinvalbuf(hpmp->hpm_devvp, V_SAVE, NOCRED, td, 0, 0);
error = VOP_CLOSE(hpmp->hpm_devvp, ronly ? FREAD : FREAD|FWRITE,
NOCRED, td);
g_wither_geom_close(hpmp->hpm_cp->geom, ENXIO);
vrele(hpmp->hpm_devvp);
dprintf(("hpfs_umount: freeing memory...\n"));

View File

@ -648,6 +648,7 @@ hpfs_strategy(ap)
register struct vnode *vp = ap->a_vp;
register struct hpfsnode *hp = VTOHP(ap->a_vp);
daddr_t blkno;
struct bufobj *bo;
int error;
dprintf(("hpfs_strategy(): \n"));
@ -671,9 +672,9 @@ hpfs_strategy(ap)
bufdone(bp);
return (0);
}
bp->b_dev = hp->h_devvp->v_rdev;
bp->b_iooffset = dbtob(bp->b_blkno);
VOP_SPECSTRATEGY(hp->h_devvp, bp);
bo = hp->h_hpmp->hpm_bo;
bo->bo_ops->bop_strategy(bo, bp);
return (0);
}