1303 files changed, 32187 insertions, 57138 deletions
diff --git a/miscutils/eject.c b/miscutils/eject.c index a20e04b..667932f 100644 --- a/miscutils/eject.c +++ b/miscutils/eject.c @@ -12,6 +12,24 @@ * This is a simple hack of eject based on something Erik posted in #uclibc. * Most of the dirty work blatantly ripped off from cat.c =) */ +//config:config EJECT +//config: bool "eject" +//config: default y +//config: select PLATFORM_LINUX +//config: help +//config: Used to eject cdroms. (defaults to /dev/cdrom) +//config: +//config:config FEATURE_EJECT_SCSI +//config: bool "SCSI support" +//config: default y +//config: depends on EJECT +//config: help +//config: Add the -s option to eject, this allows to eject SCSI-Devices and +//config: usb-storage devices. + +//applet:IF_EJECT(APPLET(eject, BB_DIR_USR_BIN, BB_SUID_DROP)) + +//kbuild:lib-$(CONFIG_EJECT) += eject.o //usage:#define eject_trivial_usage //usage: "[-t] [-T] [DEVICE]" @@ -25,26 +43,22 @@ #include <sys/mount.h> #include "libbb.h" +#if ENABLE_FEATURE_EJECT_SCSI /* Must be after libbb.h: they need size_t */ -#include "fix_u32.h" -#include <scsi/sg.h> -#include <scsi/scsi.h> - -/* various defines swiped from linux/cdrom.h */ -#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */ -#define CDROMEJECT 0x5309 /* Ejects the cdrom media */ -#define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */ -/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */ -#define CDS_TRAY_OPEN 2 +# include "fix_u32.h" +# include <scsi/sg.h> +# include <scsi/scsi.h> +#endif #define dev_fd 3 /* Code taken from the original eject (http://eject.sourceforge.net/), * refactored it a bit for busybox (ne-bb@nicoerfurth.de) */ +#if ENABLE_FEATURE_EJECT_SCSI static void eject_scsi(const char *dev) { - static const char sg_commands[3][6] = { + static const char sg_commands[3][6] ALIGN1 = { { ALLOW_MEDIUM_REMOVAL, 0, 0, 0, 0, 0 }, { START_STOP, 0, 0, 0, 1, 0 }, { START_STOP, 0, 0, 0, 2, 0 } @@ -76,6 +90,16 @@ static void eject_scsi(const char *dev) /* force kernel to reread partition table when new disc is inserted */ ioctl(dev_fd, BLKRRPART); } +#else +# define eject_scsi(dev) ((void)0) +#endif + +/* various defines swiped from linux/cdrom.h */ +#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */ +#define CDROMEJECT 0x5309 /* Ejects the cdrom media */ +#define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */ +/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */ +#define CDS_TRAY_OPEN 2 #define FLAG_CLOSE 1 #define FLAG_SMART 2 |