aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-05-11 00:25:47 +0000
committerMike Frysinger <vapier@gentoo.org>2005-05-11 00:25:47 +0000
commit55e2cf6533582ba0e795176103df0df22436b230 (patch)
tree861e274991d9290735776b7f38b6b18861da1598
parentfb6d22c96c1147014294b30c97e7b912db36bfed (diff)
downloadbusybox-w32-55e2cf6533582ba0e795176103df0df22436b230.tar.gz
busybox-w32-55e2cf6533582ba0e795176103df0df22436b230.tar.bz2
busybox-w32-55e2cf6533582ba0e795176103df0df22436b230.zip
import eject by Peter Willis / Tito Ragusa
-rw-r--r--AUTHORS6
-rw-r--r--include/applets.h3
-rw-r--r--include/usage.h13
-rw-r--r--miscutils/Config.in13
-rw-r--r--miscutils/Makefile.in27
-rw-r--r--miscutils/eject.c64
-rw-r--r--patches/eject.diff164
7 files changed, 112 insertions, 178 deletions
diff --git a/AUTHORS b/AUTHORS
index ebf57b619..67015627c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -8,6 +8,9 @@ incorrect, _please_ let me know.
8 8
9----------- 9-----------
10 10
11Peter Willis <psyphreak@phreaker.net>
12 eject
13
11Emanuele Aina <emanuele.aina@tiscali.it> 14Emanuele Aina <emanuele.aina@tiscali.it>
12 run-parts 15 run-parts
13 16
@@ -139,5 +142,6 @@ Enrique Zanardi <ezanardi@ull.es>
139 tarcat (since removed), loadkmap, various fixes, Debian maintenance 142 tarcat (since removed), loadkmap, various fixes, Debian maintenance
140 143
141Tito Ragusa <farmatito@tiscali.it> 144Tito Ragusa <farmatito@tiscali.it>
142 devfsd and size optimizations in strings, openvt, chvt, deallocvt, hdparm and fdformat. 145 devfsd and size optimizations in strings, openvt, chvt, deallocvt, hdparm,
146 fdformat, lsattr, chattr, id and eject.
143 147
diff --git a/include/applets.h b/include/applets.h
index 7f6f75864..3f411c269 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -182,6 +182,9 @@
182#if defined(CONFIG_FEATURE_GREP_EGREP_ALIAS) 182#if defined(CONFIG_FEATURE_GREP_EGREP_ALIAS)
183 APPLET_NOUSAGE("egrep", grep_main, _BB_DIR_BIN, _BB_SUID_NEVER) 183 APPLET_NOUSAGE("egrep", grep_main, _BB_DIR_BIN, _BB_SUID_NEVER)
184#endif 184#endif
185#ifdef CONFIG_EJECT
186 APPLET(eject, eject_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
187#endif
185#ifdef CONFIG_ENV 188#ifdef CONFIG_ENV
186 APPLET(env, env_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) 189 APPLET(env, env_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
187#endif 190#endif
diff --git a/include/usage.h b/include/usage.h
index 1ef79df61..316772ea2 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -556,6 +556,19 @@
556 "$ echo \"Erik\\nis\\ncool\"\n" \ 556 "$ echo \"Erik\\nis\\ncool\"\n" \
557 "Erik\\nis\\ncool\n") 557 "Erik\\nis\\ncool\n")
558 558
559#ifdef CONFIG_FEATURE_EJECT_LONG_OPTIONS
560# define USAGE_EJECT_TRAYCLOSE ",trayclose"
561#else
562# define USAGE_EJECT_TRAYCLOSE ""
563#endif
564
565#define eject_trivial_usage \
566 "[-t] [DEVICE]"
567#define eject_full_usage \
568 "Eject specified DEVICE (or default /dev/cdrom).\n\n" \
569 "Options:\n" \
570 "\tt" USAGE_EJECT_TRAYCLOSE "\tclose tray"
571
559#define env_trivial_usage \ 572#define env_trivial_usage \
560 "[-iu] [-] [name=value]... [command]" 573 "[-iu] [-] [name=value]... [command]"
561#define env_full_usage \ 574#define env_full_usage \
diff --git a/miscutils/Config.in b/miscutils/Config.in
index 77e13e84e..710639aba 100644
--- a/miscutils/Config.in
+++ b/miscutils/Config.in
@@ -83,6 +83,19 @@ config CONFIG_DEVFSD_VERBOSE
83 help 83 help
84 Increases logging to stderr or syslog. 84 Increases logging to stderr or syslog.
85 85
86config CONFIG_EJECT
87 bool "eject"
88 default n
89 help
90 Used to eject cdroms. (defaults to /dev/cdrom)
91
92config CONFIG_FEATURE_EJECT_LONG_OPTIONS
93 bool " Enable support for --trayclose long option (-t)"
94 default n
95 depends on CONFIG_EJECT
96 help
97 Enable use of long options (like --trayclose for -t).
98
86config CONFIG_LAST 99config CONFIG_LAST
87 bool "last" 100 bool "last"
88 default n 101 default n
diff --git a/miscutils/Makefile.in b/miscutils/Makefile.in
index ddddf72b3..d714f4038 100644
--- a/miscutils/Makefile.in
+++ b/miscutils/Makefile.in
@@ -24,19 +24,20 @@ endif
24srcdir=$(top_srcdir)/miscutils 24srcdir=$(top_srcdir)/miscutils
25 25
26MISCUTILS-y:= 26MISCUTILS-y:=
27MISCUTILS-$(CONFIG_ADJTIMEX) += adjtimex.o 27MISCUTILS-$(CONFIG_ADJTIMEX) += adjtimex.o
28MISCUTILS-$(CONFIG_CROND) += crond.o 28MISCUTILS-$(CONFIG_CROND) += crond.o
29MISCUTILS-$(CONFIG_CRONTAB) += crontab.o 29MISCUTILS-$(CONFIG_CRONTAB) += crontab.o
30MISCUTILS-$(CONFIG_DC) += dc.o 30MISCUTILS-$(CONFIG_DC) += dc.o
31MISCUTILS-$(CONFIG_DEVFSD) += devfsd.o 31MISCUTILS-$(CONFIG_DEVFSD) += devfsd.o
32MISCUTILS-$(CONFIG_HDPARM) += hdparm.o 32MISCUTILS-$(CONFIG_EJECT) += eject.o
33MISCUTILS-$(CONFIG_LAST) += last.o 33MISCUTILS-$(CONFIG_HDPARM) += hdparm.o
34MISCUTILS-$(CONFIG_MAKEDEVS) += makedevs.o 34MISCUTILS-$(CONFIG_LAST) += last.o
35MISCUTILS-$(CONFIG_MT) += mt.o 35MISCUTILS-$(CONFIG_MAKEDEVS) += makedevs.o
36MISCUTILS-$(CONFIG_RX) += rx.o 36MISCUTILS-$(CONFIG_MT) += mt.o
37MISCUTILS-$(CONFIG_STRINGS) += strings.o 37MISCUTILS-$(CONFIG_RX) += rx.o
38MISCUTILS-$(CONFIG_TIME) += time.o 38MISCUTILS-$(CONFIG_STRINGS) += strings.o
39MISCUTILS-$(CONFIG_WATCHDOG) += watchdog.o 39MISCUTILS-$(CONFIG_TIME) += time.o
40MISCUTILS-$(CONFIG_WATCHDOG) += watchdog.o
40 41
41libraries-y+=$(MISCUTILS_DIR)$(MISCUTILS_AR) 42libraries-y+=$(MISCUTILS_DIR)$(MISCUTILS_AR)
42 43
diff --git a/miscutils/eject.c b/miscutils/eject.c
new file mode 100644
index 000000000..cbfd115f7
--- /dev/null
+++ b/miscutils/eject.c
@@ -0,0 +1,64 @@
1/*
2 * eject implementation for busybox
3 *
4 * Copyright (C) 2004 Peter Willis <psyphreak@phreaker.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22/*
23 * This is a simple hack of eject based on something Erik posted in #uclibc.
24 * Most of the dirty work blatantly ripped off from cat.c =)
25 */
26
27#include <stdio.h>
28#include <string.h>
29#include <sys/types.h>
30#include <sys/stat.h>
31#include <fcntl.h>
32#include <sys/ioctl.h>
33#include <getopt.h>
34#include "busybox.h"
35
36/* various defines swiped from linux/cdrom.h */
37#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
38#define CDROMEJECT 0x5309 /* Ejects the cdrom media */
39#define DEFAULT_CDROM "/dev/cdrom"
40/*#define CLOSE_TRAY 1*/
41
42extern int eject_main(int argc, char **argv)
43{
44 unsigned long flags;
45
46#ifdef CONFIG_FEATURE_EJECT_LONG_OPTIONS
47 static const struct option eject_long_options[] = {
48 { "trayclose", 0, 0, 't' },
49 { 0, 0, 0, 0 }
50 };
51 bb_applet_long_options = eject_long_options;
52#endif
53
54 flags = bb_getopt_ulflags(argc, argv, "t");
55
56 if (ioctl(bb_xopen((argv[optind] ? argv[optind] : DEFAULT_CDROM),
57 (O_RDONLY | O_NONBLOCK)),
58 ( flags /*& CLOSE_TRAY*/ ? CDROMCLOSETRAY : CDROMEJECT)))
59 {
60 bb_perror_msg_and_die(bb_msg_unknown);
61 }
62
63 return EXIT_SUCCESS;
64}
diff --git a/patches/eject.diff b/patches/eject.diff
deleted file mode 100644
index 197b8cd02..000000000
--- a/patches/eject.diff
+++ /dev/null
@@ -1,164 +0,0 @@
1Index: AUTHORS
2===================================================================
3RCS file: /var/cvs/busybox/AUTHORS,v
4retrieving revision 1.40
5diff -u -r1.40 AUTHORS
6--- a/AUTHORS 9 Oct 2003 21:19:21 -0000 1.40
7+++ b/AUTHORS 5 Mar 2004 07:23:17 -0000
8@@ -8,6 +8,9 @@
9
10 -----------
11
12+Peter Willis <psyphreak@phreaker.net>
13+ eject
14+
15 Emanuele Aina <emanuele.aina@tiscali.it>
16 run-parts
17
18Index: coreutils/Config.in
19===================================================================
20RCS file: /var/cvs/busybox/coreutils/Config.in,v
21retrieving revision 1.23
22diff -u -r1.23 Config.in
23--- a/coreutils/Config.in 5 Mar 2004 06:47:25 -0000 1.23
24+++ b/coreutils/Config.in 5 Mar 2004 07:23:18 -0000
25@@ -164,6 +164,13 @@
26 a command; without options it displays the current
27 environment.
28
29+config CONFIG_EJECT
30+ bool "eject"
31+ default n
32+ help
33+ ejects a cdrom drive.
34+ defaults to /dev/cdrom
35+
36 config CONFIG_EXPR
37 bool "expr"
38 default n
39Index: coreutils/Makefile.in
40===================================================================
41RCS file: /var/cvs/busybox/coreutils/Makefile.in,v
42retrieving revision 1.8
43diff -u -r1.8 Makefile.in
44--- a/coreutils/Makefile.in 27 Jan 2004 09:22:20 -0000 1.8
45+++ b/coreutils/Makefile.in 5 Mar 2004 07:23:18 -0000
46@@ -41,6 +41,7 @@
47 COREUTILS-$(CONFIG_DU) += du.o
48 COREUTILS-$(CONFIG_ECHO) += echo.o
49 COREUTILS-$(CONFIG_ENV) += env.o
50+COREUTILS-$(CONFIG_EJECT) += eject.o
51 COREUTILS-$(CONFIG_EXPR) += expr.o
52 COREUTILS-$(CONFIG_FALSE) += false.o
53 COREUTILS-$(CONFIG_FOLD) += fold.o
54Index: coreutils/eject.c
55===================================================================
56RCS file: coreutils/eject.c
57diff -N coreutils/eject.c
58--- /dev/null 1 Jan 1970 00:00:00 -0000
59+++ b/coreutils/eject.c 5 Mar 2004 07:23:21 -0000
60@@ -0,0 +1,66 @@
61+/*
62+ * eject implementation for busybox
63+ *
64+ * Copyright (C) 2004 Peter Willis <psyphreak@phreaker.net>
65+ *
66+ * This program is free software; you can redistribute it and/or modify
67+ * it under the terms of the GNU General Public License as published by
68+ * the Free Software Foundation; either version 2 of the License, or
69+ * (at your option) any later version.
70+ *
71+ * This program is distributed in the hope that it will be useful,
72+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
73+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74+ * General Public License for more details.
75+ *
76+ * You should have received a copy of the GNU General Public License
77+ * along with this program; if not, write to the Free Software
78+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
79+ *
80+ */
81+
82+/*
83+ * This is a simple hack of eject based on something Erik posted in #uclibc.
84+ * Most of the dirty work blatantly ripped off from cat.c =)
85+ */
86+
87+#include <stdio.h>
88+#include <string.h>
89+#include <sys/types.h>
90+#include <sys/stat.h>
91+#include <fcntl.h>
92+#include <sys/ioctl.h>
93+#include "busybox.h"
94+#include <linux/cdrom.h> // needs to be after busybox.h or compile problems arise
95+
96+#define DEFAULT_CDROM "/dev/cdrom"
97+
98+extern int eject_main(int argc, char **argv)
99+{
100+ int fd;
101+ int flag = CDROMEJECT;
102+ int i = 1;
103+ char *device = NULL;
104+
105+ /*
106+ * i'm too lazy to learn bb_getopt_ulflags and this is obscenely large
107+ * for just some argument parsing so mjn3 can clean it up later.
108+ * sorry, but PlumpOS 7.0-pre2 needs this asap :-/
109+ */
110+ while (++i <= argc) {
111+ if ( (! strncmp(argv[i-1],"-t",2)) || (! strncmp(argv[i-1],"--trayclose",11)) ) {
112+ flag = CDROMCLOSETRAY;
113+ } else {
114+ device = argv[i-1];
115+ }
116+ }
117+ if ( (fd = open(device == NULL ? DEFAULT_CDROM : device, O_RDONLY | O_NONBLOCK) ) < 0 ) {
118+ perror("eject: Can't open device");
119+ return(EXIT_FAILURE);
120+ }
121+ if (ioctl(fd, flag)) {
122+ perror("eject: Can't eject cdrom");
123+ return(EXIT_FAILURE);
124+ }
125+ return EXIT_SUCCESS;
126+}
127Index: include/applets.h
128===================================================================
129RCS file: /var/cvs/busybox/include/applets.h,v
130retrieving revision 1.111
131diff -u -r1.111 applets.h
132--- a/include/applets.h 27 Jan 2004 09:22:20 -0000 1.111
133+++ b/include/applets.h 5 Mar 2004 07:23:21 -0000
134@@ -178,6 +178,9 @@
135 #if defined(CONFIG_FEATURE_GREP_EGREP_ALIAS)
136 APPLET_NOUSAGE("egrep", grep_main, _BB_DIR_BIN, _BB_SUID_NEVER)
137 #endif
138+#ifdef CONFIG_EJECT
139+ APPLET(eject, eject_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
140+#endif
141 #ifdef CONFIG_ENV
142 APPLET(env, env_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
143 #endif
144Index: include/usage.h
145===================================================================
146RCS file: /var/cvs/busybox/include/usage.h,v
147retrieving revision 1.191
148diff -u -r1.191 usage.h
149--- a/include/usage.h 25 Feb 2004 10:35:55 -0000 1.191
150+++ b/include/usage.h 5 Mar 2004 07:23:29 -0000
151@@ -537,6 +537,13 @@
152 "\t-, -i\tstart with an empty environment\n" \
153 "\t-u\tremove variable from the environment\n"
154
155+#define eject_trivial_usage \
156+ "[-t] [FILE]"
157+#define eject_full_usage \
158+ "Ejects the specified FILE or /dev/cdrom if FILE is unspecified.\n\n" \
159+ "Options:\n" \
160+ "\t-t, --trayclose\tclose tray\n"
161+
162 #define expr_trivial_usage \
163 "EXPRESSION"
164 #define expr_full_usage \