From owner-freebsd-current@FreeBSD.ORG Sun May 14 18:47:16 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C79F416A403 for ; Sun, 14 May 2006 18:47:16 +0000 (UTC) (envelope-from uspoerlein@gmail.com) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.190]) by mx1.FreeBSD.org (Postfix) with ESMTP id A5CEE43D48 for ; Sun, 14 May 2006 18:47:15 +0000 (GMT) (envelope-from uspoerlein@gmail.com) Received: by nf-out-0910.google.com with SMTP id n15so5690nfc for ; Sun, 14 May 2006 11:47:14 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:date:from:to:subject:message-id:mail-followup-to:mime-version:content-type:content-disposition:sender; b=Wkk9dgA9MWzyv06Jiotf+FaJhOjMWZPrvqvsV5vFLOt8908aWrxfp52H90W1Zx0UQfyLbht86bd0FO0CwogxoDvHfWEs1Ukj47HX4Ymar1voUtiPWK5GEQxe6x550tUNFRtLC6you0lAX2+KfKdvQBV0Oo70bl8w/YKGDOIX7g0= Received: by 10.48.220.3 with SMTP id s3mr1448889nfg; Sun, 14 May 2006 11:47:14 -0700 (PDT) Received: from roadrunner.q.local ( [217.185.114.67]) by mx.gmail.com with ESMTP id x1sm1057182nfb.2006.05.14.11.46.47; Sun, 14 May 2006 11:47:14 -0700 (PDT) Received: from roadrunner.q.local (localhost [127.0.0.1]) by roadrunner.q.local (8.13.6/8.13.6) with ESMTP id k4EIj8jN004879 for ; Sun, 14 May 2006 20:45:09 +0200 (CEST) (envelope-from spoerlein@informatik.uni-wuerzburg.de) Received: (from q@localhost) by roadrunner.q.local (8.13.6/8.13.6/Submit) id k4EHlItv004595 for current@freebsd.org; Sun, 14 May 2006 19:47:18 +0200 (CEST) (envelope-from spoerlein@informatik.uni-wuerzburg.de) Date: Sun, 14 May 2006 19:47:18 +0200 From: Ulrich Spoerlein To: current@freebsd.org Message-ID: <20060514174718.GA4496@roadrunner.informatik.uni-wuerzburg.de> Mail-Followup-To: current@freebsd.org MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="BwCQnh7xodEAoBMC" Content-Disposition: inline Sender: Ulrich Spoerlein Cc: Subject: cdcontrol -f /cdrom eject X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 May 2006 18:47:20 -0000 --BwCQnh7xodEAoBMC Content-Type: multipart/mixed; boundary="LQksG6bCIzRHxTLp" Content-Disposition: inline --LQksG6bCIzRHxTLp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello everybody, I tried to make 'cdcontrol -f /mountpoint eject' work, but I found something strange while implementing it. First of all, cdcontrol will eject the media, even if it is currently mounted. Shouldn't mount lock the media, and only unmount unlock it? To reproduce % mount /cdrom % mount|grep acd0 % cdcontrol -f /dev/acd0 eject # works % mount|grep acd0 # still mounted Attached is a patch that will umount the given mount-point first, then eject the media. I wonder why the CDIOCALLOW is necessary even if the media was not previously mounted. It only seems to make a difference with cd(4), acd(4) will eject the media even without the CDIOCALLOW call. Very strange (at least to me), or it might be bad atapicam-mojo that's interfering. Anyway, comments are appreciated! Ulrich Spoerlein --=20 PGP Key ID: 20FEE9DD Encrypted mail welcome! Fingerprint: AEC9 AF5E 01AC 4EE1 8F70 6CBD E76E 2227 20FE E9DD Which is worse: ignorance or apathy? Don't know. Don't care. --LQksG6bCIzRHxTLp Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Content-Transfer-Encoding: quoted-printable --- cdcontrol.c.orig Sun May 14 19:46:39 2006 +++ cdcontrol.c Sun May 14 19:46:24 2006 @@ -26,10 +26,14 @@ #include #include #include +#include +#include +#include #include #include #include #include +#include #include #include #include @@ -167,7 +171,7 @@ =20 void usage () { - fprintf (stderr, "usage: cdcontrol [-sv] [-f device] [command ...]\n"); + fprintf (stderr, "usage: cdcontrol [-sv] [-f device|mountpoint] [command = =2E..]\n"); exit (1); } =20 @@ -271,6 +275,8 @@ { long speed; int l, r, rc; + struct stat sb; + struct statfs sfsb; =20 switch (cmd) { =20 @@ -353,6 +359,23 @@ return (0); =20 case CMD_EJECT: + if (stat(cdname, &sb) !=3D 0) + warn("stat failed, %s", cdname); + /* Unmount first, if directory */ + else if (S_ISDIR(sb.st_mode)) { + if (statfs(cdname, &sfsb) !=3D 0) + warn("statfs failed, %s", cdname); + else { + if (strncmp(cdname, sfsb.f_mntonname, MAXPATHLEN) !=3D 0) + warnx("device %s and mountpoint %s differ", + cdname, sfsb.f_mntonname); + if (unmount(cdname, 0) !=3D 0) + warn("umount of %s failed", cdname); + else + cdname =3D sfsb.f_mntfromname; + } + } + if (fd < 0 && ! open_cd ()) return (0); =20 --LQksG6bCIzRHxTLp-- --BwCQnh7xodEAoBMC Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (FreeBSD) iD8DBQFEZ20l524iJyD+6d0RAnc5AJwJ8K6xh/LyOnrvC+gHw2oY/Vy+2QCdH98i xdhNTbklg3DgJDmDJDRJfsw= =X/yA -----END PGP SIGNATURE----- --BwCQnh7xodEAoBMC--