Add a no unmount option to eject. http://bugs.gentoo.org/91977 --- eject.1 +++ eject.1 @@ -123,6 +123,13 @@ also passes the -n option to umount(1). .TP 0.5i +.B \-m +This option allows eject to work with device drivers which automatically +mount removable media and therefore must be always mount()ed. +The option tells eject to not try to unmount the given device, +even if it is mounted according to /etc/mtab or /proc/mounts. + +.TP 0.5i .B -V This option causes .B eject --- eject.c +++ eject.c @@ -84,6 +84,7 @@ int v_option = 0; int x_option = 0; int p_option = 0; +int m_option = 0; int a_arg = 0; int c_arg = 0; int x_arg = 0; @@ -128,7 +129,9 @@ " -s\t-- eject SCSI device\n" " -f\t-- eject floppy\n" " -q\t-- eject tape\n" -" -p\t-- use /proc/mounts instead of /etc/mtab\n") +" -p\t-- use /proc/mounts instead of /etc/mtab\n" +" -m\t-- do not unmount device even if it is mounted\n" +) , version); #ifdef GETOPTLONG fprintf(stderr,_( @@ -137,7 +140,7 @@ " -a --auto -c --changerslot -t --trayclose -x --cdspeed\n" " -r --cdrom -s --scsi -f --floppy\n" " -q --tape -n --noop -V --version\n" -" -p --proc\n")); +" -p --proc -m --no-unmount\n")); #endif /* GETOPTLONG */ fprintf(stderr,_( "Parameter can be a device file or a mount point.\n" @@ -151,7 +154,7 @@ /* Handle command line options. */ static void parse_args(int argc, char **argv, char **device) { - const char *flags = "a:c:x:dfhnqrstvVp"; + const char *flags = "a:c:x:dfhnqrstvVpm"; #ifdef GETOPTLONG static struct option long_options[] = { @@ -169,6 +172,7 @@ {"tape", no_argument, NULL, 'q'}, {"version", no_argument, NULL, 'V'}, {"proc", no_argument, NULL, 'p'}, + {"no-unmount", no_argument, NULL, 'm'}, {0, 0, 0, 0} }; int option_index; @@ -231,6 +235,9 @@ usage(); exit(0); break; + case 'm': + m_option = 1; + break; case 'n': n_option = 1; break; @@ -933,7 +940,7 @@ if (!c_option) HandleXOption(deviceName); /* unmount device if mounted */ - if (mounted) { + if ((m_option != 1) && mounted) { if (v_option) printf(_("%s: unmounting `%s'\n"), programName, deviceName); Unmount(deviceName); @@ -942,7 +949,7 @@ /* if it is a multipartition device, unmount any other partitions on the device */ pattern = MultiplePartitions(deviceName); - if (pattern != 0) + if ((m_option != 1) && (pattern != 0)) UnmountDevices(pattern); /* handle -c option */