eject: remove unmounting. It is buggy for many non-trivial

mounts, and can be done as shell script.
This commit is contained in:
Denis Vlasenko 2006-10-07 15:00:29 +00:00
parent 96e9d3c968
commit f7a57848c2

View File

@ -14,7 +14,6 @@
*/ */
#include "busybox.h" #include "busybox.h"
#include <mntent.h>
/* various defines swiped from linux/cdrom.h */ /* various defines swiped from linux/cdrom.h */
#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */ #define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
@ -30,23 +29,20 @@ int eject_main(int argc, char **argv)
{ {
unsigned long flags; unsigned long flags;
char *device; char *device;
struct mntent *m;
int dev, cmd; int dev, cmd;
opt_complementary = "?:?1:t--T:T--t"; opt_complementary = "?:?1:t--T:T--t";
flags = getopt32(argc, argv, "tT"); flags = getopt32(argc, argv, "tT");
device = argv[optind] ? : "/dev/cdrom"; device = argv[optind] ? : "/dev/cdrom";
// FIXME: what if something is mounted OVER our cdrom? // We used to do "umount <device>" here, but it was buggy
// We will unmount something else??! // if something was mounted OVER cdrom and
// What if cdrom is mounted many times? // if cdrom is mounted many times.
m = find_mount_point(device, bb_path_mtab_file); //
if (m) { // This works equally well (or better):
if (umount(m->mnt_dir)) // #!/bin/sh
bb_error_msg_and_die("can't umount %s", device); // umount /dev/cdrom
if (ENABLE_FEATURE_MTAB_SUPPORT) // eject
erase_mtab(m->mnt_fsname);
}
dev = xopen(device, O_RDONLY|O_NONBLOCK); dev = xopen(device, O_RDONLY|O_NONBLOCK);
cmd = CDROMEJECT; cmd = CDROMEJECT;