diff options
author | Rob Landley <rob@landley.net> | 2006-03-29 14:30:49 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-03-29 14:30:49 +0000 |
commit | fe908fda283e00fa601eb88161ce5e86ec24a321 (patch) | |
tree | afd0a385aa96b7097740986def673aabf6bdc9a0 /util-linux/mount.c | |
parent | dbd91af0613652f37ddb04e47b9bca3411ae7526 (diff) | |
download | busybox-w32-fe908fda283e00fa601eb88161ce5e86ec24a321.tar.gz busybox-w32-fe908fda283e00fa601eb88161ce5e86ec24a321.tar.bz2 busybox-w32-fe908fda283e00fa601eb88161ce5e86ec24a321.zip |
Kumar Gala tracked down a problem with NFS mounting. This is a different fix
from his, but to the same problem.
Diffstat (limited to 'util-linux/mount.c')
-rw-r--r-- | util-linux/mount.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c index 1b6ff965b..fbb4e36c4 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -184,6 +184,8 @@ static void delete_block_backed_filesystems(void) | |||
184 | { | 184 | { |
185 | llist_free(fslist); | 185 | llist_free(fslist); |
186 | } | 186 | } |
187 | #else | ||
188 | void delete_block_backed_filesystems(void); | ||
187 | #endif | 189 | #endif |
188 | 190 | ||
189 | #if ENABLE_FEATURE_MTAB_SUPPORT | 191 | #if ENABLE_FEATURE_MTAB_SUPPORT |
@@ -196,12 +198,9 @@ static int fakeIt; | |||
196 | 198 | ||
197 | // Perform actual mount of specific filesystem at specific location. | 199 | // Perform actual mount of specific filesystem at specific location. |
198 | 200 | ||
199 | static int mount_it_now(struct mntent *mp, int vfsflags) | 201 | static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts) |
200 | { | 202 | { |
201 | int rc; | 203 | int rc; |
202 | char *filteropts = 0; | ||
203 | |||
204 | parse_mount_options(mp->mnt_opts, &filteropts); | ||
205 | 204 | ||
206 | if (fakeIt) { return 0; } | 205 | if (fakeIt) { return 0; } |
207 | 206 | ||
@@ -217,8 +216,6 @@ static int mount_it_now(struct mntent *mp, int vfsflags) | |||
217 | vfsflags |= MS_RDONLY; | 216 | vfsflags |= MS_RDONLY; |
218 | } | 217 | } |
219 | 218 | ||
220 | free(filteropts); | ||
221 | |||
222 | // Abort entirely if permission denied. | 219 | // Abort entirely if permission denied. |
223 | 220 | ||
224 | if (rc && errno == EPERM) | 221 | if (rc && errno == EPERM) |
@@ -266,11 +263,11 @@ static int mount_it_now(struct mntent *mp, int vfsflags) | |||
266 | static int singlemount(struct mntent *mp) | 263 | static int singlemount(struct mntent *mp) |
267 | { | 264 | { |
268 | int rc = 1, vfsflags; | 265 | int rc = 1, vfsflags; |
269 | char *loopFile = 0; | 266 | char *loopFile = 0, *filteropts = 0; |
270 | llist_t *fl = 0; | 267 | llist_t *fl = 0; |
271 | struct stat st; | 268 | struct stat st; |
272 | 269 | ||
273 | vfsflags = parse_mount_options(mp->mnt_opts, 0); | 270 | vfsflags = parse_mount_options(mp->mnt_opts, &filteropts); |
274 | 271 | ||
275 | // Treat fstype "auto" as unspecified. | 272 | // Treat fstype "auto" as unspecified. |
276 | 273 | ||
@@ -282,16 +279,16 @@ static int singlemount(struct mntent *mp) | |||
282 | (!mp->mnt_type || !strcmp(mp->mnt_type,"nfs")) && | 279 | (!mp->mnt_type || !strcmp(mp->mnt_type,"nfs")) && |
283 | strchr(mp->mnt_fsname, ':') != NULL) | 280 | strchr(mp->mnt_fsname, ':') != NULL) |
284 | { | 281 | { |
285 | char *options=0; | 282 | if (nfsmount(mp->mnt_fsname, mp->mnt_dir, &vfsflags, &filteropts, 1)) { |
286 | parse_mount_options(mp->mnt_opts, &options); | ||
287 | if (nfsmount(mp->mnt_fsname, mp->mnt_dir, &vfsflags, &options, 1)) { | ||
288 | bb_perror_msg("nfsmount failed"); | 283 | bb_perror_msg("nfsmount failed"); |
289 | return 1; | 284 | return 1; |
285 | } else { | ||
286 | // Strangely enough, nfsmount() doesn't actually mount() anything. | ||
287 | rc = mount_it_now(mp, vfsflags, filteropts); | ||
288 | if (ENABLE_FEATURE_CLEAN_UP) free(filteropts); | ||
289 | |||
290 | return rc; | ||
290 | } | 291 | } |
291 | |||
292 | // Strangely enough, nfsmount() doesn't actually mount() anything. | ||
293 | |||
294 | else return mount_it_now(mp, vfsflags); | ||
295 | } | 292 | } |
296 | 293 | ||
297 | // Look at the file. (Not found isn't a failure for remount.) | 294 | // Look at the file. (Not found isn't a failure for remount.) |
@@ -324,7 +321,7 @@ static int singlemount(struct mntent *mp) | |||
324 | * to the actual mount. */ | 321 | * to the actual mount. */ |
325 | 322 | ||
326 | if (mp->mnt_type || (vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) | 323 | if (mp->mnt_type || (vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) |
327 | rc = mount_it_now(mp, vfsflags); | 324 | rc = mount_it_now(mp, vfsflags, filteropts); |
328 | 325 | ||
329 | // Loop through filesystem types until mount succeeds or we run out | 326 | // Loop through filesystem types until mount succeeds or we run out |
330 | 327 | ||
@@ -336,25 +333,26 @@ static int singlemount(struct mntent *mp) | |||
336 | 333 | ||
337 | if (!fslist) { | 334 | if (!fslist) { |
338 | fslist = get_block_backed_filesystems(); | 335 | fslist = get_block_backed_filesystems(); |
339 | #if ENABLE_FEATURE_CLEAN_UP | ||
340 | if (ENABLE_FEATURE_CLEAN_UP && fslist) | 336 | if (ENABLE_FEATURE_CLEAN_UP && fslist) |
341 | atexit(delete_block_backed_filesystems); | 337 | atexit(delete_block_backed_filesystems); |
342 | #endif | ||
343 | } | 338 | } |
344 | 339 | ||
345 | for (fl = fslist; fl; fl = fl->link) { | 340 | for (fl = fslist; fl; fl = fl->link) { |
346 | mp->mnt_type = fl->data; | 341 | mp->mnt_type = fl->data; |
347 | 342 | ||
348 | if (!(rc = mount_it_now(mp,vfsflags))) break; | 343 | if (!(rc = mount_it_now(mp,vfsflags, filteropts))) break; |
349 | 344 | ||
350 | mp->mnt_type = 0; | 345 | mp->mnt_type = 0; |
351 | } | 346 | } |
352 | } | 347 | } |
353 | 348 | ||
354 | // Mount failed. Clean up | 349 | if (ENABLE_FEATURE_CLEAN_UP) free(filteropts); |
350 | |||
351 | // If mount failed, clean up loop file (if any). | ||
352 | |||
355 | if (rc && loopFile) { | 353 | if (rc && loopFile) { |
356 | del_loop(mp->mnt_fsname); | 354 | del_loop(mp->mnt_fsname); |
357 | if(ENABLE_FEATURE_CLEAN_UP) { | 355 | if (ENABLE_FEATURE_CLEAN_UP) { |
358 | free(loopFile); | 356 | free(loopFile); |
359 | free(mp->mnt_fsname); | 357 | free(mp->mnt_fsname); |
360 | } | 358 | } |