diff options
Diffstat (limited to 'sys/scsi/cd.c')
-rw-r--r-- | sys/scsi/cd.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c index a796cfac311..d50e5db0787 100644 --- a/sys/scsi/cd.c +++ b/sys/scsi/cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd.c,v 1.144 2008/08/01 01:44:20 dlg Exp $ */ +/* $OpenBSD: cd.c,v 1.145 2009/01/10 18:00:59 robert Exp $ */ /* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */ /* @@ -74,7 +74,7 @@ #include <scsi/scsiconf.h> -#include <ufs/ffs/fs.h> /* for BBSIZE and SBSIZE */ +#include <ufs/ffs/fs.h> /* for BBSIZE and SBSIZE */ #define CDOUTSTANDING 4 @@ -126,6 +126,10 @@ int dvd_read_struct(struct cd_softc *, union dvd_struct *); void cd_powerhook(int why, void *arg); +#if defined(__macppc__) +int cd_eject(void); +#endif + struct cfattach cd_ca = { sizeof(struct cd_softc), cdmatch, cdattach, cddetach, cdactivate @@ -1968,3 +1972,34 @@ cd_kill_buffers(struct cd_softc *cd) } splx(s); } + +#if defined(__macppc__) +int +cd_eject(void) +{ + struct cd_softc *cd; + int error = 0; + + if (cd_cd.cd_ndevs == 0 || (cd = cd_cd.cd_devs[0]) == NULL) + return (ENXIO); + + if ((error = cdlock(cd)) != 0) + return (error); + + if (cd->sc_dk.dk_openmask == 0) { + cd->sc_link->flags |= SDEV_EJECTING; + + scsi_prevent(cd->sc_link, PR_ALLOW, + SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY | + SCSI_SILENT | SCSI_IGNORE_MEDIA_CHANGE); + cd->sc_link->flags &= ~SDEV_MEDIA_LOADED; + + scsi_start(cd->sc_link, SSS_STOP|SSS_LOEJ, 0); + + cd->sc_link->flags &= ~SDEV_EJECTING; + } + cdunlock(cd); + + return (error); +} +#endif |