/* * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * %sccs.include.redist.c% * * @(#)ufs_vfsops.c 8.3 (Berkeley) 01/21/94 */ #include #include #include #include #include #include #include #include #include #include #include #include /* * Flag to permit forcible unmounting. */ int doforce = 1; /* * Make a filesystem operational. * Nothing to do at the moment. */ /* ARGSUSED */ int ufs_start(mp, flags, p) struct mount *mp; int flags; struct proc *p; { return (0); } /* * Do operations associated with quotas */ int ufs_quotactl(mp, cmds, uid, arg, p) struct mount *mp; int cmds; uid_t uid; caddr_t arg; struct proc *p; { int cmd, type, error; #ifndef QUOTA return (EOPNOTSUPP); #else if (uid == -1) uid = p->p_cred->p_ruid; cmd = cmds >> SUBCMDSHIFT; switch (cmd) { case Q_GETQUOTA: case Q_SYNC: if (uid == p->p_cred->p_ruid) break; /* fall through */ default: if (error = suser(p->p_ucred, &p->p_acflag)) return (error); } type = cmd & SUBCMDMASK; if ((u_int)type >= MAXQUOTAS) return (EINVAL); switch (cmd) { case Q_QUOTAON: return (quotaon(p, mp, type, arg)); case Q_QUOTAOFF: if (vfs_busy(mp)) return (0); error = quotaoff(p, mp, type); vfs_unbusy(mp); return (error); case Q_SETQUOTA: return (setquota(mp, uid, type, arg)); case Q_SETUSE: return (setuse(mp, uid, type, arg)); case Q_GETQUOTA: return (getquota(mp, uid, type, arg)); case Q_SYNC: if (vfs_busy(mp)) return (0); error = qsync(mp); vfs_unbusy(mp); return (error); default: return (EINVAL); } /* NOTREACHED */ #endif } /* * This is the generic part of fhtovp called after the underlying * filesystem has validated the file handle. * * Verify that a host should have access to a filesystem, and if so * return a vnode for the presented file handle. */ int ufs_check_export(mp, ufhp, nam, vpp, exflagsp, credanonp) register struct mount *mp; struct ufid *ufhp; struct mbuf *nam; struct vnode **vpp; int *exflagsp; struct ucred **credanonp; { register struct inode *ip; register struct netcred *np; register struct ufsmount *ump = VFSTOUFS(mp); struct vnode *nvp; int error; /* * Get the export permission structure for this tuple. */ np = vfs_export_lookup(mp, &ump->um_export, nam); if (np == NULL) return (EACCES); if (error = VFS_VGET(mp, ufhp->ufid_ino, &nvp)) { *vpp = NULLVP; return (error); } ip = VTOI(nvp); if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen) { vput(nvp); *vpp = NULLVP; return (ESTALE); } *vpp = nvp; *exflagsp = np->netc_exflags; *credanonp = &np->netc_anon; return (0); }