Implement the DIOCKLABEL ioctl. Through this ioctl it it possible keep the
disklabel on the last close or to drop it.
This commit is contained in:
parent
aafe48897d
commit
384bdc532b
@ -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>. All rights reserved.
|
||||
@ -175,6 +175,8 @@ The driver
|
||||
.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.
|
||||
|
@ -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 @@ struct wd_softc {
|
||||
#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 @@ wdclose(dev, flag, fmt, p)
|
||||
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);
|
||||
}
|
||||
|
||||
@ -970,6 +974,13 @@ wdioctl(dev, xfer, addr, flag, p)
|
||||
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)
|
||||
return EBADF;
|
||||
|
@ -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 @@ struct scsipi_link {
|
||||
#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
|
||||
|
@ -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 @@ sdclose(dev, flag, fmt, p)
|
||||
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 @@ sdioctl(dev, cmd, addr, flag, p)
|
||||
*/
|
||||
if ((sd->sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
|
||||
switch (cmd) {
|
||||
case DIOCKLABEL:
|
||||
case DIOCWLABEL:
|
||||
case DIOCLOCK:
|
||||
case DIOCEJECT:
|
||||
@ -905,6 +909,13 @@ sdioctl(dev, cmd, addr, flag, p)
|
||||
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);
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user