Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Implement the DIOCKLABEL ioctl. Through this ioctl it it pos...



details:   https://anonhg.NetBSD.org/src/rev/065646b0393a
branches:  trunk
changeset: 479869:065646b0393a
user:      leo <leo%NetBSD.org@localhost>
date:      Thu Dec 23 21:23:19 1999 +0000

description:
Implement the DIOCKLABEL ioctl. Through this ioctl it it possible keep the
disklabel on the last close or to drop it.

diffstat:

 share/man/man4/sd.4         |   4 +++-
 sys/dev/ata/wd.c            |  13 ++++++++++++-
 sys/dev/scsipi/scsipiconf.h |   3 ++-
 sys/dev/scsipi/sd.c         |  13 ++++++++++++-
 sys/sys/dkio.h              |   3 ++-
 5 files changed, 31 insertions(+), 5 deletions(-)

diffs (134 lines):

diff -r 1ad401ac77cf -r 065646b0393a share/man/man4/sd.4
--- a/share/man/man4/sd.4       Thu Dec 23 19:46:27 1999 +0000
+++ b/share/man/man4/sd.4       Thu Dec 23 21:23:19 1999 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: sd.4,v 1.8 1999/03/16 01:19:18 garbled Exp $
+.\"    $NetBSD: sd.4,v 1.9 1999/12/23 21:24:03 leo Exp $
 .\"
 .\" Copyright (c) 1996
 .\"     Julian Elischer <julian%freebsd.org@localhost>.  All rights reserved.
@@ -175,6 +175,8 @@
 .Em will not
 write the new
 disklabel to the disk.
+.It Dv DIOCKLABEL
+Keep or drop the in-core disklabel on the last close.
 .It Dv DIOCWLABEL
 Enable or disable the driver's software
 write protect of the disklabel on the disk.
diff -r 1ad401ac77cf -r 065646b0393a sys/dev/ata/wd.c
--- a/sys/dev/ata/wd.c  Thu Dec 23 19:46:27 1999 +0000
+++ b/sys/dev/ata/wd.c  Thu Dec 23 21:23:19 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wd.c,v 1.198 1999/11/10 14:11:34 leo Exp $ */
+/*     $NetBSD: wd.c,v 1.199 1999/12/23 21:23:19 leo Exp $ */
 
 /*
  * Copyright (c) 1998 Manuel Bouyer.  All rights reserved.
@@ -153,6 +153,7 @@
 #define WDF_LOADED       0x10 /* parameters loaded */
 #define WDF_WAIT       0x20 /* waiting for resources */
 #define WDF_LBA         0x40 /* using LBA mode */
+#define WDF_KLABEL      0x80 /* retain label after 'full' close */
        int sc_capacity;
        int cyl; /* actual drive parameters */
        int heads;
@@ -816,6 +817,9 @@
                wd_flushcache(wd, AT_WAIT);
                /* XXXX Must wait for I/O to complete! */
 
+               if (! (wd->sc_flags & WDF_KLABEL))
+                       wd->sc_flags &= ~WDF_LOADED;
+
                wdc_ata_delref(wd->drvp);
        }
 
@@ -969,6 +973,13 @@
                wd->sc_flags &= ~WDF_LABELLING;
                wdunlock(wd);
                return error;
+
+       case DIOCKLABEL:
+               if (*(int *)addr)
+                       wd->sc_flags |= WDF_KLABEL;
+               else
+                       wd->sc_flags &= ~WDF_KLABEL;
+               return 0;
        
        case DIOCWLABEL:
                if ((flag & FWRITE) == 0)
diff -r 1ad401ac77cf -r 065646b0393a sys/dev/scsipi/scsipiconf.h
--- a/sys/dev/scsipi/scsipiconf.h       Thu Dec 23 19:46:27 1999 +0000
+++ b/sys/dev/scsipi/scsipiconf.h       Thu Dec 23 21:23:19 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsipiconf.h,v 1.33 1999/10/20 15:22:28 enami Exp $    */
+/*     $NetBSD: scsipiconf.h,v 1.34 1999/12/23 21:23:29 leo Exp $      */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -180,6 +180,7 @@
 #define        SDEV_OPEN               0x08    /* at least 1 open session */
 #define        SDEV_DBX                0xf0    /* debuging flags (scsipi_debug.h) */
 #define        SDEV_WAITDRAIN          0x100   /* waiting for pending_xfers to drain */
+#define        SDEV_KEEP_LABEL         0x200   /* retain label after 'full' close */
        u_int16_t quirks;               /* per-device oddities */
 #define        SDEV_AUTOSAVE           0x0001  /*
                                         * Do implicit SAVEDATAPOINTER on
diff -r 1ad401ac77cf -r 065646b0393a sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c       Thu Dec 23 19:46:27 1999 +0000
+++ b/sys/dev/scsipi/sd.c       Thu Dec 23 21:23:19 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sd.c,v 1.153 1999/11/03 20:50:17 matt Exp $    */
+/*     $NetBSD: sd.c,v 1.154 1999/12/23 21:23:30 leo Exp $     */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -530,6 +530,9 @@
                    XS_CTL_IGNORE_ILLEGAL_REQUEST | XS_CTL_IGNORE_NOT_READY);
                sd->sc_link->flags &= ~SDEV_OPEN;
 
+               if (! (sd->sc_link->flags & SDEV_KEEP_LABEL))
+                       sd->sc_link->flags &= ~SDEV_MEDIA_LOADED;
+
                scsipi_wait_drain(sd->sc_link);
 
                scsipi_adapter_delref(sd->sc_link);
@@ -852,6 +855,7 @@
         */
        if ((sd->sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
                switch (cmd) {
+               case DIOCKLABEL:
                case DIOCWLABEL:
                case DIOCLOCK:
                case DIOCEJECT:
@@ -905,6 +909,13 @@
                sdunlock(sd);
                return (error);
 
+       case DIOCKLABEL:
+               if (*(int *)addr)
+                       sd->sc_link->flags |= SDEV_KEEP_LABEL;
+               else
+                       sd->sc_link->flags &= ~SDEV_KEEP_LABEL;
+               return (0);
+
        case DIOCWLABEL:
                if ((flag & FWRITE) == 0)
                        return (EBADF);
diff -r 1ad401ac77cf -r 065646b0393a sys/sys/dkio.h
--- a/sys/sys/dkio.h    Thu Dec 23 19:46:27 1999 +0000
+++ b/sys/sys/dkio.h    Thu Dec 23 21:23:19 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dkio.h,v 1.3 1999/02/08 16:33:18 bouyer Exp $  */
+/*     $NetBSD: dkio.h,v 1.4 1999/12/23 21:23:31 leo Exp $     */
 
 /*
  * Copyright (c) 1987, 1988, 1993
@@ -53,6 +53,7 @@
 
 #define DIOCSSTEP      _IOW('d', 107, int)     /* set step rate */
 #define DIOCSRETRIES   _IOW('d', 108, int)     /* set # of retries */
+#define DIOCKLABEL     _IOW('d', 119, int)     /* keep/drop label on close? */
 #define DIOCWLABEL     _IOW('d', 109, int)     /* write en/disable label */
 
 #define DIOCSBAD       _IOW('d', 110, struct dkbad)    /* set kernel dkbad */



Home | Main Index | Thread Index | Old Index