]>
Commit | Line | Data |
---|---|---|
2292dd30 JR |
1 | --- util-linux-2.12p/mount/mount.c.ocfs2 2005-07-12 16:31:16.000000000 +0200 |
2 | +++ util-linux-2.12p/mount/mount.c 2005-07-12 16:31:46.000000000 +0200 | |
3 | @@ -466,6 +466,61 @@ | |
4 | } | |
5 | ||
6 | /* | |
7 | + * check_special_mountprog() | |
8 | + * If there is a special mount program for this type, exec it. | |
9 | + * returns: 0: no exec was done, 1: exec was done, status has result | |
10 | + */ | |
11 | + | |
12 | +static int | |
13 | +check_special_mountprog(const char *spec, const char *node, const char *type, int flags, | |
14 | + char *extra_opts, int *status) { | |
15 | + char mountprog[120]; | |
16 | + struct stat statbuf; | |
17 | + int res; | |
18 | + | |
19 | + if (!external_allowed) | |
20 | + return 0; | |
21 | + | |
22 | + if (type && strlen(type) < 100) { | |
23 | + sprintf(mountprog, "/sbin/mount.%s", type); | |
24 | + if (stat(mountprog, &statbuf) == 0) { | |
25 | + res = fork(); | |
26 | + if (res == 0) { | |
27 | + char *oo, *mountargs[10]; | |
28 | + int i = 0; | |
29 | + | |
30 | + setuid(getuid()); | |
31 | + setgid(getgid()); | |
32 | + oo = fix_opts_string (flags, extra_opts, NULL); | |
33 | + mountargs[i++] = mountprog; | |
34 | + mountargs[i++] = spec; | |
35 | + mountargs[i++] = node; | |
36 | + if (nomtab) | |
37 | + mountargs[i++] = "-n"; | |
38 | + if (verbose) | |
39 | + mountargs[i++] = "-v"; | |
40 | + if (oo && *oo) { | |
41 | + mountargs[i++] = "-o"; | |
42 | + mountargs[i++] = oo; | |
43 | + } | |
44 | + mountargs[i] = NULL; | |
45 | + execv(mountprog, mountargs); | |
46 | + exit(1); /* exec failed */ | |
47 | + } else if (res != -1) { | |
48 | + int st; | |
49 | + wait(&st); | |
50 | + *status = (WIFEXITED(st) ? WEXITSTATUS(st) : EX_SYSERR); | |
51 | + return 1; | |
52 | + } else { | |
53 | + int errsv = errno; | |
54 | + error(_("mount: cannot fork: %s"), strerror(errsv)); | |
55 | + } | |
56 | + } | |
57 | + } | |
58 | + return 0; | |
59 | +} | |
60 | + | |
61 | +/* | |
62 | * guess_fstype_and_mount() | |
63 | * Mount a single file system. Guess the type when unknown. | |
64 | * returns: 0: OK, -1: error in errno, 1: other error | |
65 | @@ -474,9 +529,11 @@ | |
66 | */ | |
67 | static int | |
68 | guess_fstype_and_mount(const char *spec, const char *node, const char **types, | |
69 | - int flags, char *mount_opts) { | |
70 | + int flags, char *mount_opts, int *special, int *status) { | |
71 | struct mountargs args = { spec, node, NULL, flags & ~MS_NOSYS, mount_opts }; | |
72 | ||
73 | + *special = 0; | |
74 | + | |
75 | if (*types && strcasecmp (*types, "auto") == 0) | |
76 | *types = NULL; | |
77 | ||
78 | @@ -485,10 +542,16 @@ | |
79 | ||
80 | if (!*types && !(flags & MS_REMOUNT)) { | |
81 | *types = guess_fstype(spec); | |
82 | - if (*types && !strcmp(*types, "swap")) { | |
83 | - error(_("%s looks like swapspace - not mounted"), spec); | |
84 | - *types = NULL; | |
85 | - return 1; | |
86 | + if (*types) { | |
87 | + if (!strcmp(*types, "swap")) { | |
88 | + error(_("%s looks like swapspace - not mounted"), spec); | |
89 | + *types = NULL; | |
90 | + return 1; | |
91 | + } else if (check_special_mountprog(spec, node, *types, flags, | |
92 | + mount_opts, status)) { | |
93 | + *special = 1; | |
94 | + return 0; | |
95 | + } | |
96 | } | |
97 | } | |
98 | ||
99 | @@ -741,61 +804,6 @@ | |
100 | } | |
101 | ||
102 | /* | |
103 | - * check_special_mountprog() | |
104 | - * If there is a special mount program for this type, exec it. | |
105 | - * returns: 0: no exec was done, 1: exec was done, status has result | |
106 | - */ | |
107 | - | |
108 | -static int | |
109 | -check_special_mountprog(const char *spec, const char *node, const char *type, | |
110 | - int flags, char *extra_opts, int *status) { | |
111 | - char mountprog[120]; | |
112 | - struct stat statbuf; | |
113 | - int res; | |
114 | - | |
115 | - if (!external_allowed) | |
116 | - return 0; | |
117 | - | |
118 | - if (type && strlen(type) < 100) { | |
119 | - sprintf(mountprog, "/sbin/mount.%s", type); | |
120 | - if (stat(mountprog, &statbuf) == 0) { | |
121 | - res = fork(); | |
122 | - if (res == 0) { | |
123 | - const char *oo, *mountargs[10]; | |
124 | - int i = 0; | |
125 | - | |
126 | - setuid(getuid()); | |
127 | - setgid(getgid()); | |
128 | - oo = fix_opts_string (flags, extra_opts, NULL); | |
129 | - mountargs[i++] = mountprog; | |
130 | - mountargs[i++] = spec; | |
131 | - mountargs[i++] = node; | |
132 | - if (nomtab) | |
133 | - mountargs[i++] = "-n"; | |
134 | - if (verbose) | |
135 | - mountargs[i++] = "-v"; | |
136 | - if (oo && *oo) { | |
137 | - mountargs[i++] = "-o"; | |
138 | - mountargs[i++] = oo; | |
139 | - } | |
140 | - mountargs[i] = NULL; | |
141 | - execv(mountprog, (char **) mountargs); | |
142 | - exit(1); /* exec failed */ | |
143 | - } else if (res != -1) { | |
144 | - int st; | |
145 | - wait(&st); | |
146 | - *status = (WIFEXITED(st) ? WEXITSTATUS(st) : EX_SYSERR); | |
147 | - return 1; | |
148 | - } else { | |
149 | - int errsv = errno; | |
150 | - error(_("mount: cannot fork: %s"), strerror(errsv)); | |
151 | - } | |
152 | - } | |
153 | - } | |
154 | - return 0; | |
155 | -} | |
156 | - | |
157 | -/* | |
158 | * try_mount_one() | |
159 | * Try to mount one file system. When "bg" is 1, this is a retry | |
160 | * in the background. One additional exit code EX_BG is used here. | |
161 | @@ -807,7 +815,7 @@ | |
162 | static int | |
163 | try_mount_one (const char *spec0, const char *node0, const char *types0, | |
164 | const char *opts0, int freq, int pass, int bg, int ro) { | |
165 | - int res = 0, status; | |
166 | + int res = 0, status, special; | |
167 | int mnt5_res = 0; /* only for gcc */ | |
168 | int mnt_err; | |
169 | int flags; | |
170 | @@ -898,9 +906,15 @@ | |
171 | block_signals (SIG_BLOCK); | |
172 | nosigblock: | |
173 | ||
174 | - if (!fake) | |
175 | + if (!fake) { | |
176 | mnt5_res = guess_fstype_and_mount (spec, node, &types, flags & ~MS_NOSYS, | |
177 | - mount_opts); | |
178 | + mount_opts, &special, &status); | |
179 | + | |
180 | + if (special) { | |
181 | + block_signals (SIG_UNBLOCK); | |
182 | + return status; | |
183 | + } | |
184 | + } | |
185 | ||
186 | if (fake || mnt5_res == 0) { | |
187 | /* Mount succeeded, report this (if verbose) and write mtab entry. */ |