svn commit: r198477 - head/usr.sbin/sysinstall
Ronald Klop
ronald-freebsd8 at klop.yi.org
Mon Oct 26 20:33:04 UTC 2009
I'm no committer, but isn't it nice to close the fd?
Ronald.
On Mon, 26 Oct 2009 07:51:21 +0100, Colin Percival <cperciva at freebsd.org>
wrote:
> Author: cperciva
> Date: Mon Oct 26 06:51:20 2009
> New Revision: 198477
> URL: http://svn.freebsd.org/changeset/base/198477
>
> Log:
> Eject CDROM after installation if used as source media.
> Submitted by: randi
> MFC after: 1 month
>
> Modified:
> head/usr.sbin/sysinstall/cdrom.c
>
> Modified: head/usr.sbin/sysinstall/cdrom.c
> ==============================================================================
> --- head/usr.sbin/sysinstall/cdrom.c Mon Oct 26 00:01:52 2009 (r198476)
> +++ head/usr.sbin/sysinstall/cdrom.c Mon Oct 26 06:51:20 2009 (r198477)
> @@ -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,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);
> + }
> }
> _______________________________________________
> svn-src-all at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscribe at freebsd.org"
More information about the svn-src-all
mailing list