From stsp@stsp.in-berlin.de  Tue Jul 19 12:25:05 2005
Return-Path: <stsp@stsp.in-berlin.de>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E0A2616A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 19 Jul 2005 12:25:04 +0000 (GMT)
	(envelope-from stsp@stsp.in-berlin.de)
Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4814B43D4C
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 19 Jul 2005 12:25:03 +0000 (GMT)
	(envelope-from stsp@stsp.in-berlin.de)
Received: from dice.seeling33.de (e178132097.adsl.alicedsl.de [85.178.132.97])
	(authenticated bits=0)
	by einhorn.in-berlin.de (8.12.10/8.12.10/Debian-4) with ESMTP id j6JCOxS8000842
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 19 Jul 2005 14:25:01 +0200
Received: by dice.seeling33.de (Postfix, from userid 1001)
	id 5C60833C39; Tue, 19 Jul 2005 14:24:59 +0200 (CEST)
Message-Id: <20050719122459.5C60833C39@dice.seeling33.de>
Date: Tue, 19 Jul 2005 14:24:59 +0200 (CEST)
From: Stefan Sperling <stsp@stsp.in-berlin.de>
Reply-To: Stefan Sperling <stsp@stsp.in-berlin.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] teach eject to open devices specified with /dev/ prefix
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         83719
>Category:       ports
>Synopsis:       [patch] teach eject to open devices specified with /dev/ prefix
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pav
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 19 12:30:31 GMT 2005
>Closed-Date:    Tue Jul 19 20:48:41 GMT 2005
>Last-Modified:  Tue Jul 19 20:48:41 GMT 2005
>Originator:     Stefan Sperling
>Release:        FreeBSD 6.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD dice.seeling33.de 6.0-CURRENT FreeBSD 6.0-CURRENT #38: Sun Jul 17 19:10:40 CEST 2005 stsp@dice.seeling33.de:/usr/src/sys/i386/compile/DICE i386


	
>Description:
	The eject program currently only accepts devices specified with their
	plain name, e.g. acd0, instead of /dev/acd0. This is a minor nuisance
	for people coming from linux, since the linux eject accepts devices
	with their full path. It might also break applications that expect
	the eject program to accept a full path to the device file.
>How-To-Repeat:
	Try 'eject /dev/<device>'. It won't work.
	'eject <device>' in turn will work.
>Fix:
	Please put these two patches into /usr/ports/sysutiles/eject/files,
	and forward upstream if appropriate.
	The first patch obsoletes the file patch-eject.c that is currently
	applied to the port.

	patch-aa:

--- eject.c.orig	Tue Jul 19 13:43:37 2005
+++ eject.c	Tue Jul 19 14:14:24 2005
@@ -122,7 +122,7 @@
 }
 
 /*
- *  check device is exists.
+ *  check whether device exists.
  */
 
 int
@@ -133,8 +133,14 @@
     int sts;
     struct stat sb;
 
-    if (asprintf(device, "/dev/%sc", name) == -1)
-	return sts;
+    if (strncmp("/dev/", name, strlen("/dev/")) == 0) {
+	    if (asprintf(device, "%s", name) == -1)
+		return sts;
+    }
+    else { 
+	    if (asprintf(device, "/dev/%s", name) == -1)
+		return sts;
+    }
     if (vflag || nflag) {
 	printf("%s: using device %s\n", program, device);
     }
@@ -174,11 +180,16 @@
     /* get proper mount information into the list */
     len = strlen(name);
     for (n = 0; n < mnts; n++) {
-	p = rindex(mntbuf[n].f_mntfromname, '/');
-	if (p == NULL) {
-	    continue;
+	if (strncmp("/dev/", name, strlen("/dev/")) == 0) 
+		p = mntbuf[n].f_mntfromname;
+	else {
+		p = rindex(mntbuf[n].f_mntfromname, '/');
+		if (p == NULL)
+		    continue;
+		++p;
 	}
-	for (i = 0, ++p, q = name; *p != '\0' && *q != '\0'; ++i, ++p, ++q) {
+
+	for (i = 0, p, q = name; *p != '\0' && *q != '\0'; ++i, ++p, ++q) {
 	    if (*p != *q) {
 		break;
 	    }
	


	patch-ab:

--- eject.1.orig	Tue Jul 19 13:43:50 2005
+++ eject.1	Tue Jul 19 13:26:55 2005
@@ -39,7 +39,12 @@
 is a program to eject removable media from drive.
 The
 .Ar device
-is a removable drive name such as cd0, matcd0, mcd0, scd0, wcd0 or od0. 
+is a removable drive name such as cd0, matcd0, mcd0, scd0, wcd0 or od0.
+For compatiblity reasons, the string
+.Dq Li /dev/
+may optionally be prepended to
+.Ar device .
+
 .Nm eject
 unmounts the
 .Ar device
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: pav 
State-Changed-When: Tue Jul 19 19:39:36 GMT 2005 
State-Changed-Why:  
Asked maintainer for approval 


Responsible-Changed-From-To: freebsd-ports-bugs->pav 
Responsible-Changed-By: pav 
Responsible-Changed-When: Tue Jul 19 19:39:36 GMT 2005 
Responsible-Changed-Why:  
Track 

http://www.freebsd.org/cgi/query-pr.cgi?pr=83719 

From: Pav Lucistnik <pav@FreeBSD.org>
To: sylvioc@gmail.com, bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/83719: [patch] teach eject to open devices specified
	with /dev/ prefix
Date: Tue, 19 Jul 2005 21:39:34 +0200

 Dear maintainer of FreeBSD port sysutils/eject, please take a look at
 
 http://www.freebsd.org/cgi/query-pr.cgi?q=83719
 
 Do you approve this patch?
 
 -- 
 Pav Lucistnik <pav@oook.cz>
               <pav@FreeBSD.org>
 
 Define universe and tell me three examples.

From: Sylvio Cesar <sylvioc@gmail.com>
To: pav@freebsd.org
Cc: bug-followup@freebsd.org
Subject: Re: ports/83719: [patch] teach eject to open devices specified with /dev/ prefix
Date: Tue, 19 Jul 2005 16:50:27 -0300

 yes. It is correct.
 
 On 7/19/05, Pav Lucistnik <pav@freebsd.org> wrote:
 > Dear maintainer of FreeBSD port sysutils/eject, please take a look at
 >=20
 > http://www.freebsd.org/cgi/query-pr.cgi?q=3D83719
 >=20
 > Do you approve this patch?
 >=20
 > --
 > Pav Lucistnik <pav@oook.cz>
 >               <pav@FreeBSD.org>
 >=20
 > Define universe and tell me three examples.
 >
State-Changed-From-To: feedback->closed 
State-Changed-By: pav 
State-Changed-When: Tue Jul 19 20:48:34 GMT 2005 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=83719 
>Unformatted:
