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 * $FreeBSD: src/sys/ufs/ufs/ufs_vfsops.c,v 1.17.2.3 2001/10/14 19:08:16 iedowse Exp $
40 * $DragonFly: src/sys/vfs/ufs/ufs_vfsops.c,v 1.17 2008/09/17 21:44:25 dillon Exp $
43 #include "opt_quota.h"
45 #include <sys/param.h>
46 #include <sys/kernel.h>
47 #include <sys/mount.h>
50 #include <sys/malloc.h>
51 #include <sys/vnode.h>
56 #include "ufs_extern.h"
58 MALLOC_DEFINE(M_UFSMNT, "UFS mount", "UFS mount structure");
60 * Return the root of a filesystem.
63 ufs_root(struct mount *mp, struct vnode **vpp)
68 error = VFS_VGET(mp, NULL, (ino_t)ROOTINO, &nvp);
76 * Do operations associated with quotas
79 ufs_quotactl(struct mount *mp, int cmds, uid_t uid, caddr_t arg,
87 type = cmds & SUBCMDMASK;
88 cmd = cmds >> SUBCMDSHIFT;
109 error = priv_check_cred(cred, PRIV_UFS_QUOTAON, 0);
113 error = priv_check_cred(cred, PRIV_UFS_QUOTAOFF, 0);
117 error = priv_check_cred(cred, PRIV_VFS_SETQUOTA, 0);
121 error = priv_check_cred(cred, PRIV_UFS_SETUSE, 0);
125 if (uid == cred->cr_ruid)
128 error = priv_check_cred(cred, PRIV_VFS_GETQUOTA, 0);
144 if ((uint)type >= MAXQUOTAS)
146 if (vfs_busy(mp, LK_NOWAIT))
152 error = ufs_quotaon(cred, mp, type, arg);
156 error = ufs_quotaoff(mp, type);
160 error = ufs_setquota(mp, uid, type, arg);
164 error = ufs_setuse(mp, uid, type, arg);
168 error = ufs_getquota(mp, uid, type, arg);
172 error = ufs_qsync(mp);
185 * Initial UFS filesystems, done only once.
188 ufs_init(struct vfsconf *vfsp)
202 * This is the generic part of fhtovp called after the underlying
203 * filesystem has validated the file handle.
205 * Call the VFS_CHECKEXP beforehand to verify access.
208 ufs_fhtovp(struct mount *mp, struct vnode *rootpv,
209 struct ufid *ufhp, struct vnode **vpp)
215 error = VFS_VGET(mp, NULL, ufhp->ufid_ino, &nvp);
221 if (ip->i_mode == 0 ||
222 ip->i_gen != ufhp->ufid_gen ||
223 (VFSTOUFS(mp)->um_i_effnlink_valid ? ip->i_effnlink :
235 * This is the generic part of fhtovp called after the underlying
236 * filesystem has validated the file handle.
238 * Verify that a host should have access to a filesystem.
241 ufs_check_export(struct mount *mp, struct sockaddr *nam, int *exflagsp,
242 struct ucred **credanonp)
245 struct ufsmount *ump;
249 * Get the export permission structure for this <mp, client> tuple.
251 np = vfs_export_lookup(mp, &ump->um_export, nam);
255 *exflagsp = np->netc_exflags;
256 *credanonp = &np->netc_anon;