root/ufs/ufs/ufs_vfsops.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ufs_start
  2. ufs_root
  3. ufs_check_export
  4. ufs_init
  5. ufs_fhtovp

    1 /*      $OpenBSD: ufs_vfsops.c,v 1.15 2006/04/04 11:21:40 pedro Exp $   */
    2 /*      $NetBSD: ufs_vfsops.c,v 1.4 1996/02/09 22:36:12 christos Exp $  */
    3 
    4 /*
    5  * Copyright (c) 1991, 1993, 1994
    6  *      The Regents of the University of California.  All rights reserved.
    7  * (c) UNIX System Laboratories, Inc.
    8  * All or some portions of this file are derived from material licensed
    9  * to the University of California by American Telephone and Telegraph
   10  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
   11  * the permission of UNIX System Laboratories, Inc.
   12  *
   13  * Redistribution and use in source and binary forms, with or without
   14  * modification, are permitted provided that the following conditions
   15  * are met:
   16  * 1. Redistributions of source code must retain the above copyright
   17  *    notice, this list of conditions and the following disclaimer.
   18  * 2. Redistributions in binary form must reproduce the above copyright
   19  *    notice, this list of conditions and the following disclaimer in the
   20  *    documentation and/or other materials provided with the distribution.
   21  * 3. Neither the name of the University nor the names of its contributors
   22  *    may be used to endorse or promote products derived from this software
   23  *    without specific prior written permission.
   24  *
   25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   35  * SUCH DAMAGE.
   36  *
   37  *      @(#)ufs_vfsops.c        8.4 (Berkeley) 4/16/94
   38  */
   39 
   40 #include <sys/param.h>
   41 #include <sys/mbuf.h>
   42 #include <sys/mount.h>
   43 #include <sys/proc.h>
   44 #include <sys/buf.h>
   45 #include <sys/vnode.h>
   46 #include <sys/malloc.h>
   47 
   48 #include <miscfs/specfs/specdev.h>
   49 
   50 #include <ufs/ufs/quota.h>
   51 #include <ufs/ufs/inode.h>
   52 #include <ufs/ufs/ufsmount.h>
   53 #include <ufs/ufs/ufs_extern.h>
   54 #ifdef UFS_DIRHASH
   55 #include <ufs/ufs/dir.h>
   56 #include <ufs/ufs/dirhash.h>
   57 #endif
   58 
   59 /*
   60  * Make a filesystem operational.
   61  * Nothing to do at the moment.
   62  */
   63 /* ARGSUSED */
   64 int
   65 ufs_start(struct mount *mp, int flags, struct proc *p)
   66 {
   67         return (0);
   68 }
   69 
   70 /*
   71  * Return the root of a filesystem.
   72  */
   73 int
   74 ufs_root(struct mount *mp, struct vnode **vpp)
   75 {
   76         struct vnode *nvp;
   77         int error;
   78 
   79         if ((error = VFS_VGET(mp, (ino_t)ROOTINO, &nvp)) != 0)
   80                 return (error);
   81         *vpp = nvp;
   82         return (0);
   83 }
   84 
   85 /*
   86  * Verify a remote client has export rights and return these rights via.
   87  * exflagsp and credanonp.
   88  */
   89 int
   90 ufs_check_export(struct mount *mp, struct mbuf *nam, int *exflagsp,
   91     struct ucred **credanonp) 
   92 {
   93         struct netcred *np;
   94         struct ufsmount *ump = VFSTOUFS(mp);
   95 
   96         /*
   97          * Get the export permission structure for this <mp, client> tuple.
   98          */
   99         np = vfs_export_lookup(mp, &ump->um_export, nam);
  100         if (np == NULL)
  101                 return (EACCES);
  102 
  103         *exflagsp = np->netc_exflags;
  104         *credanonp = &np->netc_anon;
  105         return (0);
  106 }
  107 
  108 /*
  109  * Initialize UFS file systems, done only once.
  110  */
  111 int
  112 ufs_init(struct vfsconf *vfsp)
  113 {
  114         static int done;
  115 
  116         if (done)
  117                 return (0);
  118         done = 1;
  119         ufs_ihashinit();
  120         ufs_quota_init();
  121 #ifdef UFS_DIRHASH
  122         ufsdirhash_init();
  123 #endif
  124 
  125         return (0);
  126 }
  127 
  128 /*
  129  * This is the generic part of fhtovp called after the underlying
  130  * filesystem has validated the file handle.
  131  */
  132 int
  133 ufs_fhtovp(struct mount *mp, struct ufid *ufhp, struct vnode **vpp)
  134 {
  135         struct inode *ip;
  136         struct vnode *nvp;
  137         int error;
  138 
  139         if ((error = VFS_VGET(mp, ufhp->ufid_ino, &nvp)) != 0) {
  140                 *vpp = NULLVP;
  141                 return (error);
  142         }
  143         ip = VTOI(nvp);
  144         if (DIP(ip, mode) == 0 || DIP(ip, gen) != ufhp->ufid_gen) {
  145                 vput(nvp);
  146                 *vpp = NULLVP;
  147                 return (ESTALE);
  148         }
  149         *vpp = nvp;
  150         return (0);
  151 }

/* [<][>][^][v][top][bottom][index][help] */