summaryrefslogtreecommitdiff
blob: fac0e60cb965efeabf8f8deace627ced470ca02b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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 <name> 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 */