aboutsummaryrefslogtreecommitdiff
path: root/sysutils/eject
diff options
context:
space:
mode:
authorSylvio Cesar Teixeira <sylvio@FreeBSD.org>2010-03-31 01:11:31 +0000
committerSylvio Cesar Teixeira <sylvio@FreeBSD.org>2010-03-31 01:11:31 +0000
commit2870be019a6d79943d44a462b9d504d4277f8a35 (patch)
treef5fb30277ff9e753c7cd4f3ea85739f0cf128d96 /sysutils/eject
parentaa18e32d9a8e7550d5a4acd8e46e03ae8a69ac54 (diff)
downloadports-2870be019a6d79943d44a462b9d504d4277f8a35.tar.gz
ports-2870be019a6d79943d44a462b9d504d4277f8a35.zip
Notes
Diffstat (limited to 'sysutils/eject')
-rw-r--r--sysutils/eject/Makefile5
-rw-r--r--sysutils/eject/files/patch-Makefile11
-rw-r--r--sysutils/eject/files/patch-eject.113
-rw-r--r--sysutils/eject/files/patch-eject.c182
4 files changed, 159 insertions, 52 deletions
diff --git a/sysutils/eject/Makefile b/sysutils/eject/Makefile
index 107fa60ecef8..ab69fbb74b60 100644
--- a/sysutils/eject/Makefile
+++ b/sysutils/eject/Makefile
@@ -7,7 +7,7 @@
PORTNAME= eject
PORTVERSION= 1.5
-PORTREVISION= 3
+PORTREVISION= 4
CATEGORIES= sysutils
MASTER_SITES= ftp://ports.jp.FreeBSD.org/pub/FreeBSD-jp/OD/ \
ftp://ftp4.jp.FreeBSD.org/pub/FreeBSD-jp/OD/ \
@@ -22,6 +22,9 @@ PORTDOCS= README README-J
MAN1= eject.1
MANCOMPRESSED= yes
+post-patch:
+ ${REINPLACE_CMD} -e 's,4555,555,' ${WRKSRC}/Makefile
+
post-install:
.if !defined(NOPORTDOCS)
${MKDIR} ${DOCSDIR}
diff --git a/sysutils/eject/files/patch-Makefile b/sysutils/eject/files/patch-Makefile
deleted file mode 100644
index 2d271c850b9e..000000000000
--- a/sysutils/eject/files/patch-Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
---- Makefile.orig 2007-08-04 13:17:07.000000000 +0400
-+++ Makefile 2007-08-04 13:17:14.000000000 +0400
-@@ -5,7 +5,7 @@
- PROG= eject
-
- BINOWN= root
--BINMODE= 4555
-+BINMODE= 555
- BINDIR= ${PREFIX}/sbin
-
- MANDIR= ${PREFIX}/man/man
diff --git a/sysutils/eject/files/patch-eject.1 b/sysutils/eject/files/patch-eject.1
index 6f633fa6eca9..08379a9bafde 100644
--- a/sysutils/eject/files/patch-eject.1
+++ b/sysutils/eject/files/patch-eject.1
@@ -1,5 +1,5 @@
---- eject.1.orig Tue Jul 19 13:43:50 2005
-+++ eject.1 Tue Jul 19 13:26:55 2005
+--- eject.1.orig 2000-09-24 10:12:50.000000000 -0300
++++ eject.1 2010-03-19 23:02:03.000000000 -0300
@@ -39,7 +39,12 @@
is a program to eject removable media from drive.
The
@@ -14,3 +14,12 @@
.Nm eject
unmounts the
.Ar device
+@@ -53,6 +58,8 @@
+ Not execute operation but print it.
+ .It Fl v
+ Verbose mode.
++.It Fl t
++Give drive tray close command.
+ .Sh ENVIRONMENT
+ If the following environment variable exists, it is used by
+ .Nm eject :
diff --git a/sysutils/eject/files/patch-eject.c b/sysutils/eject/files/patch-eject.c
index 18990fe3a9e4..8b593134e9b1 100644
--- a/sysutils/eject/files/patch-eject.c
+++ b/sysutils/eject/files/patch-eject.c
@@ -1,49 +1,155 @@
---- eject.c.orig Tue Jul 19 13:43:37 2005
-+++ eject.c Tue Jul 19 14:14:24 2005
-@@ -122,7 +122,7 @@
- }
+--- eject.c.orig 2010-03-19 23:03:17.000000000 -0300
++++ eject.c 2010-03-19 23:03:25.000000000 -0300
+@@ -52,6 +52,7 @@
+ int fflag; /* force unmount filesystem */
+ int nflag; /* not execute operation */
+ int vflag; /* verbose operation */
++int tflag; /* close tray */
/*
-- * check device is exists.
-+ * check whether device exists.
- */
+ * simple eject program
+@@ -69,10 +70,10 @@
+ char *err;
+ char *defdev;
- int
-@@ -133,8 +133,14 @@
- int sts;
- struct stat sb;
+- fflag = nflag = vflag = 0;
++ fflag = nflag = vflag = tflag = 0;
+ defdev = getenv("EJECT");
+
+- while ((ch = getopt(argc, argv, "fnv?")) != EOF) {
++ while ((ch = getopt(argc, argv, "fnvt?")) != EOF) {
+ switch (ch) {
+ case 'f' :
+ fflag = 1;
+@@ -83,6 +84,9 @@
+ case 'v' :
+ vflag = 1;
+ break;
++ case 't' :
++ tflag = 1;
++ break;
+ case '?' :
+ default :
+ usage();
+@@ -104,6 +108,39 @@
+ if (sts < 0) {
+ perror(program);
+ exit(1);
++ } else {
++ int c;
++ free(name);
++ char *dev_bak = malloc(MAXPATHLEN);
++ if ((c = readlink(device, dev_bak, MAXPATHLEN))>0) {
++ dev_bak[c] = '\0';
++ name = dev_bak;
++ } else {
++ free(dev_bak);
++ name = device;
++ }
++ if (strncmp(device, "/dev/", 5) != 0)
++ {
++ int mnts;
++ struct statfs *mntbuf;
++ mnts = getmntinfo(&mntbuf, MNT_NOWAIT);
++ if (mnts == 0) {
++ perror(program);
++ exit(1);
++ }
++ for (ch = 0; ch < mnts; ch++) {
++ if (strcmp(mntbuf[ch].f_mntonname, name) == 0) {
++ device = strdup(mntbuf[ch].f_mntfromname);
++ name = strdup(mntbuf[ch].f_mntfromname);
++ break;
++ }
++ }
++ if (strncmp(device, "/dev/", 5) != 0)
++ {
++ perror(program);
++ exit(1);
++ }
++ }
+ }
+ sts = unmount_fs(name, &err);
+@@ -130,16 +167,24 @@
+ char *name;
+ char **device;
+ {
+- int sts;
++ int sts = 0, i;
+ 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 @@
+- if (vflag || nflag) {
+- printf("%s: using device %s\n", program, device);
+- }
+- sts = stat(*device, &sb);
+-
++ const char* dev_list[] = { "/dev/%sc", "/dev/%s", "%s" };
++ for (i = 0; i < 3; i++) {
++ if ((sts = asprintf(device, dev_list[i], name)) == -1)
++ return sts;
++ if (vflag || nflag) {
++ printf("%s: trying device %s\n", program, *device);
++ }
++ sts = stat(*device, &sb);
++ if (sts) { /* stat failed, try next */
++ free(*device);
++ continue;
++ } else {
++ break;
++ }
++ }
++
+ return sts;
+ }
+
+@@ -174,7 +219,7 @@
/* 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;
++ p = mntbuf[n].f_mntfromname - 1;
+ if (p == NULL) {
+ continue;
+ }
+@@ -256,14 +301,26 @@
+ }
+ if (!nflag) {
+ if (vflag) {
+- printf("%s: ejecting media from %s\n", program, name);
++ if (tflag) {
++ printf("%s: track close on %s\n", program, name);
++ } else {
++ printf("%s: ejecting media from %s\n", program, name);
++ }
}
-- 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;
- }
+ sts = ioctl(fd, CDIOCALLOW);
+ if (sts >= 0) {
+- sts = ioctl(fd, CDIOCEJECT);
++ if (tflag) {
++ sts = ioctl(fd, CDIOCCLOSE);
++ } else {
++ sts = ioctl(fd, CDIOCEJECT);
++ }
+ }
+- } else {
+- printf("%s: ejecting media from %s\n", program, name);
++ } else {
++ if (tflag) {
++ printf("%s: track close on %s\n", program, name);
++ } else {
++ printf("%s: ejecting media from %s\n", program, name);
++ }
+ sts = 0;
+ }
+ close(fd);
+@@ -278,6 +335,6 @@
+ void
+ usage(void)
+ {
+- fprintf(stderr, "usage: %s [-fnv] device\n", program);
++ fprintf(stderr, "usage: %s [-fnvt] device\n", program);
+ exit(1);
+ }