svn commit: r208530 - stable/8/usr.sbin/sysinstall

Randi Harper randi at FreeBSD.org
Tue May 25 03:15:10 UTC 2010


Author: randi
Date: Tue May 25 03:15:09 2010
New Revision: 208530
URL: http://svn.freebsd.org/changeset/base/208530

Log:
  MFC r198477,198503:
    Eject CDROM after installation if used as source media.
  
  Approved by: cperciva (mentor)

Modified:
  stable/8/usr.sbin/sysinstall/cdrom.c
Directory Properties:
  stable/8/usr.sbin/sysinstall/   (props changed)

Modified: stable/8/usr.sbin/sysinstall/cdrom.c
==============================================================================
--- stable/8/usr.sbin/sysinstall/cdrom.c	Tue May 25 03:08:47 2010	(r208529)
+++ stable/8/usr.sbin/sysinstall/cdrom.c	Tue May 25 03:15:09 2010	(r208530)
@@ -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
 static char mountpoint[MAXPATHLEN] = "/dist";
 int CDROMInitQuiet;
 
+static void mediaEjectCDROM(Device *dev);
+
 static properties
 read_props(char *name)
 {
@@ -218,4 +221,24 @@ 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);
+		close(fd);
+	}
 }


More information about the svn-src-all mailing list