Merged from sys/isa/fd.c revision 1.197.

This commit is contained in:
kato 2001-05-15 08:55:30 +00:00
parent 0877e37ec1
commit a4dc3b58c8
2 changed files with 80 additions and 46 deletions

View File

@ -18,6 +18,9 @@
* joerg_wunsch@uriah.sax.de (Joerg Wunsch)
* dufault@hda.com (Peter Dufault)
*
* Copyright (c) 2001 Joerg Wunsch,
* joerg_wunsch@uriah.sax.de (Joerg Wunsch)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -26,13 +29,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@ -1836,7 +1832,7 @@ fdclose(dev_t dev, int flags, int mode, struct proc *p)
fd = devclass_get_softc(fd_devclass, fdu);
fd->flags &= ~FD_OPEN;
fd->options &= ~FDOPT_NORETRY;
fd->options &= ~(FDOPT_NORETRY | FDOPT_NOERRLOG | FDOPT_NOERROR);
return (0);
}
@ -2661,12 +2657,16 @@ retrier(struct fdc_data *fdc)
fail:
{
dev_t sav_bio_dev = bp->bio_dev;
int printerror = (fd->options & FDOPT_NOERRLOG) == 0;
/* Trick diskerr */
bp->bio_dev = makedev(major(bp->bio_dev),
(FDUNIT(minor(bp->bio_dev))<<3)|RAW_PART);
if (printerror)
diskerr(bp, "hard error", fdc->fd->skip / DEV_BSIZE,
(struct disklabel *)NULL);
bp->bio_dev = sav_bio_dev;
if (printerror) {
if (fdc->flags & FDC_STAT_VALID)
{
printf(
@ -2680,9 +2680,12 @@ retrier(struct fdc_data *fdc)
else
printf(" (No status)\n");
}
}
if ((fd->options & FDOPT_NOERROR) == 0) {
bp->bio_flags |= BIO_ERROR;
bp->bio_error = EIO;
bp->bio_resid += bp->bio_bcount - fdc->fd->skip;
}
fdc->bp = NULL;
fdc->fd->skip = 0;
device_unbusy(fd->dev);
@ -2788,6 +2791,7 @@ fdioctl(dev, cmd, addr, flag, p)
struct fd_type *fdt;
struct disklabel *dl;
struct fdc_status *fsp;
char buffer[DEV_BSIZE];
int error = 0;
@ -2867,6 +2871,19 @@ fdioctl(dev, cmd, addr, flag, p)
fd->options = *(int *)addr;
break;
case FD_CLRERR:
if (suser(p) != 0)
return EPERM;
fd->fdc->fdc_errs = 0;
break;
case FD_GSTAT:
fsp = (struct fdc_status *)addr;
if ((fd->fdc->flags & FDC_STAT_VALID) == 0)
return EINVAL;
memcpy(fsp->status, fd->fdc->status, 7 * sizeof(u_int));
break;
default:
error = ENOTTY;
break;

View File

@ -18,6 +18,9 @@
* joerg_wunsch@uriah.sax.de (Joerg Wunsch)
* dufault@hda.com (Peter Dufault)
*
* Copyright (c) 2001 Joerg Wunsch,
* joerg_wunsch@uriah.sax.de (Joerg Wunsch)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -26,13 +29,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@ -1836,7 +1832,7 @@ fdclose(dev_t dev, int flags, int mode, struct proc *p)
fd = devclass_get_softc(fd_devclass, fdu);
fd->flags &= ~FD_OPEN;
fd->options &= ~FDOPT_NORETRY;
fd->options &= ~(FDOPT_NORETRY | FDOPT_NOERRLOG | FDOPT_NOERROR);
return (0);
}
@ -2661,12 +2657,16 @@ retrier(struct fdc_data *fdc)
fail:
{
dev_t sav_bio_dev = bp->bio_dev;
int printerror = (fd->options & FDOPT_NOERRLOG) == 0;
/* Trick diskerr */
bp->bio_dev = makedev(major(bp->bio_dev),
(FDUNIT(minor(bp->bio_dev))<<3)|RAW_PART);
if (printerror)
diskerr(bp, "hard error", fdc->fd->skip / DEV_BSIZE,
(struct disklabel *)NULL);
bp->bio_dev = sav_bio_dev;
if (printerror) {
if (fdc->flags & FDC_STAT_VALID)
{
printf(
@ -2680,9 +2680,12 @@ retrier(struct fdc_data *fdc)
else
printf(" (No status)\n");
}
}
if ((fd->options & FDOPT_NOERROR) == 0) {
bp->bio_flags |= BIO_ERROR;
bp->bio_error = EIO;
bp->bio_resid += bp->bio_bcount - fdc->fd->skip;
}
fdc->bp = NULL;
fdc->fd->skip = 0;
device_unbusy(fd->dev);
@ -2788,6 +2791,7 @@ fdioctl(dev, cmd, addr, flag, p)
struct fd_type *fdt;
struct disklabel *dl;
struct fdc_status *fsp;
char buffer[DEV_BSIZE];
int error = 0;
@ -2867,6 +2871,19 @@ fdioctl(dev, cmd, addr, flag, p)
fd->options = *(int *)addr;
break;
case FD_CLRERR:
if (suser(p) != 0)
return EPERM;
fd->fdc->fdc_errs = 0;
break;
case FD_GSTAT:
fsp = (struct fdc_status *)addr;
if ((fd->fdc->flags & FDC_STAT_VALID) == 0)
return EINVAL;
memcpy(fsp->status, fd->fdc->status, 7 * sizeof(u_int));
break;
default:
error = ENOTTY;
break;