2 * Copyright (c) 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * @(#)ufs_vfsops.c 8.8 (Berkeley) 5/20/95
39 * $Id: ufs_vfsops.c,v 1.12 1998/11/10 09:16:28 peter Exp $
42 #include "opt_quota.h"
44 #include <sys/param.h>
45 #include <sys/kernel.h>
46 #include <sys/mount.h>
48 #include <sys/malloc.h>
49 #include <sys/vnode.h>
51 #include <ufs/ufs/quota.h>
52 #include <ufs/ufs/inode.h>
53 #include <ufs/ufs/ufsmount.h>
54 #include <ufs/ufs/ufs_extern.h>
56 MALLOC_DEFINE(M_UFSMNT, "UFS mount", "UFS mount structure");
58 * Make a filesystem operational.
59 * Nothing to do at the moment.
63 ufs_start(mp, flags, p)
73 * Return the root of a filesystem.
83 error = VFS_VGET(mp, (ino_t)ROOTINO, &nvp);
91 * Do operations associated with quotas
94 ufs_quotactl(mp, cmds, uid, arg, p)
104 int cmd, type, error;
107 uid = p->p_cred->p_ruid;
108 cmd = cmds >> SUBCMDSHIFT;
114 if (uid == p->p_cred->p_ruid)
118 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
122 type = cmds & SUBCMDMASK;
123 if ((u_int)type >= MAXQUOTAS)
125 if (vfs_busy(mp, LK_NOWAIT, 0, p))
131 error = quotaon(p, mp, type, arg);
135 error = quotaoff(p, mp, type);
139 error = setquota(mp, uid, type, arg);
143 error = setuse(mp, uid, type, arg);
147 error = getquota(mp, uid, type, arg);
164 * Initial UFS filesystems, done only once.
168 struct vfsconf *vfsp;
183 * This is the generic part of fhtovp called after the underlying
184 * filesystem has validated the file handle.
186 * Verify that a host should have access to a filesystem, and if so
187 * return a vnode for the presented file handle.
190 ufs_check_export(mp, ufhp, nam, vpp, exflagsp, credanonp)
191 register struct mount *mp;
193 struct sockaddr *nam;
196 struct ucred **credanonp;
198 register struct inode *ip;
199 register struct netcred *np;
200 register struct ufsmount *ump = VFSTOUFS(mp);
205 * Get the export permission structure for this <mp, client> tuple.
207 np = vfs_export_lookup(mp, &ump->um_export, nam);
211 error = VFS_VGET(mp, ufhp->ufid_ino, &nvp);
217 if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen) {
223 *exflagsp = np->netc_exflags;
224 *credanonp = &np->netc_anon;