The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/ufs/ufs/ufs_vfsops.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: ufs_vfsops.c,v 1.18 2003/08/07 16:34:47 agc Exp $      */
    2 
    3 /*
    4  * Copyright (c) 1991, 1993, 1994
    5  *      The Regents of the University of California.  All rights reserved.
    6  * (c) UNIX System Laboratories, Inc.
    7  * All or some portions of this file are derived from material licensed
    8  * to the University of California by American Telephone and Telegraph
    9  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
   10  * the permission of UNIX System Laboratories, Inc.
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  * 1. Redistributions of source code must retain the above copyright
   16  *    notice, this list of conditions and the following disclaimer.
   17  * 2. Redistributions in binary form must reproduce the above copyright
   18  *    notice, this list of conditions and the following disclaimer in the
   19  *    documentation and/or other materials provided with the distribution.
   20  * 3. Neither the name of the University nor the names of its contributors
   21  *    may be used to endorse or promote products derived from this software
   22  *    without specific prior written permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   34  * SUCH DAMAGE.
   35  *
   36  *      @(#)ufs_vfsops.c        8.8 (Berkeley) 5/20/95
   37  */
   38 
   39 #include <sys/cdefs.h>
   40 __KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.18 2003/08/07 16:34:47 agc Exp $");
   41 
   42 #include "opt_quota.h"
   43 
   44 #include <sys/param.h>
   45 #include <sys/mbuf.h>
   46 #include <sys/mount.h>
   47 #include <sys/proc.h>
   48 #include <sys/buf.h>
   49 #include <sys/vnode.h>
   50 #include <sys/malloc.h>
   51 
   52 #include <miscfs/specfs/specdev.h>
   53 
   54 #include <ufs/ufs/quota.h>
   55 #include <ufs/ufs/inode.h>
   56 #include <ufs/ufs/ufsmount.h>
   57 #include <ufs/ufs/ufs_extern.h>
   58 
   59 /* how many times ufs_init() was called */
   60 int ufs_initcount = 0;
   61 
   62 /*
   63  * Make a filesystem operational.
   64  * Nothing to do at the moment.
   65  */
   66 /* ARGSUSED */
   67 int
   68 ufs_start(mp, flags, p)
   69         struct mount *mp;
   70         int flags;
   71         struct proc *p;
   72 {
   73 
   74         return (0);
   75 }
   76 
   77 /*
   78  * Return the root of a filesystem.
   79  */
   80 int
   81 ufs_root(mp, vpp)
   82         struct mount *mp;
   83         struct vnode **vpp;
   84 {
   85         struct vnode *nvp;
   86         int error;
   87 
   88         if ((error = VFS_VGET(mp, (ino_t)ROOTINO, &nvp)) != 0)
   89                 return (error);
   90         *vpp = nvp;
   91         return (0);
   92 }
   93 
   94 /*
   95  * Do operations associated with quotas
   96  */
   97 int
   98 ufs_quotactl(mp, cmds, uid, arg, p)
   99         struct mount *mp;
  100         int cmds;
  101         uid_t uid;
  102         caddr_t arg;
  103         struct proc *p;
  104 {
  105 
  106 #ifndef QUOTA
  107         return (EOPNOTSUPP);
  108 #else
  109         int cmd, type, error;
  110 
  111         if (uid == -1)
  112                 uid = p->p_cred->p_ruid;
  113         cmd = cmds >> SUBCMDSHIFT;
  114 
  115         switch (cmd) {
  116         case Q_SYNC:
  117                 break;
  118         case Q_GETQUOTA:
  119                 if (uid == p->p_cred->p_ruid)
  120                         break;
  121                 /* fall through */
  122         default:
  123                 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
  124                         return (error);
  125         }
  126 
  127         type = cmds & SUBCMDMASK;
  128         if ((u_int)type >= MAXQUOTAS)
  129                 return (EINVAL);
  130         if (vfs_busy(mp, LK_NOWAIT, 0))
  131                 return (0);
  132 
  133         switch (cmd) {
  134 
  135         case Q_QUOTAON:
  136                 error = quotaon(p, mp, type, arg);
  137                 break;
  138 
  139         case Q_QUOTAOFF:
  140                 error = quotaoff(p, mp, type);
  141                 break;
  142 
  143         case Q_SETQUOTA:
  144                 error = setquota(mp, uid, type, arg);
  145                 break;
  146 
  147         case Q_SETUSE:
  148                 error = setuse(mp, uid, type, arg);
  149                 break;
  150 
  151         case Q_GETQUOTA:
  152                 error = getquota(mp, uid, type, arg);
  153                 break;
  154 
  155         case Q_SYNC:
  156                 error = qsync(mp);
  157                 break;
  158 
  159         default:
  160                 error = EINVAL;
  161         }
  162         vfs_unbusy(mp);
  163         return (error);
  164 #endif
  165 }
  166 
  167 /*
  168  * Verify a remote client has export rights and return these rights via.
  169  * exflagsp and credanonp.
  170  */
  171 int
  172 ufs_check_export(mp, nam, exflagsp, credanonp)
  173         struct mount *mp;
  174         struct mbuf *nam;
  175         int *exflagsp;
  176         struct ucred **credanonp;
  177 {
  178         struct netcred *np;
  179         struct ufsmount *ump = VFSTOUFS(mp);
  180 
  181         /*
  182          * Get the export permission structure for this <mp, client> tuple.
  183          */
  184         np = vfs_export_lookup(mp, &ump->um_export, nam);
  185         if (np == NULL)
  186                 return (EACCES);
  187 
  188         *exflagsp = np->netc_exflags;
  189         *credanonp = &np->netc_anon;
  190         return (0);
  191 }
  192 
  193 /*
  194  * This is the generic part of fhtovp called after the underlying
  195  * filesystem has validated the file handle.
  196  */
  197 int
  198 ufs_fhtovp(mp, ufhp, vpp)
  199         struct mount *mp;
  200         struct ufid *ufhp;
  201         struct vnode **vpp;
  202 {
  203         struct vnode *nvp;
  204         struct inode *ip;
  205         int error;
  206 
  207         if ((error = VFS_VGET(mp, ufhp->ufid_ino, &nvp)) != 0) {
  208                 *vpp = NULLVP;
  209                 return (error);
  210         }
  211         ip = VTOI(nvp);
  212         if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen) {
  213                 vput(nvp);
  214                 *vpp = NULLVP;
  215                 return (ESTALE);
  216         }
  217         *vpp = nvp;
  218         return (0);
  219 }
  220 
  221 /*
  222  * Initialize UFS filesystems, done only once.
  223  */
  224 void
  225 ufs_init()
  226 {
  227         if (ufs_initcount++ > 0)
  228                 return;
  229 
  230         ufs_ihashinit();
  231 #ifdef QUOTA
  232         dqinit();
  233 #endif
  234 }
  235 
  236 void
  237 ufs_reinit()
  238 {
  239         ufs_ihashreinit();
  240 #ifdef QUOTA
  241         dqreinit();
  242 #endif
  243 }
  244 
  245 /*
  246  * Free UFS filesystem resources, done only once.
  247  */
  248 void
  249 ufs_done()
  250 {
  251         if (--ufs_initcount > 0)
  252                 return;
  253 
  254         ufs_ihashdone();
  255 #ifdef QUOTA
  256         dqdone();
  257 #endif
  258 }

Cache object: e9458ecf811fe3f4b039927ce006783d


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.