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 /*
    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.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   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.
   25  *
   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
   36  * SUCH DAMAGE.
   37  *
   38  *      @(#)ufs_vfsops.c        8.8 (Berkeley) 5/20/95
   39  */
   40 
   41 #include <sys/cdefs.h>
   42 __FBSDID("$FreeBSD: releng/5.2/sys/ufs/ufs/ufs_vfsops.c 116384 2003-06-15 06:36:19Z rwatson $");
   43 
   44 #include "opt_quota.h"
   45 #include "opt_ufs.h"
   46 
   47 #include <sys/param.h>
   48 #include <sys/systm.h>
   49 #include <sys/kernel.h>
   50 #include <sys/lock.h>
   51 #include <sys/malloc.h>
   52 #include <sys/mount.h>
   53 #include <sys/proc.h>
   54 #include <sys/socket.h>
   55 #include <sys/vnode.h>
   56 
   57 #include <ufs/ufs/extattr.h>
   58 #include <ufs/ufs/quota.h>
   59 #include <ufs/ufs/inode.h>
   60 #include <ufs/ufs/ufsmount.h>
   61 #include <ufs/ufs/ufs_extern.h>
   62 #ifdef UFS_DIRHASH
   63 #include <ufs/ufs/dir.h>
   64 #include <ufs/ufs/dirhash.h>
   65 #endif
   66 
   67 MALLOC_DEFINE(M_UFSMNT, "UFS mount", "UFS mount structure");
   68 /*
   69  * Make a filesystem operational.
   70  * Nothing to do at the moment.
   71  */
   72 /* ARGSUSED */
   73 int
   74 ufs_start(mp, flags, td)
   75         struct mount *mp;
   76         int flags;
   77         struct thread *td;
   78 {
   79 
   80         return (0);
   81 }
   82 
   83 /*
   84  * Return the root of a filesystem.
   85  */
   86 int
   87 ufs_root(mp, vpp)
   88         struct mount *mp;
   89         struct vnode **vpp;
   90 {
   91         struct vnode *nvp;
   92         int error;
   93 
   94         error = VFS_VGET(mp, (ino_t)ROOTINO, LK_EXCLUSIVE, &nvp);
   95         if (error)
   96                 return (error);
   97         *vpp = nvp;
   98         return (0);
   99 }
  100 
  101 /*
  102  * Do operations associated with quotas
  103  */
  104 int
  105 ufs_quotactl(mp, cmds, uid, arg, td)
  106         struct mount *mp;
  107         int cmds;
  108         uid_t uid;
  109         caddr_t arg;
  110         struct thread *td;
  111 {
  112 #ifndef QUOTA
  113         return (EOPNOTSUPP);
  114 #else
  115         int cmd, type, error;
  116 
  117         if (uid == -1)
  118                 uid = td->td_ucred->cr_ruid;
  119         cmd = cmds >> SUBCMDSHIFT;
  120         type = cmds & SUBCMDMASK;
  121         if ((u_int)type >= MAXQUOTAS)
  122                 return (EINVAL);
  123 
  124         if (vfs_busy(mp, LK_NOWAIT, 0, td))
  125                 return (0);
  126 
  127         switch (cmd) {
  128         case Q_QUOTAON:
  129                 error = quotaon(td, mp, type, arg);
  130                 break;
  131 
  132         case Q_QUOTAOFF:
  133                 error = quotaoff(td, mp, type);
  134                 break;
  135 
  136         case Q_SETQUOTA:
  137                 error = setquota(td, mp, uid, type, arg);
  138                 break;
  139 
  140         case Q_SETUSE:
  141                 error = setuse(td, mp, uid, type, arg);
  142                 break;
  143 
  144         case Q_GETQUOTA:
  145                 error = getquota(td, mp, uid, type, arg);
  146                 break;
  147 
  148         case Q_SYNC:
  149                 error = qsync(mp);
  150                 break;
  151 
  152         default:
  153                 error = EINVAL;
  154                 break;
  155         }
  156         vfs_unbusy(mp, td);
  157         return (error);
  158 #endif
  159 }
  160 
  161 /*
  162  * Initial UFS filesystems, done only once.
  163  */
  164 int
  165 ufs_init(vfsp)
  166         struct vfsconf *vfsp;
  167 {
  168 
  169         ufs_ihashinit();
  170 #ifdef QUOTA
  171         dqinit();
  172 #endif
  173 #ifdef UFS_DIRHASH
  174         ufsdirhash_init();
  175 #endif
  176         return (0);
  177 }
  178 
  179 /*
  180  * Uninitialise UFS filesystems, done before module unload.
  181  */
  182 int
  183 ufs_uninit(vfsp)
  184         struct vfsconf *vfsp;
  185 {
  186 
  187         ufs_ihashuninit();
  188 #ifdef QUOTA
  189         dquninit();
  190 #endif
  191 #ifdef UFS_DIRHASH
  192         ufsdirhash_uninit();
  193 #endif
  194         return (0);
  195 }
  196 
  197 /*
  198  * This is the generic part of fhtovp called after the underlying
  199  * filesystem has validated the file handle.
  200  *
  201  * Call the VFS_CHECKEXP beforehand to verify access.
  202  */
  203 int
  204 ufs_fhtovp(mp, ufhp, vpp)
  205         struct mount *mp;
  206         struct ufid *ufhp;
  207         struct vnode **vpp;
  208 {
  209         struct inode *ip;
  210         struct vnode *nvp;
  211         int error;
  212 
  213         error = VFS_VGET(mp, ufhp->ufid_ino, LK_EXCLUSIVE, &nvp);
  214         if (error) {
  215                 *vpp = NULLVP;
  216                 return (error);
  217         }
  218         ip = VTOI(nvp);
  219         if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen ||
  220             ip->i_effnlink <= 0) {
  221                 vput(nvp);
  222                 *vpp = NULLVP;
  223                 return (ESTALE);
  224         }
  225         *vpp = nvp;
  226         return (0);
  227 }

Cache object: 655366f6148a9ddef905d1aa41ee1c7d


[ 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.