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/scsi/ssc.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 /* "superscsi" pseudo device.
    2  * "superscsi" supports general SCSI utilities that can iterate
    3  * over all SCSI targets, including those without device entry
    4  * points.
    5  *
    6  * "superscsi" supports the SCIOCADDR ioctl to change the BUS, ID, LUN
    7  * of the target so that you can get to all devices.  The only thing
    8  * you can do to "superscsi" is open it, set the target, perform ioctl
    9  * calls, and close it.
   10  *
   11  * Keep "superscsi" protected: you can drive a truck through the
   12  * security hole if you don't.
   13  *
   14  *Begin copyright
   15  *
   16  * Copyright (C) 1993, 1994, 1995, HD Associates, Inc.
   17  * PO Box 276
   18  * Pepperell, MA 01463
   19  * 508 433 5266
   20  * dufault@hda.com
   21  *
   22  * This code is contributed to the University of California at Berkeley:
   23  *
   24  * Redistribution and use in source and binary forms, with or without
   25  * modification, are permitted provided that the following conditions
   26  * are met:
   27  * 1. Redistributions of source code must retain the above copyright
   28  *    notice, this list of conditions and the following disclaimer.
   29  * 2. Redistributions in binary form must reproduce the above copyright
   30  *    notice, this list of conditions and the following disclaimer in the
   31  *    documentation and/or other materials provided with the distribution.
   32  * 3. All advertising materials mentioning features or use of this software
   33  *    must display the following acknowledgement:
   34  *      This product includes software developed by the University of
   35  *      California, Berkeley and its contributors.
   36  * 4. Neither the name of the University nor the names of its contributors
   37  *    may be used to endorse or promote products derived from this software
   38  *    without specific prior written permission.
   39  *
   40  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   41  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   42  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   43  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   44  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   45  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   46  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   48  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   49  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   50  * SUCH DAMAGE.
   51  *End copyright
   52  * $FreeBSD: src/sys/scsi/ssc.c,v 1.12.6.2 1999/09/05 08:21:50 peter Exp $
   53  */
   54 
   55 #include <sys/types.h>
   56 #include <sys/param.h>
   57 #include <sys/conf.h>
   58 #include <sys/disklabel.h>
   59 #include <sys/scsiio.h>
   60 #include <sys/kernel.h>
   61 #include <sys/errno.h>
   62 #include <sys/stat.h>
   63 #include <sys/buf.h>
   64 #include <sys/systm.h>
   65 #ifdef DEVFS
   66 #include <sys/devfsext.h>
   67 #endif /*DEVFS*/
   68 #include <scsi/scsiconf.h>
   69 
   70 static  d_open_t        sscopen;
   71 static  d_close_t       sscclose;
   72 static  d_ioctl_t       sscioctl;
   73 
   74 extern  d_open_t        suopen;
   75 extern  d_close_t       suclose;
   76 extern  d_ioctl_t       suioctl;
   77 
   78 #define CDEV_MAJOR 49
   79 static struct cdevsw ssc_cdevsw = 
   80         { sscopen,      sscclose,       noread,         nowrite,        /*49*/
   81           sscioctl,     nostop,         nullreset,      nodevtotty,
   82           noselect,     nommap,         nostrategy,     "ssc",  NULL,   -1 };
   83 
   84 static dev_t sscdev = NODEV;
   85 
   86 static  int
   87 sscopen(dev_t dev, int flag, int type, struct proc *p)
   88 {
   89         if (sscdev != NODEV)
   90                 return suopen(sscdev, flag, type, p);
   91         return 0;
   92 }
   93 
   94 static  int
   95 sscclose(dev_t dev, int fflag, int type, struct proc *p)
   96 {
   97 
   98         if (sscdev != NODEV)
   99                 return suclose(sscdev, fflag, type, p);
  100         return 0;
  101 }
  102 
  103 static  int
  104 sscioctl(dev_t dev, int cmd, caddr_t data, int fflag, struct proc *p)
  105 {
  106         if (cmd == SCIOCADDR)
  107         {
  108                 struct scsi_addr *sca;
  109                 dev_t newdev;
  110                 int ret;
  111 
  112                 sca = (struct scsi_addr *) data;
  113                 newdev = SCSI_MKFIXED(sca->scbus,sca->target,sca->lun,RAW_PART);
  114 
  115                 if (sscdev != NODEV)
  116                 {
  117                         suclose(sscdev, fflag, S_IFCHR, p);
  118                         sscdev = NODEV;
  119                 }
  120 
  121                 if ( (ret = suopen(newdev, fflag, S_IFCHR, p)) )
  122                         return ret;
  123 
  124                 sscdev = newdev;
  125 
  126                 return 0;
  127         }
  128 
  129         if (sscdev != NODEV)
  130                 return suioctl(sscdev, cmd, data, fflag, p);
  131 
  132         return ENXIO;
  133 }
  134 
  135 /*
  136  * I've elected not to support any other entries.  There really is no
  137  * good reason other than I'm not sure how you would use them.
  138  */
  139 
  140 static ssc_devsw_installed = 0;
  141 #ifdef DEVFS
  142 static  void *ssc_devfs_token;
  143 #endif
  144 
  145 static void
  146 ssc_drvinit(void *unused)
  147 {
  148         dev_t dev;
  149 
  150         if( ! ssc_devsw_installed ) {
  151                 dev = makedev(CDEV_MAJOR, 0);
  152                 cdevsw_add(&dev,&ssc_cdevsw, NULL);
  153                 ssc_devsw_installed = 1;
  154 #ifdef DEVFS
  155                 ssc_devfs_token = 
  156                         devfs_add_devswf(&ssc_cdevsw, 0, DV_CHR, 0, 0, 
  157                                          0600, "ssc");
  158 #endif
  159         }
  160 }
  161 
  162 SYSINIT(sscdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,ssc_drvinit,NULL)
  163 

Cache object: 3ef8287a5f7af843d737a9514ff43afe


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