Subject: Re: To stick or not to stick [ disklabels ]
To: Todd Vierling <tv@pobox.com>
From: Leo Weppelman <leo@wau.mis.ah.nl>
List: tech-kern
Date: 12/14/1999 10:36:48
--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii

On Fri, Dec 10, 1999 at 07:44:01PM -0500, Todd Vierling wrote:
> On Fri, 10 Dec 1999, Leo Weppelman wrote:
> 
> : > the notion of 'label' should be in the name.  8-)
> : 
> : I'll make it: DIOCSTICKLABEL
> 
> How about "...STICKYLABEL"?  The word "sticky" has been used before to
> describe concepts assoiated with making something non-transient... as was
> the case with the "sticky" bit vs. text pages in the older days of Unix
> virtual memory.

Julian suggested DIOCKLABEL. And when looking at dkio.h, this looks to be
the one that fits in best (DIOCWLABEL is also there).

For those interested, I attached the diff that should do the trick for the
sd-driver. I planned to do some testing tonight and do the wd stuff too.

Leo.

--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="label.diffs"

--- /usr/src/sys.org/dev/scsipi/scsipiconf.h	Thu Oct 28 15:09:30 1999
+++ /mnt/sys/dev/scsipi/scsipiconf.h	Fri Dec 10 22:27:43 1999
@@ -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 -ru /usr/src/sys.org/dev/scsipi/sd.c /mnt/sys/dev/scsipi/sd.c
--- /usr/src/sys.org/dev/scsipi/sd.c	Tue Nov 23 11:14:45 1999
+++ /mnt/sys/dev/scsipi/sd.c	Fri Dec 10 22:09:22 1999
@@ -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:
@@ -904,6 +908,13 @@
 		sd->flags &= ~SDF_LABELLING;
 		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)
diff -ru /usr/src/sys.org/sys/dkio.h /mnt/sys/sys/dkio.h
--- /usr/src/sys.org/sys/dkio.h	Tue Feb  9 13:19:29 1999
+++ /mnt/sys/sys/dkio.h	Fri Dec 10 22:10:58 1999
@@ -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 */



--oyUTqETQ0mS9luUI--