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