|
|
int v_option = 0; | int v_option = 0; |
int x_option = 0; | int x_option = 0; |
int p_option = 0; | int p_option = 0; |
|
int m_option = 0; |
int a_arg = 0; | int a_arg = 0; |
int c_arg = 0; | int c_arg = 0; |
int x_arg = 0; | int x_arg = 0; |
|
|
" -s\t-- eject SCSI device\n" | " -s\t-- eject SCSI device\n" |
" -f\t-- eject floppy\n" | " -f\t-- eject floppy\n" |
" -q\t-- eject tape\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); | , version); |
#ifdef GETOPTLONG | #ifdef GETOPTLONG |
fprintf(stderr,_( | fprintf(stderr,_( |
|
|
" -a --auto -c --changerslot -t --trayclose -x --cdspeed\n" | " -a --auto -c --changerslot -t --trayclose -x --cdspeed\n" |
" -r --cdrom -s --scsi -f --floppy\n" | " -r --cdrom -s --scsi -f --floppy\n" |
" -q --tape -n --noop -V --version\n" | " -q --tape -n --noop -V --version\n" |
" -p --proc\n")); |
" -p --proc -m --no-unmount\n")); |
#endif /* GETOPTLONG */ | #endif /* GETOPTLONG */ |
fprintf(stderr,_( | fprintf(stderr,_( |
"Parameter <name> can be a device file or a mount point.\n" | "Parameter <name> can be a device file or a mount point.\n" |
|
|
/* Handle command line options. */ | /* Handle command line options. */ |
static void parse_args(int argc, char **argv, char **device) | 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 | #ifdef GETOPTLONG |
static struct option long_options[] = | static struct option long_options[] = |
{ | { |
|
|
{"tape", no_argument, NULL, 'q'}, | {"tape", no_argument, NULL, 'q'}, |
{"version", no_argument, NULL, 'V'}, | {"version", no_argument, NULL, 'V'}, |
{"proc", no_argument, NULL, 'p'}, | {"proc", no_argument, NULL, 'p'}, |
|
{"no-unmount", no_argument, NULL, 'm'}, |
{0, 0, 0, 0} | {0, 0, 0, 0} |
}; | }; |
int option_index; | int option_index; |
|
|
usage(); | usage(); |
exit(0); | exit(0); |
break; | break; |
|
case 'm': |
|
m_option = 1; |
|
break; |
case 'n': | case 'n': |
n_option = 1; | n_option = 1; |
break; | break; |
|
|
if (!c_option) HandleXOption(deviceName); | if (!c_option) HandleXOption(deviceName); |
| |
/* unmount device if mounted */ | /* unmount device if mounted */ |
if (mounted) { |
if ((m_option != 1) && mounted) { |
if (v_option) | if (v_option) |
printf(_("%s: unmounting `%s'\n"), programName, deviceName); | printf(_("%s: unmounting `%s'\n"), programName, deviceName); |
Unmount(deviceName); | Unmount(deviceName); |
|
|
/* if it is a multipartition device, unmount any other partitions on | /* if it is a multipartition device, unmount any other partitions on |
the device */ | the device */ |
pattern = MultiplePartitions(deviceName); | pattern = MultiplePartitions(deviceName); |
if (pattern != 0) |
if ((m_option != 1) && (pattern != 0)) |
UnmountDevices(pattern); | UnmountDevices(pattern); |
| |
/* handle -c option */ | /* handle -c option */ |