openpart -> openmask

This commit is contained in:
mycroft 1994-10-20 14:08:07 +00:00
parent bb12b9c8a2
commit cd66683989
7 changed files with 98 additions and 95 deletions

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
* $Id: wd.c,v 1.93 1994/10/20 13:44:46 mycroft Exp $
* $Id: wd.c,v 1.94 1994/10/20 14:08:07 mycroft Exp $
*/
#define INSTRUMENT /* instrumentation stuff by Brad Parker */
@ -48,11 +48,12 @@
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/disklabel.h>
#include <sys/buf.h>
#include <sys/uio.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/disklabel.h>
#include <sys/disk.h>
#include <sys/syslog.h>
#ifdef INSTRUMENT
#include <sys/dkstat.h>
@ -889,7 +890,7 @@ wdopen(dev, flag, fmt, p)
* Warn if a partition is opened that overlaps another partition which
* is open unless one is the "raw" partition (whole disk).
*/
if ((wd->sc_dk.dk_openpart & (1 << part)) == 0 && part != RAW_PART) {
if ((wd->sc_dk.dk_openmask & (1 << part)) == 0 && part != RAW_PART) {
int start, end;
pp = &wd->sc_dk.dk_label.d_partitions[part];
@ -903,7 +904,7 @@ wdopen(dev, flag, fmt, p)
continue;
if (pp - wd->sc_dk.dk_label.d_partitions == RAW_PART)
continue;
if (wd->sc_dk.dk_openpart & (1 << (pp - wd->sc_dk.dk_label.d_partitions)))
if (wd->sc_dk.dk_openmask & (1 << (pp - wd->sc_dk.dk_label.d_partitions)))
log(LOG_WARNING,
"%s%c: overlaps open partition (%c)\n",
wd->sc_dev.dv_xname, part + 'a',
@ -920,13 +921,13 @@ wdopen(dev, flag, fmt, p)
/* Insure only one open at a time. */
switch (fmt) {
case S_IFCHR:
wd->sc_dk.dk_copenpart |= (1 << part);
wd->sc_dk.dk_copenmask |= (1 << part);
break;
case S_IFBLK:
wd->sc_dk.dk_bopenpart |= (1 << part);
wd->sc_dk.dk_bopenmask |= (1 << part);
break;
}
wd->sc_dk.dk_openpart = wd->sc_dk.dk_copenpart | wd->sc_dk.dk_bopenpart;
wd->sc_dk.dk_openmask = wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
return 0;
@ -1140,13 +1141,13 @@ wdclose(dev, flag, fmt)
switch (fmt) {
case S_IFCHR:
wd->sc_dk.dk_copenpart &= ~(1 << part);
wd->sc_dk.dk_copenmask &= ~(1 << part);
break;
case S_IFBLK:
wd->sc_dk.dk_bopenpart &= ~(1 << part);
wd->sc_dk.dk_bopenmask &= ~(1 << part);
break;
}
wd->sc_dk.dk_openpart = wd->sc_dk.dk_copenpart | wd->sc_dk.dk_bopenpart;
wd->sc_dk.dk_openmask = wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
return 0;
}
@ -1187,7 +1188,7 @@ wdioctl(dev, cmd, addr, flag, p)
return EBADF;
error = setdisklabel(&wd->sc_dk.dk_label,
(struct disklabel *)addr,
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openpart : */0,
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openmask : */0,
&wd->sc_dk.dk_cpulabel);
if (error == 0) {
wd->sc_flags |= WDF_BSDLABEL;
@ -1212,7 +1213,7 @@ wdioctl(dev, cmd, addr, flag, p)
return EBADF;
error = setdisklabel(&wd->sc_dk.dk_label,
(struct disklabel *)addr,
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openpart : */0,
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openmask : */0,
&wd->sc_dk.dk_cpulabel);
if (error == 0) {
wd->sc_flags |= WDF_BSDLABEL;
@ -1220,11 +1221,11 @@ wdioctl(dev, cmd, addr, flag, p)
wd->sc_state = GEOMETRY;
/* Simulate opening partition 0 so write succeeds. */
wd->sc_dk.dk_openpart |= (1 << 0); /* XXX */
wd->sc_dk.dk_openmask |= (1 << 0); /* XXX */
error = writedisklabel(WDLABELDEV(dev), wdstrategy,
&wd->sc_dk.dk_label, &wd->sc_dk.dk_cpulabel);
wd->sc_dk.dk_openpart =
wd->sc_dk.dk_copenpart | wd->sc_dk.dk_bopenpart;
wd->sc_dk.dk_openmask =
wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
}
return error;

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
* $Id: wd.c,v 1.93 1994/10/20 13:44:46 mycroft Exp $
* $Id: wd.c,v 1.94 1994/10/20 14:08:07 mycroft Exp $
*/
#define INSTRUMENT /* instrumentation stuff by Brad Parker */
@ -48,11 +48,12 @@
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/disklabel.h>
#include <sys/buf.h>
#include <sys/uio.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/disklabel.h>
#include <sys/disk.h>
#include <sys/syslog.h>
#ifdef INSTRUMENT
#include <sys/dkstat.h>
@ -889,7 +890,7 @@ wdopen(dev, flag, fmt, p)
* Warn if a partition is opened that overlaps another partition which
* is open unless one is the "raw" partition (whole disk).
*/
if ((wd->sc_dk.dk_openpart & (1 << part)) == 0 && part != RAW_PART) {
if ((wd->sc_dk.dk_openmask & (1 << part)) == 0 && part != RAW_PART) {
int start, end;
pp = &wd->sc_dk.dk_label.d_partitions[part];
@ -903,7 +904,7 @@ wdopen(dev, flag, fmt, p)
continue;
if (pp - wd->sc_dk.dk_label.d_partitions == RAW_PART)
continue;
if (wd->sc_dk.dk_openpart & (1 << (pp - wd->sc_dk.dk_label.d_partitions)))
if (wd->sc_dk.dk_openmask & (1 << (pp - wd->sc_dk.dk_label.d_partitions)))
log(LOG_WARNING,
"%s%c: overlaps open partition (%c)\n",
wd->sc_dev.dv_xname, part + 'a',
@ -920,13 +921,13 @@ wdopen(dev, flag, fmt, p)
/* Insure only one open at a time. */
switch (fmt) {
case S_IFCHR:
wd->sc_dk.dk_copenpart |= (1 << part);
wd->sc_dk.dk_copenmask |= (1 << part);
break;
case S_IFBLK:
wd->sc_dk.dk_bopenpart |= (1 << part);
wd->sc_dk.dk_bopenmask |= (1 << part);
break;
}
wd->sc_dk.dk_openpart = wd->sc_dk.dk_copenpart | wd->sc_dk.dk_bopenpart;
wd->sc_dk.dk_openmask = wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
return 0;
@ -1140,13 +1141,13 @@ wdclose(dev, flag, fmt)
switch (fmt) {
case S_IFCHR:
wd->sc_dk.dk_copenpart &= ~(1 << part);
wd->sc_dk.dk_copenmask &= ~(1 << part);
break;
case S_IFBLK:
wd->sc_dk.dk_bopenpart &= ~(1 << part);
wd->sc_dk.dk_bopenmask &= ~(1 << part);
break;
}
wd->sc_dk.dk_openpart = wd->sc_dk.dk_copenpart | wd->sc_dk.dk_bopenpart;
wd->sc_dk.dk_openmask = wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
return 0;
}
@ -1187,7 +1188,7 @@ wdioctl(dev, cmd, addr, flag, p)
return EBADF;
error = setdisklabel(&wd->sc_dk.dk_label,
(struct disklabel *)addr,
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openpart : */0,
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openmask : */0,
&wd->sc_dk.dk_cpulabel);
if (error == 0) {
wd->sc_flags |= WDF_BSDLABEL;
@ -1212,7 +1213,7 @@ wdioctl(dev, cmd, addr, flag, p)
return EBADF;
error = setdisklabel(&wd->sc_dk.dk_label,
(struct disklabel *)addr,
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openpart : */0,
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openmask : */0,
&wd->sc_dk.dk_cpulabel);
if (error == 0) {
wd->sc_flags |= WDF_BSDLABEL;
@ -1220,11 +1221,11 @@ wdioctl(dev, cmd, addr, flag, p)
wd->sc_state = GEOMETRY;
/* Simulate opening partition 0 so write succeeds. */
wd->sc_dk.dk_openpart |= (1 << 0); /* XXX */
wd->sc_dk.dk_openmask |= (1 << 0); /* XXX */
error = writedisklabel(WDLABELDEV(dev), wdstrategy,
&wd->sc_dk.dk_label, &wd->sc_dk.dk_cpulabel);
wd->sc_dk.dk_openpart =
wd->sc_dk.dk_copenpart | wd->sc_dk.dk_bopenpart;
wd->sc_dk.dk_openmask =
wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
}
return error;

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
* $Id: wd.c,v 1.93 1994/10/20 13:44:46 mycroft Exp $
* $Id: wd.c,v 1.94 1994/10/20 14:08:07 mycroft Exp $
*/
#define INSTRUMENT /* instrumentation stuff by Brad Parker */
@ -48,11 +48,12 @@
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/disklabel.h>
#include <sys/buf.h>
#include <sys/uio.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/disklabel.h>
#include <sys/disk.h>
#include <sys/syslog.h>
#ifdef INSTRUMENT
#include <sys/dkstat.h>
@ -889,7 +890,7 @@ wdopen(dev, flag, fmt, p)
* Warn if a partition is opened that overlaps another partition which
* is open unless one is the "raw" partition (whole disk).
*/
if ((wd->sc_dk.dk_openpart & (1 << part)) == 0 && part != RAW_PART) {
if ((wd->sc_dk.dk_openmask & (1 << part)) == 0 && part != RAW_PART) {
int start, end;
pp = &wd->sc_dk.dk_label.d_partitions[part];
@ -903,7 +904,7 @@ wdopen(dev, flag, fmt, p)
continue;
if (pp - wd->sc_dk.dk_label.d_partitions == RAW_PART)
continue;
if (wd->sc_dk.dk_openpart & (1 << (pp - wd->sc_dk.dk_label.d_partitions)))
if (wd->sc_dk.dk_openmask & (1 << (pp - wd->sc_dk.dk_label.d_partitions)))
log(LOG_WARNING,
"%s%c: overlaps open partition (%c)\n",
wd->sc_dev.dv_xname, part + 'a',
@ -920,13 +921,13 @@ wdopen(dev, flag, fmt, p)
/* Insure only one open at a time. */
switch (fmt) {
case S_IFCHR:
wd->sc_dk.dk_copenpart |= (1 << part);
wd->sc_dk.dk_copenmask |= (1 << part);
break;
case S_IFBLK:
wd->sc_dk.dk_bopenpart |= (1 << part);
wd->sc_dk.dk_bopenmask |= (1 << part);
break;
}
wd->sc_dk.dk_openpart = wd->sc_dk.dk_copenpart | wd->sc_dk.dk_bopenpart;
wd->sc_dk.dk_openmask = wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
return 0;
@ -1140,13 +1141,13 @@ wdclose(dev, flag, fmt)
switch (fmt) {
case S_IFCHR:
wd->sc_dk.dk_copenpart &= ~(1 << part);
wd->sc_dk.dk_copenmask &= ~(1 << part);
break;
case S_IFBLK:
wd->sc_dk.dk_bopenpart &= ~(1 << part);
wd->sc_dk.dk_bopenmask &= ~(1 << part);
break;
}
wd->sc_dk.dk_openpart = wd->sc_dk.dk_copenpart | wd->sc_dk.dk_bopenpart;
wd->sc_dk.dk_openmask = wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
return 0;
}
@ -1187,7 +1188,7 @@ wdioctl(dev, cmd, addr, flag, p)
return EBADF;
error = setdisklabel(&wd->sc_dk.dk_label,
(struct disklabel *)addr,
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openpart : */0,
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openmask : */0,
&wd->sc_dk.dk_cpulabel);
if (error == 0) {
wd->sc_flags |= WDF_BSDLABEL;
@ -1212,7 +1213,7 @@ wdioctl(dev, cmd, addr, flag, p)
return EBADF;
error = setdisklabel(&wd->sc_dk.dk_label,
(struct disklabel *)addr,
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openpart : */0,
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openmask : */0,
&wd->sc_dk.dk_cpulabel);
if (error == 0) {
wd->sc_flags |= WDF_BSDLABEL;
@ -1220,11 +1221,11 @@ wdioctl(dev, cmd, addr, flag, p)
wd->sc_state = GEOMETRY;
/* Simulate opening partition 0 so write succeeds. */
wd->sc_dk.dk_openpart |= (1 << 0); /* XXX */
wd->sc_dk.dk_openmask |= (1 << 0); /* XXX */
error = writedisklabel(WDLABELDEV(dev), wdstrategy,
&wd->sc_dk.dk_label, &wd->sc_dk.dk_cpulabel);
wd->sc_dk.dk_openpart =
wd->sc_dk.dk_copenpart | wd->sc_dk.dk_bopenpart;
wd->sc_dk.dk_openmask =
wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask;
}
return error;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd.c,v 1.36 1994/10/20 14:03:38 mycroft Exp $ */
/* $NetBSD: cd.c,v 1.37 1994/10/20 14:09:10 mycroft Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -208,7 +208,7 @@ cdopen(dev, flag, fmt, p)
* forbid re-entry. (may have changed media)
*/
if ((sc_link->flags & SDEV_MEDIA_LOADED) == 0 &&
cd->sc_dk.dk_openpart != 0)
cd->sc_dk.dk_openmask != 0)
return ENXIO;
/*
@ -267,20 +267,20 @@ cdopen(dev, flag, fmt, p)
/* Insure only one open at a time. */
switch (fmt) {
case S_IFCHR:
cd->sc_dk.dk_copenpart |= (1 << part);
cd->sc_dk.dk_copenmask |= (1 << part);
break;
case S_IFBLK:
cd->sc_dk.dk_bopenpart |= (1 << part);
cd->sc_dk.dk_bopenmask |= (1 << part);
break;
}
cd->sc_dk.dk_openpart = cd->sc_dk.dk_copenpart | cd->sc_dk.dk_bopenpart;
cd->sc_dk.dk_openmask = cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;
SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
sc_link->flags |= SDEV_MEDIA_LOADED;
return 0;
bad:
if (cd->sc_dk.dk_openpart == 0) {
if (cd->sc_dk.dk_openmask == 0) {
scsi_prevent(sc_link, PR_ALLOW, SCSI_ERR_OK | SCSI_SILENT);
sc_link->flags &= ~SDEV_OPEN;
}
@ -300,15 +300,15 @@ cdclose(dev)
switch (fmt) {
case S_IFCHR:
cd->sc_dk.dk_copenpart &= ~(1 << part);
cd->sc_dk.dk_copenmask &= ~(1 << part);
break;
case S_IFBLK:
cd->sc_dk.dk_bopenpart &= ~(1 << part);
cd->sc_dk.dk_bopenmask &= ~(1 << part);
break;
}
cd->sc_dk.dk_openpart = cd->sc_dk.dk_copenpart | cd->sc_dk.dk_bopenpart;
cd->sc_dk.dk_openmask = cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;
if (cd->sc_dk.dk_openpart == 0) {
if (cd->sc_dk.dk_openmask == 0) {
scsi_prevent(cd->sc_link, PR_ALLOW, SCSI_ERR_OK | SCSI_SILENT);
cd->sc_link->flags &= ~SDEV_OPEN;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sd.c,v 1.39 1994/10/20 14:05:08 mycroft Exp $ */
/* $NetBSD: sd.c,v 1.40 1994/10/20 14:09:13 mycroft Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -217,7 +217,7 @@ sdopen(dev, flag, fmt, p)
/*
* If somebody still has it open, then forbid re-entry.
*/
if (sd->sc_dk.dk_openpart != 0)
if (sd->sc_dk.dk_openmask != 0)
return ENXIO;
}
@ -279,20 +279,20 @@ sdopen(dev, flag, fmt, p)
/* Insure only one open at a time. */
switch (fmt) {
case S_IFCHR:
sd->sc_dk.dk_copenpart |= (1 << part);
sd->sc_dk.dk_copenmask |= (1 << part);
break;
case S_IFBLK:
sd->sc_dk.dk_bopenpart |= (1 << part);
sd->sc_dk.dk_bopenmask |= (1 << part);
break;
}
sd->sc_dk.dk_openpart = sd->sc_dk.dk_copenpart | sd->sc_dk.dk_bopenpart;
sd->sc_dk.dk_openmask = sd->sc_dk.dk_copenmask | sd->sc_dk.dk_bopenmask;
SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
sc_link->flags |= SDEV_MEDIA_LOADED;
return 0;
bad:
if (sd->sc_dk.dk_openpart == 0) {
if (sd->sc_dk.dk_openmask == 0) {
scsi_prevent(sc_link, PR_ALLOW, SCSI_ERR_OK | SCSI_SILENT);
sc_link->flags &= ~SDEV_OPEN;
}
@ -313,15 +313,15 @@ sdclose(dev, flag, fmt)
switch (fmt) {
case S_IFCHR:
sd->sc_dk.dk_copenpart &= ~(1 << part);
sd->sc_dk.dk_copenmask &= ~(1 << part);
break;
case S_IFBLK:
sd->sc_dk.dk_bopenpart &= ~(1 << part);
sd->sc_dk.dk_bopenmask &= ~(1 << part);
break;
}
sd->sc_dk.dk_openpart = sd->sc_dk.dk_copenpart | sd->sc_dk.dk_bopenpart;
sd->sc_dk.dk_openmask = sd->sc_dk.dk_copenmask | sd->sc_dk.dk_bopenmask;
if (sd->sc_dk.dk_openpart == 0) {
if (sd->sc_dk.dk_openmask == 0) {
scsi_prevent(sd->sc_link, PR_ALLOW, SCSI_ERR_OK | SCSI_SILENT);
sd->sc_link->flags &= ~SDEV_OPEN;
}
@ -580,7 +580,7 @@ sdioctl(dev, cmd, addr, flag)
return EBADF;
error = setdisklabel(&sd->sc_dk.dk_label,
(struct disklabel *)addr,
/*(sd->flags & SDF_BSDLABEL) ? sd->sc_dk.dk_openpart : */0,
/*(sd->flags & SDF_BSDLABEL) ? sd->sc_dk.dk_openmask : */0,
&sd->sc_dk.dk_cpulabel);
if (error == 0)
sd->flags |= SDF_BSDLABEL;
@ -602,17 +602,17 @@ sdioctl(dev, cmd, addr, flag)
return EBADF;
error = setdisklabel(&sd->sc_dk.dk_label,
(struct disklabel *)addr,
/*(sd->flags & SDF_BSDLABEL) ? sd->sc_dk.dk_openpart : */0,
/*(sd->flags & SDF_BSDLABEL) ? sd->sc_dk.dk_openmask : */0,
&sd->sc_dk.dk_cpulabel);
if (error == 0) {
sd->flags |= SDF_BSDLABEL;
/* simulate opening partition 0 so write succeeds */
sd->sc_dk.dk_openpart |= (1 << 0); /* XXX */
sd->sc_dk.dk_openmask |= (1 << 0); /* XXX */
error = writedisklabel(SDLABELDEV(dev), sdstrategy,
&sd->sc_dk.dk_label, &sd->sc_dk.dk_cpulabel);
sd->sc_dk.dk_openpart =
sd->sc_dk.dk_copenpart | sd->sc_dk.dk_bopenpart;
sd->sc_dk.dk_openmask =
sd->sc_dk.dk_copenmask | sd->sc_dk.dk_bopenmask;
}
return error;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd.c,v 1.36 1994/10/20 14:03:38 mycroft Exp $ */
/* $NetBSD: cd.c,v 1.37 1994/10/20 14:09:10 mycroft Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -208,7 +208,7 @@ cdopen(dev, flag, fmt, p)
* forbid re-entry. (may have changed media)
*/
if ((sc_link->flags & SDEV_MEDIA_LOADED) == 0 &&
cd->sc_dk.dk_openpart != 0)
cd->sc_dk.dk_openmask != 0)
return ENXIO;
/*
@ -267,20 +267,20 @@ cdopen(dev, flag, fmt, p)
/* Insure only one open at a time. */
switch (fmt) {
case S_IFCHR:
cd->sc_dk.dk_copenpart |= (1 << part);
cd->sc_dk.dk_copenmask |= (1 << part);
break;
case S_IFBLK:
cd->sc_dk.dk_bopenpart |= (1 << part);
cd->sc_dk.dk_bopenmask |= (1 << part);
break;
}
cd->sc_dk.dk_openpart = cd->sc_dk.dk_copenpart | cd->sc_dk.dk_bopenpart;
cd->sc_dk.dk_openmask = cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;
SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
sc_link->flags |= SDEV_MEDIA_LOADED;
return 0;
bad:
if (cd->sc_dk.dk_openpart == 0) {
if (cd->sc_dk.dk_openmask == 0) {
scsi_prevent(sc_link, PR_ALLOW, SCSI_ERR_OK | SCSI_SILENT);
sc_link->flags &= ~SDEV_OPEN;
}
@ -300,15 +300,15 @@ cdclose(dev)
switch (fmt) {
case S_IFCHR:
cd->sc_dk.dk_copenpart &= ~(1 << part);
cd->sc_dk.dk_copenmask &= ~(1 << part);
break;
case S_IFBLK:
cd->sc_dk.dk_bopenpart &= ~(1 << part);
cd->sc_dk.dk_bopenmask &= ~(1 << part);
break;
}
cd->sc_dk.dk_openpart = cd->sc_dk.dk_copenpart | cd->sc_dk.dk_bopenpart;
cd->sc_dk.dk_openmask = cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;
if (cd->sc_dk.dk_openpart == 0) {
if (cd->sc_dk.dk_openmask == 0) {
scsi_prevent(cd->sc_link, PR_ALLOW, SCSI_ERR_OK | SCSI_SILENT);
cd->sc_link->flags &= ~SDEV_OPEN;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sd.c,v 1.39 1994/10/20 14:05:08 mycroft Exp $ */
/* $NetBSD: sd.c,v 1.40 1994/10/20 14:09:13 mycroft Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -217,7 +217,7 @@ sdopen(dev, flag, fmt, p)
/*
* If somebody still has it open, then forbid re-entry.
*/
if (sd->sc_dk.dk_openpart != 0)
if (sd->sc_dk.dk_openmask != 0)
return ENXIO;
}
@ -279,20 +279,20 @@ sdopen(dev, flag, fmt, p)
/* Insure only one open at a time. */
switch (fmt) {
case S_IFCHR:
sd->sc_dk.dk_copenpart |= (1 << part);
sd->sc_dk.dk_copenmask |= (1 << part);
break;
case S_IFBLK:
sd->sc_dk.dk_bopenpart |= (1 << part);
sd->sc_dk.dk_bopenmask |= (1 << part);
break;
}
sd->sc_dk.dk_openpart = sd->sc_dk.dk_copenpart | sd->sc_dk.dk_bopenpart;
sd->sc_dk.dk_openmask = sd->sc_dk.dk_copenmask | sd->sc_dk.dk_bopenmask;
SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
sc_link->flags |= SDEV_MEDIA_LOADED;
return 0;
bad:
if (sd->sc_dk.dk_openpart == 0) {
if (sd->sc_dk.dk_openmask == 0) {
scsi_prevent(sc_link, PR_ALLOW, SCSI_ERR_OK | SCSI_SILENT);
sc_link->flags &= ~SDEV_OPEN;
}
@ -313,15 +313,15 @@ sdclose(dev, flag, fmt)
switch (fmt) {
case S_IFCHR:
sd->sc_dk.dk_copenpart &= ~(1 << part);
sd->sc_dk.dk_copenmask &= ~(1 << part);
break;
case S_IFBLK:
sd->sc_dk.dk_bopenpart &= ~(1 << part);
sd->sc_dk.dk_bopenmask &= ~(1 << part);
break;
}
sd->sc_dk.dk_openpart = sd->sc_dk.dk_copenpart | sd->sc_dk.dk_bopenpart;
sd->sc_dk.dk_openmask = sd->sc_dk.dk_copenmask | sd->sc_dk.dk_bopenmask;
if (sd->sc_dk.dk_openpart == 0) {
if (sd->sc_dk.dk_openmask == 0) {
scsi_prevent(sd->sc_link, PR_ALLOW, SCSI_ERR_OK | SCSI_SILENT);
sd->sc_link->flags &= ~SDEV_OPEN;
}
@ -580,7 +580,7 @@ sdioctl(dev, cmd, addr, flag)
return EBADF;
error = setdisklabel(&sd->sc_dk.dk_label,
(struct disklabel *)addr,
/*(sd->flags & SDF_BSDLABEL) ? sd->sc_dk.dk_openpart : */0,
/*(sd->flags & SDF_BSDLABEL) ? sd->sc_dk.dk_openmask : */0,
&sd->sc_dk.dk_cpulabel);
if (error == 0)
sd->flags |= SDF_BSDLABEL;
@ -602,17 +602,17 @@ sdioctl(dev, cmd, addr, flag)
return EBADF;
error = setdisklabel(&sd->sc_dk.dk_label,
(struct disklabel *)addr,
/*(sd->flags & SDF_BSDLABEL) ? sd->sc_dk.dk_openpart : */0,
/*(sd->flags & SDF_BSDLABEL) ? sd->sc_dk.dk_openmask : */0,
&sd->sc_dk.dk_cpulabel);
if (error == 0) {
sd->flags |= SDF_BSDLABEL;
/* simulate opening partition 0 so write succeeds */
sd->sc_dk.dk_openpart |= (1 << 0); /* XXX */
sd->sc_dk.dk_openmask |= (1 << 0); /* XXX */
error = writedisklabel(SDLABELDEV(dev), sdstrategy,
&sd->sc_dk.dk_label, &sd->sc_dk.dk_cpulabel);
sd->sc_dk.dk_openpart =
sd->sc_dk.dk_copenpart | sd->sc_dk.dk_bopenpart;
sd->sc_dk.dk_openmask =
sd->sc_dk.dk_copenmask | sd->sc_dk.dk_bopenmask;
}
return error;