Exemplo n.º 1
0
/*
 * nremove takes a locked, resolved ncp that generally represents a
 * positive hit and removes the file.
 *
 * The dvp passed in is referenced but unlocked.
 *
 * The namecache is automatically adjusted by this function.  The ncp
 * is left locked on return.
 *
 * MPSAFE
 */
int
vop_nremove(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
	    struct ucred *cred)
{
	struct vop_nremove_args ap;
	VFS_MPLOCK_DECLARE;
	int error;
	struct vattr va;

	ap.a_head.a_desc = &vop_nremove_desc;
	ap.a_head.a_ops = ops;
	ap.a_nch = nch;
	ap.a_dvp = dvp;
	ap.a_cred = cred;

	if ((error = VOP_GETATTR(nch->ncp->nc_vp, &va)) != 0)
		return (error);

	VFS_MPLOCK1(dvp->v_mount);
	DO_OPS(ops, error, &ap, vop_nremove);
	/* Only update space counters if this is the last hard link */
	if ((error == 0) && (va.va_nlink == 1)) {
		VFS_ACCOUNT(nch->mount, va.va_uid, va.va_gid, -va.va_size);
	}
	VFS_MPUNLOCK(dvp->v_mount);
	return(error);
}
Exemplo n.º 2
0
/*
 * NOTE: VAGE is always cleared when calling VOP_OPEN().
 */
int
vop_open(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
	struct file *fp)
{
	struct vop_open_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	/*
	 * Decrement 3-2-1-0.  Does not decrement beyond 0
	 */
	if (vp->v_flag & VAGE0) {
		vclrflags(vp, VAGE0);
	} else if (vp->v_flag & VAGE1) {
		vclrflags(vp, VAGE1);
		vsetflags(vp, VAGE0);
	}

	ap.a_head.a_desc = &vop_open_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_fp = fp;
	ap.a_mode = mode;
	ap.a_cred = cred;

	VFS_MPLOCK1(vp->v_mount);
	DO_OPS(ops, error, &ap, vop_open);
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}
Exemplo n.º 3
0
/*
 * MPSAFE
 */
int
vfs_vget(struct mount *mp, struct vnode *dvp, ino_t ino, struct vnode **vpp)
{
	VFS_MPLOCK_DECLARE;
	int error;

	VFS_MPLOCK1(mp);
	error = (mp->mnt_op->vfs_vget)(mp, dvp, ino, vpp);
	VFS_MPUNLOCK(mp);
	return (error);
}
Exemplo n.º 4
0
int
vfs_statvfs(struct mount *mp, struct statvfs *sbp, struct ucred *cred)
{
	VFS_MPLOCK_DECLARE;
	int error;

	VFS_MPLOCK1(mp);
	error = (mp->mnt_op->vfs_statvfs)(mp, sbp, cred);
	VFS_MPUNLOCK(mp);
	return (error);
}
Exemplo n.º 5
0
/*
 * MPSAFE
 */
int
vfs_sync(struct mount *mp, int waitfor)
{
	VFS_MPLOCK_DECLARE;
	int error;

	VFS_MPLOCK1(mp);
	error = (mp->mnt_op->vfs_sync)(mp, waitfor);
	VFS_MPUNLOCK(mp);
	return (error);
}
Exemplo n.º 6
0
/*
 * MPSAFE
 */
int
vfs_root(struct mount *mp, struct vnode **vpp)
{
	VFS_MPLOCK_DECLARE;
	int error;

	VFS_MPLOCK1(mp);
	error = (mp->mnt_op->vfs_root)(mp, vpp);
	VFS_MPUNLOCK(mp);
	return (error);
}
Exemplo n.º 7
0
/*
 * MPSAFE
 */
int
vfs_unmount(struct mount *mp, int mntflags)
{
	VFS_MPLOCK_DECLARE;
	int error;

	VFS_MPLOCK1(mp);
	error = (mp->mnt_op->vfs_unmount)(mp, mntflags);
	VFS_MPUNLOCK(mp);
	return (error);
}
Exemplo n.º 8
0
/*
 * MPSAFE
 */
int
vfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
{
	VFS_MPLOCK_DECLARE;
	int error;

	VFS_MPLOCK1(mp);
	error = (mp->mnt_op->vfs_mount)(mp, path, data, cred);
	VFS_MPUNLOCK(mp);
	return (error);
}
Exemplo n.º 9
0
/*
 * MPSAFE
 */
int
vfs_vptofh(struct vnode *vp, struct fid *fhp)
{
	VFS_MPLOCK_DECLARE;
	int error;

	VFS_MPLOCK1(vp->v_mount);
	error = (vp->v_mount->mnt_op->vfs_vptofh)(vp, fhp);
	VFS_MPUNLOCK(vp->v_mount);
	return (error);
}
Exemplo n.º 10
0
/*
 * MPSAFE
 */
int
vfs_checkexp(struct mount *mp, struct sockaddr *nam,
	     int *extflagsp, struct ucred **credanonp)
{
	VFS_MPLOCK_DECLARE;
	int error;

	VFS_MPLOCK1(mp);
	error = (mp->mnt_op->vfs_checkexp)(mp, nam, extflagsp, credanonp);
	VFS_MPUNLOCK(mp);
	return (error);
}
Exemplo n.º 11
0
/*
 * MPSAFE
 */
int
vfs_fhtovp(struct mount *mp, struct vnode *rootvp,
	   struct fid *fhp, struct vnode **vpp)
{
	VFS_MPLOCK_DECLARE;
	int error;

	VFS_MPLOCK1(mp);
	error = (mp->mnt_op->vfs_fhtovp)(mp, rootvp, fhp, vpp);
	VFS_MPUNLOCK(mp);
	return (error);
}
Exemplo n.º 12
0
/*
 * MPSAFE
 */
int
vfs_quotactl(struct mount *mp, int cmds, uid_t uid, caddr_t arg,
	     struct ucred *cred)
{
	VFS_MPLOCK_DECLARE;
	int error;

	VFS_MPLOCK1(mp);
	error = (mp->mnt_op->vfs_quotactl)(mp, cmds, uid, arg, cred);
	VFS_MPUNLOCK(mp);
	return (error);
}
Exemplo n.º 13
0
/*
 * MPSAFE
 */
int
vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
	struct ucred *cred)
{
	struct vop_write_args ap;
	VFS_MPLOCK_DECLARE;
	int error, do_accounting = 0;
	struct vattr va;
	uint64_t size_before=0, size_after=0;
	struct mount *mp;
	uint64_t offset, delta;

	ap.a_head.a_desc = &vop_write_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_uio = uio;
	ap.a_ioflag = ioflag;
	ap.a_cred = cred;

	/* is this a regular vnode ? */
	VFS_MPLOCK_FLAG(vp->v_mount, MNTK_WR_MPSAFE);
	if (vfs_quota_enabled && (vp->v_type == VREG)) {
		if ((error = VOP_GETATTR(vp, &va)) != 0)
			goto done;
		size_before = va.va_size;
		/* this file may already have been removed */
		if (va.va_nlink > 0)
			do_accounting = 1;

		offset = uio->uio_offset;
		if (ioflag & IO_APPEND)
			offset = size_before;
		size_after = offset + uio->uio_resid;
		if (size_after < size_before)
			size_after = size_before;
		delta = size_after - size_before;
		mp = vq_vptomp(vp);
		/* QUOTA CHECK */
		if (!vq_write_ok(mp, va.va_uid, va.va_gid, delta)) {
			error = EDQUOT;
			goto done;
		}
	}
	DO_OPS(ops, error, &ap, vop_write);
	if ((error == 0) && do_accounting) {
		VFS_ACCOUNT(mp, va.va_uid, va.va_gid, size_after - size_before);
	}
done:
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}
Exemplo n.º 14
0
/*
 * MPSAFE
 */
int
vfs_unmount(struct mount *mp, int mntflags)
{
    VFS_MPLOCK_DECLARE;
    int error;

    VFS_MPLOCK1(mp);
    if (mp->mnt_kern_flag & MNTK_THR_SYNC)
        vn_syncer_thr_stop(mp);
    error = (mp->mnt_op->vfs_acdone)(mp);
    if (error == 0)
        error = (mp->mnt_op->vfs_unmount)(mp, mntflags);
    VFS_MPUNLOCK(mp);
    return (error);
}
Exemplo n.º 15
0
/*
 * MPSAFE
 */
int
vfs_extattrctl(struct mount *mp, int cmd, struct vnode *vp,
		 int attrnamespace, const char *attrname,
		 struct ucred *cred)
{
	VFS_MPLOCK_DECLARE;
	int error;

	VFS_MPLOCK1(mp);
	error = (mp->mnt_op->vfs_extattrctl)(mp, cmd, vp,
					     attrnamespace, attrname,
					     cred);
	VFS_MPUNLOCK(mp);
	return (error);
}
Exemplo n.º 16
0
/*
 * MPSAFE
 */
int
vop_print(struct vop_ops *ops, struct vnode *vp)
{
	struct vop_print_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_print_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;

	VFS_MPLOCK1(vp->v_mount);
	DO_OPS(ops, error, &ap, vop_print);
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}
Exemplo n.º 17
0
/*
 * MPSAFE
 */
int
vfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
{
    VFS_MPLOCK_DECLARE;
    int error;

    VFS_MPLOCK1(mp);
    error = (mp->mnt_op->vfs_mount)(mp, path, data, cred);
    if (error == 0) {
        /* Create per-filesystem syncer threads if requested */
        if ((mp->mnt_flag & MNT_UPDATE) == 0 &&
                (mp->mnt_kern_flag & MNTK_THR_SYNC))
            vn_syncer_thr_create(mp);
    }
    VFS_MPUNLOCK(mp);
    return (error);
}
Exemplo n.º 18
0
/*
 * MPSAFE
 */
int
vop_close(struct vop_ops *ops, struct vnode *vp, int fflag)
{
	struct vop_close_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_close_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_fflag = fflag;

	VFS_MPLOCK1(vp->v_mount);
	DO_OPS(ops, error, &ap, vop_close);
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}
Exemplo n.º 19
0
/*
 * MPSAFE
 */
int
vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
{
	struct vop_kqfilter_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_kqfilter_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_kn = kn;

	VFS_MPLOCK1(vp->v_mount);
	DO_OPS(ops, error, &ap, vop_kqfilter);
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}
Exemplo n.º 20
0
/*
 * MPSAFE
 */
int
vop_markatime(struct vop_ops *ops, struct vnode *vp, struct ucred *cred)
{
	struct vop_markatime_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_markatime_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_cred = cred;

	VFS_MPLOCK1(vp->v_mount);
	DO_OPS(ops, error, &ap, vop_markatime);
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}
Exemplo n.º 21
0
/*
 * MPSAFE
 */
int
vfs_start(struct mount *mp, int flags)
{
    VFS_MPLOCK_DECLARE;
    int error;

    VFS_MPLOCK_FLAG(mp, MNTK_ST_MPSAFE);
    error = (mp->mnt_op->vfs_start)(mp, flags);
    if (error == 0)
        /* do not call vfs_acinit on mount updates */
        if ((mp->mnt_flag & MNT_UPDATE) == 0)
            error = (mp->mnt_op->vfs_acinit)(mp);
    VFS_MPUNLOCK(mp);
    if (error == EMOUNTEXIT)
        error = 0;
    return (error);
}
Exemplo n.º 22
0
/*
 * MPSAFE
 */
int
vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred)
{
	struct vop_poll_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_poll_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_events = events;
	ap.a_cred = cred;

	VFS_MPLOCK1(vp->v_mount);
	DO_OPS(ops, error, &ap, vop_poll);
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}
Exemplo n.º 23
0
/*
 * MPSAFE
 */
int
vop_getattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap)
{
	struct vop_getattr_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_getattr_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_vap = vap;

	VFS_MPLOCK_FLAG(vp->v_mount, MNTK_GA_MPSAFE);
	DO_OPS(ops, error, &ap, vop_getattr);
	VFS_MPUNLOCK(vp->v_mount);

	return(error);
}
Exemplo n.º 24
0
int
vop_old_lookup(struct vop_ops *ops, struct vnode *dvp,
	struct vnode **vpp, struct componentname *cnp)
{
	struct vop_old_lookup_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_old_lookup_desc;
	ap.a_head.a_ops = ops;
	ap.a_dvp = dvp;
	ap.a_vpp = vpp;
	ap.a_cnp = cnp;
	VFS_MPLOCK1(dvp->v_mount);
	DO_OPS(ops, error, &ap, vop_old_lookup);
	VFS_MPUNLOCK(dvp->v_mount);
	return(error);
}
Exemplo n.º 25
0
/*
 * MPSAFE
 */
int
vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor, int flags)
{
	struct vop_fsync_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_fsync_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_waitfor = waitfor;
	ap.a_flags = flags;

	VFS_MPLOCK1(vp->v_mount);
	DO_OPS(ops, error, &ap, vop_fsync);
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}
Exemplo n.º 26
0
/*
 * MPSAFE
 */
int
vop_freeblks(struct vop_ops *ops, struct vnode *vp, off_t offset, int length)
{
	struct vop_freeblks_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_freeblks_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_offset = offset;
	ap.a_length = length;

	VFS_MPLOCK1(vp->v_mount);
	DO_OPS(ops, error, &ap, vop_freeblks);
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}
Exemplo n.º 27
0
/*
 * MPSAFE
 */
int
vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
	struct cluster_save *buflist)
{
	struct vop_reallocblks_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_reallocblks_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_buflist = buflist;

	VFS_MPLOCK1(vp->v_mount);
	DO_OPS(ops, error, &ap, vop_reallocblks);
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}
Exemplo n.º 28
0
/*
 * MPSAFE
 */
int
vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred)
{
	struct vop_mmap_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_mmap_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_fflags = fflags;
	ap.a_cred = cred;

	VFS_MPLOCK(vp->v_mount);
	DO_OPS(ops, error, &ap, vop_mmap);
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}
Exemplo n.º 29
0
/*
 * MPSAFE
 */
int
vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
	register_t *retval)
{
	struct vop_pathconf_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_pathconf_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_name = name;
	ap.a_retval = retval;

	VFS_MPLOCK1(vp->v_mount);
	DO_OPS(ops, error, &ap, vop_pathconf);
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}
Exemplo n.º 30
0
/*
 * MPSAFE
 */
int
vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
	struct ucred *cred)
{
	struct vop_readlink_args ap;
	VFS_MPLOCK_DECLARE;
	int error;

	ap.a_head.a_desc = &vop_readlink_desc;
	ap.a_head.a_ops = ops;
	ap.a_vp = vp;
	ap.a_uio = uio;
	ap.a_cred = cred;

	VFS_MPLOCK1(vp->v_mount);
	DO_OPS(ops, error, &ap, vop_readlink);
	VFS_MPUNLOCK(vp->v_mount);
	return(error);
}