diff options
| author | Mike Frysinger <vapier@gentoo.org> | 2005-05-11 00:25:47 +0000 |
|---|---|---|
| committer | Mike Frysinger <vapier@gentoo.org> | 2005-05-11 00:25:47 +0000 |
| commit | 55e2cf6533582ba0e795176103df0df22436b230 (patch) | |
| tree | 861e274991d9290735776b7f38b6b18861da1598 /miscutils | |
| parent | fb6d22c96c1147014294b30c97e7b912db36bfed (diff) | |
| download | busybox-w32-55e2cf6533582ba0e795176103df0df22436b230.tar.gz busybox-w32-55e2cf6533582ba0e795176103df0df22436b230.tar.bz2 busybox-w32-55e2cf6533582ba0e795176103df0df22436b230.zip | |
import eject by Peter Willis / Tito Ragusa
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/Config.in | 13 | ||||
| -rw-r--r-- | miscutils/Makefile.in | 27 | ||||
| -rw-r--r-- | miscutils/eject.c | 64 |
3 files changed, 91 insertions, 13 deletions
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 | ||
| 86 | config CONFIG_EJECT | ||
| 87 | bool "eject" | ||
| 88 | default n | ||
| 89 | help | ||
| 90 | Used to eject cdroms. (defaults to /dev/cdrom) | ||
| 91 | |||
| 92 | config 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 | |||
| 86 | config CONFIG_LAST | 99 | config 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 | |||
| 24 | srcdir=$(top_srcdir)/miscutils | 24 | srcdir=$(top_srcdir)/miscutils |
| 25 | 25 | ||
| 26 | MISCUTILS-y:= | 26 | MISCUTILS-y:= |
| 27 | MISCUTILS-$(CONFIG_ADJTIMEX) += adjtimex.o | 27 | MISCUTILS-$(CONFIG_ADJTIMEX) += adjtimex.o |
| 28 | MISCUTILS-$(CONFIG_CROND) += crond.o | 28 | MISCUTILS-$(CONFIG_CROND) += crond.o |
| 29 | MISCUTILS-$(CONFIG_CRONTAB) += crontab.o | 29 | MISCUTILS-$(CONFIG_CRONTAB) += crontab.o |
| 30 | MISCUTILS-$(CONFIG_DC) += dc.o | 30 | MISCUTILS-$(CONFIG_DC) += dc.o |
| 31 | MISCUTILS-$(CONFIG_DEVFSD) += devfsd.o | 31 | MISCUTILS-$(CONFIG_DEVFSD) += devfsd.o |
| 32 | MISCUTILS-$(CONFIG_HDPARM) += hdparm.o | 32 | MISCUTILS-$(CONFIG_EJECT) += eject.o |
| 33 | MISCUTILS-$(CONFIG_LAST) += last.o | 33 | MISCUTILS-$(CONFIG_HDPARM) += hdparm.o |
| 34 | MISCUTILS-$(CONFIG_MAKEDEVS) += makedevs.o | 34 | MISCUTILS-$(CONFIG_LAST) += last.o |
| 35 | MISCUTILS-$(CONFIG_MT) += mt.o | 35 | MISCUTILS-$(CONFIG_MAKEDEVS) += makedevs.o |
| 36 | MISCUTILS-$(CONFIG_RX) += rx.o | 36 | MISCUTILS-$(CONFIG_MT) += mt.o |
| 37 | MISCUTILS-$(CONFIG_STRINGS) += strings.o | 37 | MISCUTILS-$(CONFIG_RX) += rx.o |
| 38 | MISCUTILS-$(CONFIG_TIME) += time.o | 38 | MISCUTILS-$(CONFIG_STRINGS) += strings.o |
| 39 | MISCUTILS-$(CONFIG_WATCHDOG) += watchdog.o | 39 | MISCUTILS-$(CONFIG_TIME) += time.o |
| 40 | MISCUTILS-$(CONFIG_WATCHDOG) += watchdog.o | ||
| 40 | 41 | ||
| 41 | libraries-y+=$(MISCUTILS_DIR)$(MISCUTILS_AR) | 42 | libraries-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 | |||
| 42 | extern 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 | } | ||
