X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=miscutils%2Feject.c;h=631a344a19f80a8472dcf46fbb5536114d6cdb30;hb=c2f011aa031b8598422953d5e9a93ca008ad0867;hp=b07f536b1dc1ea557746da7f04dbf2eb2d7d1c4d;hpb=000b9ba91f64a348d697fb22a546cfb4db1d9f0e;p=oweals%2Fbusybox.git diff --git a/miscutils/eject.c b/miscutils/eject.c index b07f536b1..631a344a1 100644 --- a/miscutils/eject.c +++ b/miscutils/eject.c @@ -13,8 +13,7 @@ * Most of the dirty work blatantly ripped off from cat.c =) */ -#include "busybox.h" -#include +#include "libbb.h" /* various defines swiped from linux/cdrom.h */ #define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */ @@ -26,27 +25,25 @@ #define FLAG_CLOSE 1 #define FLAG_SMART 2 +int eject_main(int argc, char **argv); int eject_main(int argc, char **argv) { unsigned long flags; - char *device; - struct mntent *m; + const char *device; int dev, cmd; opt_complementary = "?:?1:t--T:T--t"; flags = getopt32(argc, argv, "tT"); device = argv[optind] ? : "/dev/cdrom"; - // FIXME: what if something is mounted OVER our cdrom? - // We will unmount something else??! - // What if cdrom is mounted many times? - m = find_mount_point(device, bb_path_mtab_file); - if (m) { - if (umount(m->mnt_dir)) - bb_error_msg_and_die("can't umount %s", device); - if (ENABLE_FEATURE_MTAB_SUPPORT) - erase_mtab(m->mnt_fsname); - } + // We used to do "umount " here, but it was buggy + // if something was mounted OVER cdrom and + // if cdrom is mounted many times. + // + // This works equally well (or better): + // #!/bin/sh + // umount /dev/cdrom + // eject dev = xopen(device, O_RDONLY|O_NONBLOCK); cmd = CDROMEJECT;