Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Oct 1999 16:52:28 -0700 (PDT)
From:      "Ronald F. Guilmette" <rfg@monkeys.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/14561: ioctl (fd, CDIOCEJECT, (void*) 0) doesn't work, even on SCSI CD drives
Message-ID:  <199910272352.QAA63935@monkeys.com>

next in thread | raw e-mail | index | archive | help

>Number:         14561
>Category:       kern
>Synopsis:       ioctl (fd, CDIOCEJECT, (void*) 0) doesn't work
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 27 17:00:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Ronald F. Guilmette
>Release:        FreeBSD 3.3-RELEASE i386
>Organization:
E-Scrub Technologies, Inc.
>Environment:

>Description:

	Calling ioctl (fd, CDIOCEJECT, (void*) 0) from within a C program
	for an `fd' value which is an open file descriptor for a SCSI CDROM
	drive that *does* have eject capabilities and that *does* currently
	contain a loaded CD fails to cause the drive to perform the eject
	operation, and the call returns with a negative (-1?) result and
	with ERRNO set to the mysterious and uninformative value of `EIO'
	(``Input/output error'').

>How-To-Repeat:

	Compile and run the following trivial program giving it "/dev/cd0c"
	as its one and only command line argument.  Execute the program
	_only_ on a system with a SCSI CDROM drive that has programmed
	ejection capability, and only when there is already a CD loaded
	in the drive.  (I also tried specifying "/dev/rcd0c" and also
	"/dev/cd0a" and even "/dev/rcd0a" and none of these worked any
	better.)

	--------------------------------------------------------------------
	/* eject.c - program for FreeBSD to eject a CD */
	/* Usage:
		eject [device]
	*/
	/* Copyright (c) 1999 Ronald F. Guilmette; all rights reserved. */
	
	#include <stdio.h>
	#include <errno.h>
	#include <string.h>
	#include <fcntl.h>
	#include <unistd.h>
	#include <sys/cdio.h>
	
	static char const *pname;
	
	int
	main (register int const argc, register char const **argv)
	{
	  register int ifd;
	  register char const *filename;
	
	  pname = strrchr (argv[0], '/');
	  pname = pname ? pname + 1 : argv[0];
	
	  filename = argv[1];
	
	  if ((ifd = open (filename, O_RDONLY)) == -1)
	    {
	      fprintf (stderr, "%s: Error opening `%s': %s\n",
		       pname, filename, strerror (errno));
	      return 1;
	    }
	  if (ioctl (ifd, CDIOCEJECT, (void*) 0) == -1)
	    {
	      fprintf (stderr, "%s: Error opening `%s': %s\n",
		       pname, filename, strerror (errno));
	      return 1;
	    }
	  close (ifd);
	  return 0;
	}
	--------------------------------------------------------------------

>Fix:

	Manually eject the CD.  (Difficult, if you are not physically adjacent
	to it.)


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199910272352.QAA63935>