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/fs/coda/coda_fbsd.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  *             Coda: an Experimental Distributed File System
    3  *                              Release 3.1
    4  * 
    5  *           Copyright (c) 1987-1998 Carnegie Mellon University
    6  *                          All Rights Reserved
    7  * 
    8  * Permission  to  use, copy, modify and distribute this software and its
    9  * documentation is hereby granted,  provided  that  both  the  copyright
   10  * notice  and  this  permission  notice  appear  in  all  copies  of the
   11  * software, derivative works or  modified  versions,  and  any  portions
   12  * thereof, and that both notices appear in supporting documentation, and
   13  * that credit is given to Carnegie Mellon University  in  all  documents
   14  * and publicity pertaining to direct or indirect use of this code or its
   15  * derivatives.
   16  * 
   17  * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS  KNOWN  TO  HAVE  BUGS,
   18  * SOME  OF  WHICH MAY HAVE SERIOUS CONSEQUENCES.  CARNEGIE MELLON ALLOWS
   19  * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.   CARNEGIE  MELLON
   20  * DISCLAIMS  ANY  LIABILITY  OF  ANY  KIND  FOR  ANY  DAMAGES WHATSOEVER
   21  * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE  OR  OF
   22  * ANY DERIVATIVE WORK.
   23  * 
   24  * Carnegie  Mellon  encourages  users  of  this  software  to return any
   25  * improvements or extensions that  they  make,  and  to  grant  Carnegie
   26  * Mellon the rights to redistribute these changes without encumbrance.
   27  * 
   28  *      @(#) src/sys/coda/coda_fbsd.cr,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
   29  */
   30 
   31 #include <sys/cdefs.h>
   32 __FBSDID("$FreeBSD$");
   33 
   34 #include <sys/param.h>
   35 #include <sys/systm.h>
   36 #include <sys/conf.h>
   37 #include <sys/fcntl.h>
   38 #include <sys/kernel.h>
   39 #include <sys/lock.h>
   40 #include <sys/malloc.h>
   41 #include <sys/module.h>
   42 #include <sys/ucred.h>
   43 #include <sys/vnode.h>
   44 
   45 #include <vm/vm.h>
   46 #include <vm/vnode_pager.h>
   47 
   48 #include <fs/coda/coda.h>
   49 #include <fs/coda/cnode.h>
   50 #include <fs/coda/coda_vnops.h>
   51 #include <fs/coda/coda_psdev.h>
   52 
   53 static struct cdevsw codadevsw = {
   54         .d_version =    D_VERSION,
   55         .d_flags =      D_NEEDGIANT,
   56         .d_open =       vc_nb_open,
   57         .d_close =      vc_nb_close,
   58         .d_read =       vc_nb_read,
   59         .d_write =      vc_nb_write,
   60         .d_ioctl =      vc_nb_ioctl,
   61         .d_poll =       vc_nb_poll,
   62         .d_name =       "Coda",
   63 };
   64 
   65 static eventhandler_tag clonetag;
   66 
   67 static LIST_HEAD(, coda_mntinfo) coda_mnttbl;
   68 
   69 int     vcdebug = 1;
   70 #define VCDEBUG if (vcdebug) printf
   71 
   72 /* for DEVFS, using bpf & tun drivers as examples*/
   73 static void coda_fbsd_clone(void *arg, struct ucred *cred, char *name,
   74     int namelen, struct cdev **dev);
   75 
   76 static int
   77 codadev_modevent(module_t mod, int type, void *data)
   78 {
   79         struct coda_mntinfo     *mnt;
   80 
   81         switch (type) {
   82         case MOD_LOAD:
   83                 LIST_INIT(&coda_mnttbl);
   84                 clonetag = EVENTHANDLER_REGISTER(dev_clone, coda_fbsd_clone,
   85                     0, 1000);
   86                 break;
   87         case MOD_UNLOAD:
   88                 EVENTHANDLER_DEREGISTER(dev_clone, clonetag);
   89                 while ((mnt = LIST_FIRST(&coda_mnttbl)) != NULL) {
   90                         LIST_REMOVE(mnt, mi_list);
   91                         destroy_dev(mnt->dev);
   92                         free(mnt, M_CODA);
   93                 }
   94                 break;
   95 
   96         default:
   97                 return (EOPNOTSUPP);
   98         }
   99         return 0;
  100 }
  101 static moduledata_t codadev_mod = {
  102         "codadev",
  103         codadev_modevent,
  104         NULL
  105 };
  106 DECLARE_MODULE(codadev, codadev_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
  107 
  108 static void coda_fbsd_clone(arg, cred, name, namelen, dev)
  109     void *arg;
  110     struct ucred *cred;
  111     char *name;
  112     int namelen;
  113     struct cdev **dev;
  114 {
  115     int u;
  116     struct coda_mntinfo *mnt;
  117 
  118     if (*dev != NULL)
  119         return;
  120     if (dev_stdclone(name,NULL,"cfs",&u) != 1)
  121         return;
  122 
  123     *dev = make_dev(&codadevsw,unit2minor(u),UID_ROOT,GID_WHEEL,0600,"cfs%d",u);
  124     dev_ref(*dev);
  125     mnt = malloc(sizeof(struct coda_mntinfo), M_CODA, M_WAITOK|M_ZERO);
  126     LIST_INSERT_HEAD(&coda_mnttbl, mnt, mi_list);
  127     mnt->dev = *dev;
  128 }
  129 
  130 struct coda_mntinfo *
  131 dev2coda_mntinfo(struct cdev *dev)
  132 {
  133         struct coda_mntinfo     *mnt;
  134 
  135         LIST_FOREACH(mnt, &coda_mnttbl, mi_list) {
  136                 if (mnt->dev == dev)
  137                         return mnt;
  138         }
  139 
  140         return NULL;
  141 }

Cache object: e6aad47dafbda029cbdf4dc2dcc0eee2


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