diff options
author | cperciva <cperciva@FreeBSD.org> | 2009-10-26 06:51:20 +0000 |
---|---|---|
committer | cperciva <cperciva@FreeBSD.org> | 2009-10-26 06:51:20 +0000 |
commit | dbf6ce4802c38d4d6f8bc8686bb95637661ed8e2 (patch) | |
tree | e7bf302840b5eb085fb127bfe47488a2d5a7755d | |
parent | d4f827eb7aac16e5c12a421026362bdcbdf6ac97 (diff) | |
download | FreeBSD-src-dbf6ce4802c38d4d6f8bc8686bb95637661ed8e2.zip FreeBSD-src-dbf6ce4802c38d4d6f8bc8686bb95637661ed8e2.tar.gz |
Eject CDROM after installation if used as source media.
Submitted by: randi
MFC after: 1 month
-rw-r--r-- | usr.sbin/sysinstall/cdrom.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/usr.sbin/sysinstall/cdrom.c b/usr.sbin/sysinstall/cdrom.c index a5029ec..07a3722 100644 --- a/usr.sbin/sysinstall/cdrom.c +++ b/usr.sbin/sysinstall/cdrom.c @@ -43,6 +43,7 @@ #include <sys/errno.h> #include <sys/param.h> #include <sys/wait.h> +#include <sys/cdio.h> #include <unistd.h> #include <grp.h> #include <fcntl.h> @@ -58,6 +59,8 @@ static Boolean previouslyMounted; /* Was the disc already mounted? */ static char mountpoint[MAXPATHLEN] = "/dist"; int CDROMInitQuiet; +static void mediaEjectCDROM(Device *dev); + static properties read_props(char *name) { @@ -218,4 +221,23 @@ mediaShutdownCDROM(Device *dev) msgConfirm("Could not unmount the CDROM/DVD from %s: %s", mountpoint, strerror(errno)); else cdromMounted = FALSE; + + mediaEjectCDROM(dev); +} + +static void +mediaEjectCDROM(Device *dev) +{ + int fd = -1; + + msgDebug("Ejecting CDROM/DVD at %s", dev->devname); + + fd = open(dev->devname, O_RDONLY); + + if (fd < 0) + msgDebug("Could not eject the CDROM/DVD from %s: %s", dev->devname, strerror(errno)); + else { + ioctl(fd, CDIOCALLOW); + ioctl(fd, CDIOCEJECT); + } } |