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. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * @(#)ufs_vfsops.c 8.8 (Berkeley) 5/20/95
35 * $FreeBSD: src/sys/ufs/ufs/ufs_vfsops.c,v 1.17.2.3 2001/10/14 19:08:16 iedowse Exp $
38 #include "opt_quota.h"
40 #include <sys/param.h>
41 #include <sys/kernel.h>
42 #include <sys/mount.h>
45 #include <sys/malloc.h>
46 #include <sys/vnode.h>
51 #include "ufs_extern.h"
53 MALLOC_DEFINE(M_UFSMNT, "UFS mount", "UFS mount structure");
55 * Return the root of a filesystem.
58 ufs_root(struct mount *mp, struct vnode **vpp)
63 error = VFS_VGET(mp, NULL, (ino_t)UFS_ROOTINO, &nvp);
71 * Do operations associated with quotas
74 ufs_quotactl(struct mount *mp, int cmds, uid_t uid, caddr_t arg,
82 type = cmds & SUBCMDMASK;
83 cmd = cmds >> SUBCMDSHIFT;
104 error = priv_check_cred(cred, PRIV_UFS_QUOTAON, 0);
108 error = priv_check_cred(cred, PRIV_UFS_QUOTAOFF, 0);
112 error = priv_check_cred(cred, PRIV_VFS_SETQUOTA, 0);
116 error = priv_check_cred(cred, PRIV_UFS_SETUSE, 0);
120 if (uid == cred->cr_ruid)
123 error = priv_check_cred(cred, PRIV_VFS_GETQUOTA, 0);
139 if ((uint)type >= MAXQUOTAS)
141 if (vfs_busy(mp, LK_NOWAIT))
147 error = ufs_quotaon(cred, mp, type, arg);
151 error = ufs_quotaoff(mp, type);
155 error = ufs_setquota(mp, uid, type, arg);
159 error = ufs_setuse(mp, uid, type, arg);
163 error = ufs_getquota(mp, uid, type, arg);
167 error = ufs_qsync(mp);
180 * Initial UFS filesystems, done only once.
183 ufs_init(struct vfsconf *vfsp)
197 * This is the generic part of fhtovp called after the underlying
198 * filesystem has validated the file handle.
200 * Call the VFS_CHECKEXP beforehand to verify access.
203 ufs_fhtovp(struct mount *mp, struct vnode *rootvp,
204 struct ufid *ufhp, struct vnode **vpp)
210 error = VFS_VGET(mp, NULL, ufhp->ufid_ino, &nvp);
216 if (ip->i_mode == 0 ||
217 ip->i_gen != ufhp->ufid_gen ||
218 (VFSTOUFS(mp)->um_i_effnlink_valid ? ip->i_effnlink :
230 * This is the generic part of fhtovp called after the underlying
231 * filesystem has validated the file handle.
233 * Verify that a host should have access to a filesystem.
236 ufs_check_export(struct mount *mp, struct sockaddr *nam, int *exflagsp,
237 struct ucred **credanonp)
240 struct ufsmount *ump;
244 * Get the export permission structure for this <mp, client> tuple.
246 np = vfs_export_lookup(mp, &ump->um_export, nam);
250 *exflagsp = np->netc_exflags;
251 *credanonp = &np->netc_anon;