Always boundary check I/O.
This commit is contained in:
parent
e631f9d003
commit
7650bd97fc
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: wd.c,v 1.127 1995/01/13 10:22:58 mycroft Exp $ */
|
||||
/* $NetBSD: wd.c,v 1.128 1995/01/13 10:46:32 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
|
||||
|
@ -137,9 +137,8 @@ struct wd_softc {
|
|||
#define WDF_LOCKED 0x01
|
||||
#define WDF_WANTED 0x02
|
||||
#define WDF_LOADED 0x04
|
||||
#define WDF_BSDLABEL 0x08 /* has a BSD disk label */
|
||||
#define WDF_WLABEL 0x10 /* label is writable */
|
||||
#define WDF_32BIT 0x20 /* can do 32-bit transfer */
|
||||
#define WDF_WLABEL 0x08 /* label is writable */
|
||||
#define WDF_32BIT 0x10 /* can do 32-bit transfer */
|
||||
|
||||
struct wdparams sc_params; /* ESDI/IDE drive/controller parameters */
|
||||
daddr_t sc_badsect[127]; /* 126 plus trailing -1 marker */
|
||||
|
@ -407,21 +406,13 @@ wdstrategy(bp)
|
|||
if (bp->b_bcount == 0)
|
||||
goto done;
|
||||
|
||||
/* Have partitions and want to use them? */
|
||||
if (WDPART(bp->b_dev) != RAW_PART) {
|
||||
if ((wd->sc_flags & WDF_BSDLABEL) == 0) {
|
||||
bp->b_error = EIO;
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
* Do bounds checking, adjust transfer. if error, process.
|
||||
* If end of partition, just return.
|
||||
*/
|
||||
if (bounds_check_with_label(bp, &wd->sc_dk.dk_label,
|
||||
(wd->sc_flags & WDF_WLABEL) != 0) <= 0)
|
||||
goto done;
|
||||
/* Otherwise, process transfer request. */
|
||||
}
|
||||
/*
|
||||
* Do bounds checking, adjust transfer. if error, process.
|
||||
* If end of partition, just return.
|
||||
*/
|
||||
if (bounds_check_with_label(bp, &wd->sc_dk.dk_label,
|
||||
(wd->sc_flags & WDF_WLABEL) != 0) <= 0)
|
||||
goto done;
|
||||
|
||||
/* Don't bother doing rotational optimization. */
|
||||
bp->b_cylin = 0;
|
||||
|
@ -890,7 +881,6 @@ wdopen(dev, flag, fmt)
|
|||
wd->sc_flags |= WDF_LOCKED;
|
||||
|
||||
if ((wd->sc_flags & WDF_LOADED) == 0) {
|
||||
wd->sc_flags &= ~WDF_BSDLABEL;
|
||||
wd->sc_flags |= WDF_LOADED;
|
||||
|
||||
/* Load the physical device parameters. */
|
||||
|
@ -952,9 +942,6 @@ wdgetdisklabel(wd)
|
|||
{
|
||||
char *errstring;
|
||||
|
||||
if ((wd->sc_flags & WDF_BSDLABEL) != 0)
|
||||
return;
|
||||
|
||||
bzero(&wd->sc_dk.dk_label, sizeof(struct disklabel));
|
||||
bzero(&wd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
||||
|
||||
|
@ -1014,8 +1001,6 @@ wdgetdisklabel(wd)
|
|||
wd->sc_state = GEOMETRY;
|
||||
if ((wd->sc_dk.dk_label.d_flags & D_BADSECT) != 0)
|
||||
bad144intern(wd);
|
||||
|
||||
wd->sc_flags |= WDF_BSDLABEL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1343,11 +1328,9 @@ wdioctl(dev, command, addr, flag, p)
|
|||
if ((flag & FWRITE) == 0)
|
||||
return EBADF;
|
||||
error = setdisklabel(&wd->sc_dk.dk_label,
|
||||
(struct disklabel *)addr,
|
||||
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openmask : */0,
|
||||
(struct disklabel *)addr, /*wd->sc_dk.dk_openmask : */0,
|
||||
&wd->sc_dk.dk_cpulabel);
|
||||
if (error == 0) {
|
||||
wd->sc_flags |= WDF_BSDLABEL;
|
||||
if (wd->sc_state > GEOMETRY)
|
||||
wd->sc_state = GEOMETRY;
|
||||
}
|
||||
|
@ -1366,11 +1349,9 @@ wdioctl(dev, command, addr, flag, p)
|
|||
if ((flag & FWRITE) == 0)
|
||||
return EBADF;
|
||||
error = setdisklabel(&wd->sc_dk.dk_label,
|
||||
(struct disklabel *)addr,
|
||||
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openmask : */0,
|
||||
(struct disklabel *)addr, /*wd->sc_dk.dk_openmask : */0,
|
||||
&wd->sc_dk.dk_cpulabel);
|
||||
if (error == 0) {
|
||||
wd->sc_flags |= WDF_BSDLABEL;
|
||||
if (wd->sc_state > GEOMETRY)
|
||||
wd->sc_state = GEOMETRY;
|
||||
|
||||
|
@ -1446,8 +1427,7 @@ wdsize(dev)
|
|||
return -1;
|
||||
wd = wdcd.cd_devs[WDUNIT(dev)];
|
||||
part = WDPART(dev);
|
||||
if ((wd->sc_flags & WDF_BSDLABEL) == 0 ||
|
||||
wd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
|
||||
if (wd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
|
||||
size = -1;
|
||||
else
|
||||
size = wd->sc_dk.dk_label.d_partitions[part].p_size;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: wd.c,v 1.127 1995/01/13 10:22:58 mycroft Exp $ */
|
||||
/* $NetBSD: wd.c,v 1.128 1995/01/13 10:46:32 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
|
||||
|
@ -137,9 +137,8 @@ struct wd_softc {
|
|||
#define WDF_LOCKED 0x01
|
||||
#define WDF_WANTED 0x02
|
||||
#define WDF_LOADED 0x04
|
||||
#define WDF_BSDLABEL 0x08 /* has a BSD disk label */
|
||||
#define WDF_WLABEL 0x10 /* label is writable */
|
||||
#define WDF_32BIT 0x20 /* can do 32-bit transfer */
|
||||
#define WDF_WLABEL 0x08 /* label is writable */
|
||||
#define WDF_32BIT 0x10 /* can do 32-bit transfer */
|
||||
|
||||
struct wdparams sc_params; /* ESDI/IDE drive/controller parameters */
|
||||
daddr_t sc_badsect[127]; /* 126 plus trailing -1 marker */
|
||||
|
@ -407,21 +406,13 @@ wdstrategy(bp)
|
|||
if (bp->b_bcount == 0)
|
||||
goto done;
|
||||
|
||||
/* Have partitions and want to use them? */
|
||||
if (WDPART(bp->b_dev) != RAW_PART) {
|
||||
if ((wd->sc_flags & WDF_BSDLABEL) == 0) {
|
||||
bp->b_error = EIO;
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
* Do bounds checking, adjust transfer. if error, process.
|
||||
* If end of partition, just return.
|
||||
*/
|
||||
if (bounds_check_with_label(bp, &wd->sc_dk.dk_label,
|
||||
(wd->sc_flags & WDF_WLABEL) != 0) <= 0)
|
||||
goto done;
|
||||
/* Otherwise, process transfer request. */
|
||||
}
|
||||
/*
|
||||
* Do bounds checking, adjust transfer. if error, process.
|
||||
* If end of partition, just return.
|
||||
*/
|
||||
if (bounds_check_with_label(bp, &wd->sc_dk.dk_label,
|
||||
(wd->sc_flags & WDF_WLABEL) != 0) <= 0)
|
||||
goto done;
|
||||
|
||||
/* Don't bother doing rotational optimization. */
|
||||
bp->b_cylin = 0;
|
||||
|
@ -890,7 +881,6 @@ wdopen(dev, flag, fmt)
|
|||
wd->sc_flags |= WDF_LOCKED;
|
||||
|
||||
if ((wd->sc_flags & WDF_LOADED) == 0) {
|
||||
wd->sc_flags &= ~WDF_BSDLABEL;
|
||||
wd->sc_flags |= WDF_LOADED;
|
||||
|
||||
/* Load the physical device parameters. */
|
||||
|
@ -952,9 +942,6 @@ wdgetdisklabel(wd)
|
|||
{
|
||||
char *errstring;
|
||||
|
||||
if ((wd->sc_flags & WDF_BSDLABEL) != 0)
|
||||
return;
|
||||
|
||||
bzero(&wd->sc_dk.dk_label, sizeof(struct disklabel));
|
||||
bzero(&wd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
||||
|
||||
|
@ -1014,8 +1001,6 @@ wdgetdisklabel(wd)
|
|||
wd->sc_state = GEOMETRY;
|
||||
if ((wd->sc_dk.dk_label.d_flags & D_BADSECT) != 0)
|
||||
bad144intern(wd);
|
||||
|
||||
wd->sc_flags |= WDF_BSDLABEL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1343,11 +1328,9 @@ wdioctl(dev, command, addr, flag, p)
|
|||
if ((flag & FWRITE) == 0)
|
||||
return EBADF;
|
||||
error = setdisklabel(&wd->sc_dk.dk_label,
|
||||
(struct disklabel *)addr,
|
||||
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openmask : */0,
|
||||
(struct disklabel *)addr, /*wd->sc_dk.dk_openmask : */0,
|
||||
&wd->sc_dk.dk_cpulabel);
|
||||
if (error == 0) {
|
||||
wd->sc_flags |= WDF_BSDLABEL;
|
||||
if (wd->sc_state > GEOMETRY)
|
||||
wd->sc_state = GEOMETRY;
|
||||
}
|
||||
|
@ -1366,11 +1349,9 @@ wdioctl(dev, command, addr, flag, p)
|
|||
if ((flag & FWRITE) == 0)
|
||||
return EBADF;
|
||||
error = setdisklabel(&wd->sc_dk.dk_label,
|
||||
(struct disklabel *)addr,
|
||||
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openmask : */0,
|
||||
(struct disklabel *)addr, /*wd->sc_dk.dk_openmask : */0,
|
||||
&wd->sc_dk.dk_cpulabel);
|
||||
if (error == 0) {
|
||||
wd->sc_flags |= WDF_BSDLABEL;
|
||||
if (wd->sc_state > GEOMETRY)
|
||||
wd->sc_state = GEOMETRY;
|
||||
|
||||
|
@ -1446,8 +1427,7 @@ wdsize(dev)
|
|||
return -1;
|
||||
wd = wdcd.cd_devs[WDUNIT(dev)];
|
||||
part = WDPART(dev);
|
||||
if ((wd->sc_flags & WDF_BSDLABEL) == 0 ||
|
||||
wd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
|
||||
if (wd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
|
||||
size = -1;
|
||||
else
|
||||
size = wd->sc_dk.dk_label.d_partitions[part].p_size;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: wd.c,v 1.127 1995/01/13 10:22:58 mycroft Exp $ */
|
||||
/* $NetBSD: wd.c,v 1.128 1995/01/13 10:46:32 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
|
||||
|
@ -137,9 +137,8 @@ struct wd_softc {
|
|||
#define WDF_LOCKED 0x01
|
||||
#define WDF_WANTED 0x02
|
||||
#define WDF_LOADED 0x04
|
||||
#define WDF_BSDLABEL 0x08 /* has a BSD disk label */
|
||||
#define WDF_WLABEL 0x10 /* label is writable */
|
||||
#define WDF_32BIT 0x20 /* can do 32-bit transfer */
|
||||
#define WDF_WLABEL 0x08 /* label is writable */
|
||||
#define WDF_32BIT 0x10 /* can do 32-bit transfer */
|
||||
|
||||
struct wdparams sc_params; /* ESDI/IDE drive/controller parameters */
|
||||
daddr_t sc_badsect[127]; /* 126 plus trailing -1 marker */
|
||||
|
@ -407,21 +406,13 @@ wdstrategy(bp)
|
|||
if (bp->b_bcount == 0)
|
||||
goto done;
|
||||
|
||||
/* Have partitions and want to use them? */
|
||||
if (WDPART(bp->b_dev) != RAW_PART) {
|
||||
if ((wd->sc_flags & WDF_BSDLABEL) == 0) {
|
||||
bp->b_error = EIO;
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
* Do bounds checking, adjust transfer. if error, process.
|
||||
* If end of partition, just return.
|
||||
*/
|
||||
if (bounds_check_with_label(bp, &wd->sc_dk.dk_label,
|
||||
(wd->sc_flags & WDF_WLABEL) != 0) <= 0)
|
||||
goto done;
|
||||
/* Otherwise, process transfer request. */
|
||||
}
|
||||
/*
|
||||
* Do bounds checking, adjust transfer. if error, process.
|
||||
* If end of partition, just return.
|
||||
*/
|
||||
if (bounds_check_with_label(bp, &wd->sc_dk.dk_label,
|
||||
(wd->sc_flags & WDF_WLABEL) != 0) <= 0)
|
||||
goto done;
|
||||
|
||||
/* Don't bother doing rotational optimization. */
|
||||
bp->b_cylin = 0;
|
||||
|
@ -890,7 +881,6 @@ wdopen(dev, flag, fmt)
|
|||
wd->sc_flags |= WDF_LOCKED;
|
||||
|
||||
if ((wd->sc_flags & WDF_LOADED) == 0) {
|
||||
wd->sc_flags &= ~WDF_BSDLABEL;
|
||||
wd->sc_flags |= WDF_LOADED;
|
||||
|
||||
/* Load the physical device parameters. */
|
||||
|
@ -952,9 +942,6 @@ wdgetdisklabel(wd)
|
|||
{
|
||||
char *errstring;
|
||||
|
||||
if ((wd->sc_flags & WDF_BSDLABEL) != 0)
|
||||
return;
|
||||
|
||||
bzero(&wd->sc_dk.dk_label, sizeof(struct disklabel));
|
||||
bzero(&wd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
||||
|
||||
|
@ -1014,8 +1001,6 @@ wdgetdisklabel(wd)
|
|||
wd->sc_state = GEOMETRY;
|
||||
if ((wd->sc_dk.dk_label.d_flags & D_BADSECT) != 0)
|
||||
bad144intern(wd);
|
||||
|
||||
wd->sc_flags |= WDF_BSDLABEL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1343,11 +1328,9 @@ wdioctl(dev, command, addr, flag, p)
|
|||
if ((flag & FWRITE) == 0)
|
||||
return EBADF;
|
||||
error = setdisklabel(&wd->sc_dk.dk_label,
|
||||
(struct disklabel *)addr,
|
||||
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openmask : */0,
|
||||
(struct disklabel *)addr, /*wd->sc_dk.dk_openmask : */0,
|
||||
&wd->sc_dk.dk_cpulabel);
|
||||
if (error == 0) {
|
||||
wd->sc_flags |= WDF_BSDLABEL;
|
||||
if (wd->sc_state > GEOMETRY)
|
||||
wd->sc_state = GEOMETRY;
|
||||
}
|
||||
|
@ -1366,11 +1349,9 @@ wdioctl(dev, command, addr, flag, p)
|
|||
if ((flag & FWRITE) == 0)
|
||||
return EBADF;
|
||||
error = setdisklabel(&wd->sc_dk.dk_label,
|
||||
(struct disklabel *)addr,
|
||||
/*(wd->sc_flags & WDF_BSDLABEL) ? wd->sc_dk.dk_openmask : */0,
|
||||
(struct disklabel *)addr, /*wd->sc_dk.dk_openmask : */0,
|
||||
&wd->sc_dk.dk_cpulabel);
|
||||
if (error == 0) {
|
||||
wd->sc_flags |= WDF_BSDLABEL;
|
||||
if (wd->sc_state > GEOMETRY)
|
||||
wd->sc_state = GEOMETRY;
|
||||
|
||||
|
@ -1446,8 +1427,7 @@ wdsize(dev)
|
|||
return -1;
|
||||
wd = wdcd.cd_devs[WDUNIT(dev)];
|
||||
part = WDPART(dev);
|
||||
if ((wd->sc_flags & WDF_BSDLABEL) == 0 ||
|
||||
wd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
|
||||
if (wd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
|
||||
size = -1;
|
||||
else
|
||||
size = wd->sc_dk.dk_label.d_partitions[part].p_size;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cd.c,v 1.47 1994/12/28 19:42:47 mycroft Exp $ */
|
||||
/* $NetBSD: cd.c,v 1.48 1995/01/13 10:51:14 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||
|
@ -88,7 +88,6 @@ struct cd_softc {
|
|||
int flags;
|
||||
#define CDF_LOCKED 0x01
|
||||
#define CDF_WANTED 0x02
|
||||
#define CDF_BSDLABEL 0x04
|
||||
struct scsi_link *sc_link; /* address of scsi low level switch */
|
||||
struct cd_parms {
|
||||
int blksize;
|
||||
|
@ -249,7 +248,6 @@ cdopen(dev, flag, fmt)
|
|||
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY);
|
||||
|
||||
if ((sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
|
||||
cd->flags &= ~CDF_BSDLABEL;
|
||||
sc_link->flags |= SDEV_MEDIA_LOADED;
|
||||
|
||||
/* Load the physical device parameters. */
|
||||
|
@ -416,22 +414,13 @@ cdstrategy(bp)
|
|||
*/
|
||||
if (bp->b_bcount == 0)
|
||||
goto done;
|
||||
|
||||
/*
|
||||
* Decide which unit and partition we are talking about
|
||||
* Do bounds checking, adjust transfer. if error, process.
|
||||
* If end of partition, just return.
|
||||
*/
|
||||
if (CDPART(bp->b_dev) != RAW_PART) {
|
||||
if ((cd->flags & CDF_BSDLABEL) == 0) {
|
||||
bp->b_error = EIO;
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
* do bounds checking, adjust transfer. if error, process.
|
||||
* if end of partition, just return
|
||||
*/
|
||||
if (bounds_check_with_label(bp, &cd->sc_dk.dk_label, 1) <= 0)
|
||||
goto done;
|
||||
/* otherwise, process transfer request */
|
||||
}
|
||||
if (bounds_check_with_label(bp, &cd->sc_dk.dk_label, 0) <= 0)
|
||||
goto done;
|
||||
|
||||
opri = splbio();
|
||||
|
||||
|
@ -601,11 +590,8 @@ cdioctl(dev, cmd, addr, flag, p)
|
|||
if ((flag & FWRITE) == 0)
|
||||
return EBADF;
|
||||
error = setdisklabel(&cd->sc_dk.dk_label,
|
||||
(struct disklabel *)addr,
|
||||
/*(cd->flags & CDF_BSDLABEL) ? cd->sc_dk.dk_openmask : */0,
|
||||
(struct disklabel *)addr, /*cd->sc_dk.dk_openmask : */0,
|
||||
&cd->sc_dk.dk_cpulabel);
|
||||
if (error == 0)
|
||||
cd->flags |= CDF_BSDLABEL;
|
||||
return error;
|
||||
|
||||
case DIOCWLABEL:
|
||||
|
@ -831,9 +817,6 @@ cdgetdisklabel(cd)
|
|||
struct cd_softc *cd;
|
||||
{
|
||||
|
||||
if ((cd->flags & CDF_BSDLABEL) != 0)
|
||||
return;
|
||||
|
||||
bzero(&cd->sc_dk.dk_label, sizeof(struct disklabel));
|
||||
bzero(&cd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
||||
|
||||
|
@ -862,8 +845,6 @@ cdgetdisklabel(cd)
|
|||
cd->sc_dk.dk_label.d_magic = DISKMAGIC;
|
||||
cd->sc_dk.dk_label.d_magic2 = DISKMAGIC;
|
||||
cd->sc_dk.dk_label.d_checksum = dkcksum(&cd->sc_dk.dk_label);
|
||||
|
||||
cd->flags |= CDF_BSDLABEL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sd.c,v 1.51 1994/12/28 19:43:13 mycroft Exp $ */
|
||||
/* $NetBSD: sd.c,v 1.52 1995/01/13 10:51:18 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||
|
@ -87,8 +87,7 @@ struct sd_softc {
|
|||
int flags;
|
||||
#define SDF_LOCKED 0x01
|
||||
#define SDF_WANTED 0x02
|
||||
#define SDF_BSDLABEL 0x04
|
||||
#define SDF_WLABEL 0x08 /* label is writable */
|
||||
#define SDF_WLABEL 0x04 /* label is writable */
|
||||
struct scsi_link *sc_link; /* contains our targ, lun etc. */
|
||||
struct disk_parms {
|
||||
u_char heads; /* Number of heads */
|
||||
|
@ -252,7 +251,6 @@ sdopen(dev, flag, fmt)
|
|||
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY);
|
||||
|
||||
if ((sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
|
||||
sd->flags &= ~SDF_BSDLABEL;
|
||||
sc_link->flags |= SDEV_MEDIA_LOADED;
|
||||
|
||||
/* Load the physical device parameters. */
|
||||
|
@ -419,24 +417,14 @@ sdstrategy(bp)
|
|||
*/
|
||||
if (bp->b_bcount == 0)
|
||||
goto done;
|
||||
|
||||
/*
|
||||
* Decide which unit and partition we are talking about
|
||||
* only raw is ok if no label
|
||||
* Do bounds checking, adjust transfer. if error, process.
|
||||
* If end of partition, just return.
|
||||
*/
|
||||
if (SDPART(bp->b_dev) != RAW_PART) {
|
||||
if ((sd->flags & SDF_BSDLABEL) == 0) {
|
||||
bp->b_error = EIO;
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
* do bounds checking, adjust transfer. if error, process.
|
||||
* if end of partition, just return
|
||||
*/
|
||||
if (bounds_check_with_label(bp, &sd->sc_dk.dk_label,
|
||||
(sd->flags & SDF_WLABEL) != 0) <= 0)
|
||||
goto done;
|
||||
/* otherwise, process transfer request */
|
||||
}
|
||||
if (bounds_check_with_label(bp, &sd->sc_dk.dk_label,
|
||||
(sd->flags & SDF_WLABEL) != 0) <= 0)
|
||||
goto done;
|
||||
|
||||
opri = splbio();
|
||||
|
||||
|
@ -601,11 +589,8 @@ sdioctl(dev, cmd, addr, flag, p)
|
|||
if ((flag & FWRITE) == 0)
|
||||
return EBADF;
|
||||
error = setdisklabel(&sd->sc_dk.dk_label,
|
||||
(struct disklabel *)addr,
|
||||
/*(sd->flags & SDF_BSDLABEL) ? sd->sc_dk.dk_openmask : */0,
|
||||
(struct disklabel *)addr, /*sd->sc_dk.dk_openmask : */0,
|
||||
&sd->sc_dk.dk_cpulabel);
|
||||
if (error == 0)
|
||||
sd->flags |= SDF_BSDLABEL;
|
||||
return error;
|
||||
|
||||
case DIOCWLABEL:
|
||||
|
@ -621,12 +606,9 @@ sdioctl(dev, cmd, addr, flag, p)
|
|||
if ((flag & FWRITE) == 0)
|
||||
return EBADF;
|
||||
error = setdisklabel(&sd->sc_dk.dk_label,
|
||||
(struct disklabel *)addr,
|
||||
/*(sd->flags & SDF_BSDLABEL) ? sd->sc_dk.dk_openmask : */0,
|
||||
(struct disklabel *)addr, /*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_openmask |= (1 << 0); /* XXX */
|
||||
error = writedisklabel(SDLABELDEV(dev), sdstrategy,
|
||||
|
@ -656,9 +638,6 @@ sdgetdisklabel(sd)
|
|||
{
|
||||
char *errstring;
|
||||
|
||||
if ((sd->flags & SDF_BSDLABEL) != 0)
|
||||
return;
|
||||
|
||||
bzero(&sd->sc_dk.dk_label, sizeof(struct disklabel));
|
||||
bzero(&sd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
||||
|
||||
|
@ -701,8 +680,6 @@ sdgetdisklabel(sd)
|
|||
printf("%s: %s\n", sd->sc_dev.dv_xname, errstring);
|
||||
return;
|
||||
}
|
||||
|
||||
sd->flags |= SDF_BSDLABEL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -861,8 +838,7 @@ sdsize(dev)
|
|||
return -1;
|
||||
sd = sdcd.cd_devs[SDUNIT(dev)];
|
||||
part = SDPART(dev);
|
||||
if ((sd->flags & SDF_BSDLABEL) == 0 ||
|
||||
sd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
|
||||
if (sd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
|
||||
size = -1;
|
||||
else
|
||||
size = sd->sc_dk.dk_label.d_partitions[part].p_size;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cd.c,v 1.47 1994/12/28 19:42:47 mycroft Exp $ */
|
||||
/* $NetBSD: cd.c,v 1.48 1995/01/13 10:51:14 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||
|
@ -88,7 +88,6 @@ struct cd_softc {
|
|||
int flags;
|
||||
#define CDF_LOCKED 0x01
|
||||
#define CDF_WANTED 0x02
|
||||
#define CDF_BSDLABEL 0x04
|
||||
struct scsi_link *sc_link; /* address of scsi low level switch */
|
||||
struct cd_parms {
|
||||
int blksize;
|
||||
|
@ -249,7 +248,6 @@ cdopen(dev, flag, fmt)
|
|||
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY);
|
||||
|
||||
if ((sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
|
||||
cd->flags &= ~CDF_BSDLABEL;
|
||||
sc_link->flags |= SDEV_MEDIA_LOADED;
|
||||
|
||||
/* Load the physical device parameters. */
|
||||
|
@ -416,22 +414,13 @@ cdstrategy(bp)
|
|||
*/
|
||||
if (bp->b_bcount == 0)
|
||||
goto done;
|
||||
|
||||
/*
|
||||
* Decide which unit and partition we are talking about
|
||||
* Do bounds checking, adjust transfer. if error, process.
|
||||
* If end of partition, just return.
|
||||
*/
|
||||
if (CDPART(bp->b_dev) != RAW_PART) {
|
||||
if ((cd->flags & CDF_BSDLABEL) == 0) {
|
||||
bp->b_error = EIO;
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
* do bounds checking, adjust transfer. if error, process.
|
||||
* if end of partition, just return
|
||||
*/
|
||||
if (bounds_check_with_label(bp, &cd->sc_dk.dk_label, 1) <= 0)
|
||||
goto done;
|
||||
/* otherwise, process transfer request */
|
||||
}
|
||||
if (bounds_check_with_label(bp, &cd->sc_dk.dk_label, 0) <= 0)
|
||||
goto done;
|
||||
|
||||
opri = splbio();
|
||||
|
||||
|
@ -601,11 +590,8 @@ cdioctl(dev, cmd, addr, flag, p)
|
|||
if ((flag & FWRITE) == 0)
|
||||
return EBADF;
|
||||
error = setdisklabel(&cd->sc_dk.dk_label,
|
||||
(struct disklabel *)addr,
|
||||
/*(cd->flags & CDF_BSDLABEL) ? cd->sc_dk.dk_openmask : */0,
|
||||
(struct disklabel *)addr, /*cd->sc_dk.dk_openmask : */0,
|
||||
&cd->sc_dk.dk_cpulabel);
|
||||
if (error == 0)
|
||||
cd->flags |= CDF_BSDLABEL;
|
||||
return error;
|
||||
|
||||
case DIOCWLABEL:
|
||||
|
@ -831,9 +817,6 @@ cdgetdisklabel(cd)
|
|||
struct cd_softc *cd;
|
||||
{
|
||||
|
||||
if ((cd->flags & CDF_BSDLABEL) != 0)
|
||||
return;
|
||||
|
||||
bzero(&cd->sc_dk.dk_label, sizeof(struct disklabel));
|
||||
bzero(&cd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
||||
|
||||
|
@ -862,8 +845,6 @@ cdgetdisklabel(cd)
|
|||
cd->sc_dk.dk_label.d_magic = DISKMAGIC;
|
||||
cd->sc_dk.dk_label.d_magic2 = DISKMAGIC;
|
||||
cd->sc_dk.dk_label.d_checksum = dkcksum(&cd->sc_dk.dk_label);
|
||||
|
||||
cd->flags |= CDF_BSDLABEL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sd.c,v 1.51 1994/12/28 19:43:13 mycroft Exp $ */
|
||||
/* $NetBSD: sd.c,v 1.52 1995/01/13 10:51:18 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||
|
@ -87,8 +87,7 @@ struct sd_softc {
|
|||
int flags;
|
||||
#define SDF_LOCKED 0x01
|
||||
#define SDF_WANTED 0x02
|
||||
#define SDF_BSDLABEL 0x04
|
||||
#define SDF_WLABEL 0x08 /* label is writable */
|
||||
#define SDF_WLABEL 0x04 /* label is writable */
|
||||
struct scsi_link *sc_link; /* contains our targ, lun etc. */
|
||||
struct disk_parms {
|
||||
u_char heads; /* Number of heads */
|
||||
|
@ -252,7 +251,6 @@ sdopen(dev, flag, fmt)
|
|||
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY);
|
||||
|
||||
if ((sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
|
||||
sd->flags &= ~SDF_BSDLABEL;
|
||||
sc_link->flags |= SDEV_MEDIA_LOADED;
|
||||
|
||||
/* Load the physical device parameters. */
|
||||
|
@ -419,24 +417,14 @@ sdstrategy(bp)
|
|||
*/
|
||||
if (bp->b_bcount == 0)
|
||||
goto done;
|
||||
|
||||
/*
|
||||
* Decide which unit and partition we are talking about
|
||||
* only raw is ok if no label
|
||||
* Do bounds checking, adjust transfer. if error, process.
|
||||
* If end of partition, just return.
|
||||
*/
|
||||
if (SDPART(bp->b_dev) != RAW_PART) {
|
||||
if ((sd->flags & SDF_BSDLABEL) == 0) {
|
||||
bp->b_error = EIO;
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
* do bounds checking, adjust transfer. if error, process.
|
||||
* if end of partition, just return
|
||||
*/
|
||||
if (bounds_check_with_label(bp, &sd->sc_dk.dk_label,
|
||||
(sd->flags & SDF_WLABEL) != 0) <= 0)
|
||||
goto done;
|
||||
/* otherwise, process transfer request */
|
||||
}
|
||||
if (bounds_check_with_label(bp, &sd->sc_dk.dk_label,
|
||||
(sd->flags & SDF_WLABEL) != 0) <= 0)
|
||||
goto done;
|
||||
|
||||
opri = splbio();
|
||||
|
||||
|
@ -601,11 +589,8 @@ sdioctl(dev, cmd, addr, flag, p)
|
|||
if ((flag & FWRITE) == 0)
|
||||
return EBADF;
|
||||
error = setdisklabel(&sd->sc_dk.dk_label,
|
||||
(struct disklabel *)addr,
|
||||
/*(sd->flags & SDF_BSDLABEL) ? sd->sc_dk.dk_openmask : */0,
|
||||
(struct disklabel *)addr, /*sd->sc_dk.dk_openmask : */0,
|
||||
&sd->sc_dk.dk_cpulabel);
|
||||
if (error == 0)
|
||||
sd->flags |= SDF_BSDLABEL;
|
||||
return error;
|
||||
|
||||
case DIOCWLABEL:
|
||||
|
@ -621,12 +606,9 @@ sdioctl(dev, cmd, addr, flag, p)
|
|||
if ((flag & FWRITE) == 0)
|
||||
return EBADF;
|
||||
error = setdisklabel(&sd->sc_dk.dk_label,
|
||||
(struct disklabel *)addr,
|
||||
/*(sd->flags & SDF_BSDLABEL) ? sd->sc_dk.dk_openmask : */0,
|
||||
(struct disklabel *)addr, /*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_openmask |= (1 << 0); /* XXX */
|
||||
error = writedisklabel(SDLABELDEV(dev), sdstrategy,
|
||||
|
@ -656,9 +638,6 @@ sdgetdisklabel(sd)
|
|||
{
|
||||
char *errstring;
|
||||
|
||||
if ((sd->flags & SDF_BSDLABEL) != 0)
|
||||
return;
|
||||
|
||||
bzero(&sd->sc_dk.dk_label, sizeof(struct disklabel));
|
||||
bzero(&sd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
|
||||
|
||||
|
@ -701,8 +680,6 @@ sdgetdisklabel(sd)
|
|||
printf("%s: %s\n", sd->sc_dev.dv_xname, errstring);
|
||||
return;
|
||||
}
|
||||
|
||||
sd->flags |= SDF_BSDLABEL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -861,8 +838,7 @@ sdsize(dev)
|
|||
return -1;
|
||||
sd = sdcd.cd_devs[SDUNIT(dev)];
|
||||
part = SDPART(dev);
|
||||
if ((sd->flags & SDF_BSDLABEL) == 0 ||
|
||||
sd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
|
||||
if (sd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
|
||||
size = -1;
|
||||
else
|
||||
size = sd->sc_dk.dk_label.d_partitions[part].p_size;
|
||||
|
|
Loading…
Reference in New Issue