summaryrefslogtreecommitdiff
path: root/util-linux/mount.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2006-03-20 18:07:50 +0000
committerEric Andersen <andersen@codepoet.org>2006-03-20 18:07:50 +0000
commit9601a1c8c21c61232d5c1d7962107f0dd3f19b90 (patch)
tree32c6f7872250f354cab5fcb8c7b770742fb21e04 /util-linux/mount.c
parent19b5b8ff6a40bd72685bf63963394dc2b2707e68 (diff)
downloadbusybox-w32-9601a1c8c21c61232d5c1d7962107f0dd3f19b90.tar.gz
busybox-w32-9601a1c8c21c61232d5c1d7962107f0dd3f19b90.tar.bz2
busybox-w32-9601a1c8c21c61232d5c1d7962107f0dd3f19b90.zip
whitespace cleanup
Diffstat (limited to 'util-linux/mount.c')
-rw-r--r--util-linux/mount.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 4750989ce..f0b4d3831 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -16,7 +16,7 @@
16/* Design notes: There is no spec for this. Remind me to write one. 16/* Design notes: There is no spec for this. Remind me to write one.
17 17
18 mount_main() calls singlemount() which calls mount_it_now(). 18 mount_main() calls singlemount() which calls mount_it_now().
19 19
20 mount_main() can loop through /etc/fstab for mount -a 20 mount_main() can loop through /etc/fstab for mount -a
21 singlemount() can loop through /etc/filesystems for fstype detection. 21 singlemount() can loop through /etc/filesystems for fstype detection.
22 mount_it_now() does the actual mount. 22 mount_it_now() does the actual mount.
@@ -62,7 +62,7 @@ struct {
62 {"defaults", 0}, 62 {"defaults", 0},
63 {"quiet", 0}, 63 {"quiet", 0},
64 64
65 // vfs flags 65 // vfs flags
66 66
67 {"ro", MS_RDONLY}, 67 {"ro", MS_RDONLY},
68 {"rw", ~MS_RDONLY}, 68 {"rw", ~MS_RDONLY},
@@ -79,7 +79,7 @@ struct {
79 {"diratime", ~MS_NODIRATIME}, 79 {"diratime", ~MS_NODIRATIME},
80 {"nodiratime", MS_NODIRATIME}, 80 {"nodiratime", MS_NODIRATIME},
81 {"loud", ~MS_SILENT}, 81 {"loud", ~MS_SILENT},
82 82
83 // action flags 83 // action flags
84 84
85 {"remount", MS_REMOUNT}, 85 {"remount", MS_REMOUNT},
@@ -127,23 +127,23 @@ static int parse_mount_options(char *options, char **unrecognized)
127 // If unrecognized not NULL, append unrecognized mount options */ 127 // If unrecognized not NULL, append unrecognized mount options */
128 if (unrecognized 128 if (unrecognized
129 && i == (sizeof(mount_options) / sizeof(*mount_options))) 129 && i == (sizeof(mount_options) / sizeof(*mount_options)))
130 { 130 {
131 // Add it to strflags, to pass on to kernel 131 // Add it to strflags, to pass on to kernel
132 i = *unrecognized ? strlen(*unrecognized) : 0; 132 i = *unrecognized ? strlen(*unrecognized) : 0;
133 *unrecognized = xrealloc(*unrecognized, i+strlen(options)+2); 133 *unrecognized = xrealloc(*unrecognized, i+strlen(options)+2);
134 134
135 // Comma separated if it's not the first one 135 // Comma separated if it's not the first one
136 if (i) (*unrecognized)[i++] = ','; 136 if (i) (*unrecognized)[i++] = ',';
137 strcpy((*unrecognized)+i, options); 137 strcpy((*unrecognized)+i, options);
138 } 138 }
139 139
140 // Advance to next option, or finish 140 // Advance to next option, or finish
141 if(comma) { 141 if(comma) {
142 *comma = ','; 142 *comma = ',';
143 options = ++comma; 143 options = ++comma;
144 } else break; 144 } else break;
145 } 145 }
146 146
147 return flags; 147 return flags;
148} 148}
149 149
@@ -159,16 +159,16 @@ static llist_t *get_block_backed_filesystems(void)
159 159
160 for(i = 0; filesystems[i]; i++) { 160 for(i = 0; filesystems[i]; i++) {
161 if(!(f = fopen(filesystems[i], "r"))) continue; 161 if(!(f = fopen(filesystems[i], "r"))) continue;
162 162
163 for(fs = buf = 0; (fs = buf = bb_get_chomped_line_from_file(f)); 163 for(fs = buf = 0; (fs = buf = bb_get_chomped_line_from_file(f));
164 free(buf)) 164 free(buf))
165 { 165 {
166 if(!strncmp(buf,"nodev",5) && isspace(buf[5])) continue; 166 if(!strncmp(buf,"nodev",5) && isspace(buf[5])) continue;
167 167
168 while(isspace(*fs)) fs++; 168 while(isspace(*fs)) fs++;
169 if(*fs=='#' || *fs=='*') continue; 169 if(*fs=='#' || *fs=='*') continue;
170 if(!*fs) continue; 170 if(!*fs) continue;
171 171
172 list=llist_add_to_end(list,bb_xstrdup(fs)); 172 list=llist_add_to_end(list,bb_xstrdup(fs));
173 } 173 }
174 if (ENABLE_FEATURE_CLEAN_UP) fclose(f); 174 if (ENABLE_FEATURE_CLEAN_UP) fclose(f);
@@ -226,7 +226,7 @@ static int mount_it_now(struct mntent *mp, int vfsflags)
226 226
227 /* If the mount was successful, and we're maintaining an old-style 227 /* If the mount was successful, and we're maintaining an old-style
228 * mtab file by hand, add the new entry to it now. */ 228 * mtab file by hand, add the new entry to it now. */
229 229
230 if(ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc) { 230 if(ENABLE_FEATURE_MTAB_SUPPORT && useMtab && !rc) {
231 FILE *mountTable = setmntent(bb_path_mtab_file, "a+"); 231 FILE *mountTable = setmntent(bb_path_mtab_file, "a+");
232 int i; 232 int i;
@@ -255,7 +255,7 @@ static int mount_it_now(struct mntent *mp, int vfsflags)
255 if (ENABLE_FEATURE_CLEAN_UP) 255 if (ENABLE_FEATURE_CLEAN_UP)
256 if(strcmp(mp->mnt_type,"--bind")) mp->mnt_type = 0; 256 if(strcmp(mp->mnt_type,"--bind")) mp->mnt_type = 0;
257 } 257 }
258 258
259 return rc; 259 return rc;
260} 260}
261 261
@@ -288,7 +288,7 @@ static int singlemount(struct mntent *mp)
288 bb_perror_msg("nfsmount failed"); 288 bb_perror_msg("nfsmount failed");
289 return 1; 289 return 1;
290 } 290 }
291 291
292 // Strangely enough, nfsmount() doesn't actually mount() anything. 292 // Strangely enough, nfsmount() doesn't actually mount() anything.
293 293
294 else return mount_it_now(mp, vfsflags); 294 else return mount_it_now(mp, vfsflags);
@@ -298,9 +298,9 @@ static int singlemount(struct mntent *mp)
298 298
299 if (lstat(mp->mnt_fsname, &st)); 299 if (lstat(mp->mnt_fsname, &st));
300 300
301 if (!(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) { 301 if (!(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) {
302 // Do we need to allocate a loopback device for it? 302 // Do we need to allocate a loopback device for it?
303 303
304 if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) { 304 if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) {
305 loopFile = bb_simplify_path(mp->mnt_fsname); 305 loopFile = bb_simplify_path(mp->mnt_fsname);
306 mp->mnt_fsname = 0; 306 mp->mnt_fsname = 0;
@@ -341,7 +341,7 @@ static int singlemount(struct mntent *mp)
341 atexit(delete_block_backed_filesystems); 341 atexit(delete_block_backed_filesystems);
342#endif 342#endif
343 } 343 }
344 344
345 for (fl = fslist; fl; fl = fl->link) { 345 for (fl = fslist; fl; fl = fl->link) {
346 mp->mnt_type = fl->data; 346 mp->mnt_type = fl->data;
347 347
@@ -372,13 +372,13 @@ int mount_main(int argc, char **argv)
372 FILE *fstab; 372 FILE *fstab;
373 int i, opt, all = FALSE, rc = 1; 373 int i, opt, all = FALSE, rc = 1;
374 struct mntent mtpair[2], *mtcur = mtpair; 374 struct mntent mtpair[2], *mtcur = mtpair;
375 375
376 /* parse long options, like --bind and --move. Note that -o option 376 /* parse long options, like --bind and --move. Note that -o option
377 * and --option are synonymous. Yes, this means --remount,rw works. */ 377 * and --option are synonymous. Yes, this means --remount,rw works. */
378 378
379 for (i = opt = 0; i < argc; i++) { 379 for (i = opt = 0; i < argc; i++) {
380 if (argv[i][0] == '-' && argv[i][1] == '-') { 380 if (argv[i][0] == '-' && argv[i][1] == '-') {
381 append_mount_options(&cmdopts,argv[i]+2); 381 append_mount_options(&cmdopts,argv[i]+2);
382 } else argv[opt++] = argv[i]; 382 } else argv[opt++] = argv[i];
383 } 383 }
384 argc = opt; 384 argc = opt;
@@ -414,11 +414,11 @@ int mount_main(int argc, char **argv)
414 bb_show_usage(); 414 bb_show_usage();
415 } 415 }
416 } 416 }
417 417
418 // Three or more non-option arguments? Die with a usage message. 418 // Three or more non-option arguments? Die with a usage message.
419 419
420 if (optind-argc>2) bb_show_usage(); 420 if (optind-argc>2) bb_show_usage();
421 421
422 // If we have no arguments, show currently mounted filesystems 422 // If we have no arguments, show currently mounted filesystems
423 423
424 if (optind == argc) { 424 if (optind == argc) {
@@ -457,18 +457,18 @@ int mount_main(int argc, char **argv)
457 } 457 }
458 458
459 // If we have at least one argument, it's the storage location 459 // If we have at least one argument, it's the storage location
460 460
461 if (optind < argc) storage_path = bb_simplify_path(argv[optind]); 461 if (optind < argc) storage_path = bb_simplify_path(argv[optind]);
462 462
463 // Open either fstab or mtab 463 // Open either fstab or mtab
464 464
465 if (parse_mount_options(cmdopts,0) & MS_REMOUNT) 465 if (parse_mount_options(cmdopts,0) & MS_REMOUNT)
466 fstabname = (char *)bb_path_mtab_file; // Again with the evil const. 466 fstabname = (char *)bb_path_mtab_file; // Again with the evil const.
467 else fstabname="/etc/fstab"; 467 else fstabname="/etc/fstab";
468 468
469 if (!(fstab=setmntent(fstabname,"r"))) 469 if (!(fstab=setmntent(fstabname,"r")))
470 bb_perror_msg_and_die("Cannot read %s",fstabname); 470 bb_perror_msg_and_die("Cannot read %s",fstabname);
471 471
472 // Loop through entries until we find what we're looking for. 472 // Loop through entries until we find what we're looking for.
473 473
474 memset(mtpair,0,sizeof(mtpair)); 474 memset(mtpair,0,sizeof(mtpair));
@@ -489,7 +489,7 @@ int mount_main(int argc, char **argv)
489 if (!mtnext->mnt_fsname) 489 if (!mtnext->mnt_fsname)
490 bb_error_msg_and_die("Can't find %s in %s", 490 bb_error_msg_and_die("Can't find %s in %s",
491 argv[optind], fstabname); 491 argv[optind], fstabname);
492 492
493 // Mount the last thing we found. 493 // Mount the last thing we found.
494 494
495 mtcur = mtnext; 495 mtcur = mtnext;
@@ -518,14 +518,14 @@ int mount_main(int argc, char **argv)
518 // it, and we want the _last_ match. 518 // it, and we want the _last_ match.
519 519
520 mtcur = mtnext; 520 mtcur = mtnext;
521 521
522 // If we're mounting all. 522 // If we're mounting all.
523 523
524 } else { 524 } else {
525 525
526 // Do we need to match a filesystem type? 526 // Do we need to match a filesystem type?
527 if (fstype && strcmp(mtcur->mnt_type,fstype)) continue; 527 if (fstype && strcmp(mtcur->mnt_type,fstype)) continue;
528 528
529 // Skip noauto and swap anyway. 529 // Skip noauto and swap anyway.
530 530
531 if (parse_mount_options(mtcur->mnt_opts,0) 531 if (parse_mount_options(mtcur->mnt_opts,0)
@@ -550,7 +550,7 @@ clean_up:
550 free(cmdopts); 550 free(cmdopts);
551 free(fstype); 551 free(fstype);
552 } 552 }
553 553
554 if(rc) 554 if(rc)
555 bb_perror_msg("Mounting %s on %s failed", 555 bb_perror_msg("Mounting %s on %s failed",
556 mtcur->mnt_fsname, mtcur->mnt_dir); 556 mtcur->mnt_fsname, mtcur->mnt_dir);