ports/84321: Patch for eject device
Sylvio Cesar
sylvioc at gmail.com
Fri Jul 29 19:50:20 UTC 2005
>Number: 84321
>Category: ports
>Synopsis: Patch for eject device
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: maintainer-update
>Submitter-Id: current-users
>Arrival-Date: Fri Jul 29 19:50:14 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Sylvio Cesar
>Release: FreeBSD 6.0-BETA1 i386
>Organization:
>Environment:
System: FreeBSD sylvioc.sistel.com.br 6.0-BETA1 FreeBSD 6.0-BETA1 #4: Thu Jul 28 16:03:17 BRT
2005
>Description:
Added file(s):
- files/patch-eject.2
Removed file(s):
- files/patch-eject.c
>How-To-Repeat:
>Fix:
Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/sysutils/eject/Makefile,v
retrieving revision 1.10
diff -u -r1.10 Makefile
--- Makefile 19 Jul 2005 20:48:26 -0000 1.10
+++ Makefile 29 Jul 2005 19:33:53 -0000
@@ -7,7 +7,7 @@
PORTNAME= eject
PORTVERSION= 1.5
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= sysutils
MASTER_SITES= ftp://ports.jp.FreeBSD.org/pub/FreeBSD-jp/OD/ \
ftp://ftp4.jp.FreeBSD.org/pub/FreeBSD-jp/OD/ \
Index: files/patch-eject.2
===================================================================
RCS file: files/patch-eject.2
diff -N files/patch-eject.2
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ files/patch-eject.2 29 Jul 2005 19:33:53 -0000
@@ -0,0 +1,90 @@
+diff -u eject-1.5/eject.1 eject-1.5new/eject.1
+--- eject.1.orig Sun Sep 24 15:12:50 2000
++++ eject.1 Wed Jul 20 14:31:03 2005
+@@ -47,6 +47,8 @@
+ .Pp
+ The following options are available:
+ .Bl -tag -width Ds
++.It Fl c
++Close tray if supported.
+ .It Fl f
+ Force unmounts the device if it was mounted.
+ .It Fl n
+diff -u eject-1.5/eject.c eject-1.5new/eject.c
+--- eject.c.orig Wed Sep 6 15:40:12 2000
++++ eject.c Wed Jul 20 14:35:22 2005
+@@ -51,6 +51,7 @@
+
+ int fflag; /* force unmount filesystem */
+ int nflag; /* not execute operation */
++int cflag; /* close cdrom */
+ int vflag; /* verbose operation */
+
+ /*
+@@ -69,10 +70,10 @@
+ char *err;
+ char *defdev;
+
+- fflag = nflag = vflag = 0;
++ fflag = nflag = cflag = vflag = 0;
+ defdev = getenv("EJECT");
+
+- while ((ch = getopt(argc, argv, "fnv?")) != EOF) {
++ while ((ch = getopt(argc, argv, "cfnv?")) != EOF) {
+ switch (ch) {
+ case 'f' :
+ fflag = 1;
+@@ -83,6 +84,9 @@
+ case 'v' :
+ vflag = 1;
+ break;
++ case 'c' :
++ cflag = 1;
++ break;
+ case '?' :
+ default :
+ usage();
+@@ -133,7 +137,7 @@
+ int sts;
+ struct stat sb;
+
+- if (asprintf(device, "/dev/%sc", name) == -1)
++ if (asprintf(device, "/dev/%s", name) == -1)
+ return sts;
+ if (vflag || nflag) {
+ printf("%s: using device %s\n", program, device);
+@@ -256,14 +260,23 @@
+ }
+ if (!nflag) {
+ if (vflag) {
+- printf("%s: ejecting media from %s\n", program, name);
++ if (cflag == 0)
++ printf("%s: ejecting media from %s\n", program, name);
++ else
++ printf("%s: closing tray of %s\n", program, name);
+ }
+ sts = ioctl(fd, CDIOCALLOW);
+ if (sts >= 0) {
+- sts = ioctl(fd, CDIOCEJECT);
++ if (cflag == 0)
++ sts = ioctl(fd, CDIOCEJECT);
++ else
++ sts = ioctl(fd, CDIOCCLOSE);
+ }
+ } else {
+- printf("%s: ejecting media from %s\n", program, name);
++ if (cflag == 0)
++ printf("%s: ejecting media from %s\n", program, name);
++ else
++ printf("%s: closing tray of %s\n", program, name);
+ sts = 0;
+ }
+ close(fd);
+@@ -278,6 +291,6 @@
+ void
+ usage(void)
+ {
+- fprintf(stderr, "usage: %s [-fnv] device\n", program);
++ fprintf(stderr, "usage: %s [-cfnv] device\n", program);
+ exit(1);
+ }
Index: files/patch-eject.c
===================================================================
RCS file: files/patch-eject.c
diff -N files/patch-eject.c
--- files/patch-eject.c 19 Jul 2005 20:48:26 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,49 +0,0 @@
---- 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;
- }
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list