BSD 4_4_Lite2 release
[unix-history] / usr / src / sys / hp300 / dev / sd.c
index 373011f..95475a9 100644 (file)
@@ -5,9 +5,35 @@
  * This code is derived from software contributed to Berkeley by
  * Van Jacobson of Lawrence Berkeley Laboratory.
  *
  * This code is derived from software contributed to Berkeley by
  * Van Jacobson of Lawrence Berkeley Laboratory.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)sd.c        8.3 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)sd.c        8.9 (Berkeley) 5/14/95
  */
 
 /*
  */
 
 /*
@@ -38,10 +64,7 @@ static char rcsid[] = "$Header: /sys.lite/hp300/dev/RCS/sd.c,v 1.2 1994/01/10 18
 #include <hp300/hp300/led.h>
 #endif
 
 #include <hp300/hp300/led.h>
 #endif
 
-#include <vm/vm_param.h>
-#include <vm/lock.h>
-#include <vm/vm_prot.h>
-#include <vm/pmap.h>
+#include <vm/vm.h>
 
 extern int scsi_test_unit_rdy();
 extern int scsi_request_sense();
 
 extern int scsi_test_unit_rdy();
 extern int scsi_request_sense();
@@ -460,6 +483,9 @@ sdgetinfo(dev)
 #endif
        printf("defining `c' partition as entire disk\n");
        pi[2].p_size = sc->sc_blks;
 #endif
        printf("defining `c' partition as entire disk\n");
        pi[2].p_size = sc->sc_blks;
+       /* XXX reset other info since readdisklabel screws with it */
+       lp->d_npartitions = 3;
+       pi[0].p_size = 0;
        return(0);
 }
 
        return(0);
 }
 
@@ -471,20 +497,17 @@ sdopen(dev, flags, mode, p)
 {
        register int unit = sdunit(dev);
        register struct sd_softc *sc = &sd_softc[unit];
 {
        register int unit = sdunit(dev);
        register struct sd_softc *sc = &sd_softc[unit];
-       int mask, error;
+       int error, mask;
 
 
-       if (unit >= NSD)
-               return(ENXIO);
-       if ((sc->sc_flags & SDF_ALIVE) == 0 && suser(p->p_ucred, &p->p_acflag))
+       if (unit >= NSD || (sc->sc_flags & SDF_ALIVE) == 0)
                return(ENXIO);
                return(ENXIO);
-       if (sc->sc_flags & SDF_ERROR)
-               return(EIO);
 
        /*
         * Wait for any pending opens/closes to complete
         */
        while (sc->sc_flags & (SDF_OPENING|SDF_CLOSING))
                sleep((caddr_t)sc, PRIBIO);
 
        /*
         * Wait for any pending opens/closes to complete
         */
        while (sc->sc_flags & (SDF_OPENING|SDF_CLOSING))
                sleep((caddr_t)sc, PRIBIO);
+
        /*
         * On first open, get label and partition info.
         * We may block reading the label, so be careful
        /*
         * On first open, get label and partition info.
         * We may block reading the label, so be careful
@@ -984,7 +1007,7 @@ sdwrite(dev, uio, flags)
 int
 sdioctl(dev, cmd, data, flag, p)
        dev_t dev;
 int
 sdioctl(dev, cmd, data, flag, p)
        dev_t dev;
-       int cmd;
+       u_long cmd;
        caddr_t data;
        int flag;
        struct proc *p;
        caddr_t data;
        int flag;
        struct proc *p;