ports/83719: [patch] teach eject to open devices specified with /dev/ prefix

Stefan Sperling stsp at stsp.in-berlin.de
Tue Jul 19 12:30:34 UTC 2005


>Number:         83719
>Category:       ports
>Synopsis:       [patch] teach eject to open devices specified with /dev/ prefix
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 19 12:30:31 GMT 2005
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:



More information about the freebsd-ports-bugs mailing list