aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-08-23 06:17:46 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-08-23 06:17:46 +0000
commit8042f65398adafbe7931646b0d8833f7b650d010 (patch)
tree8066b2d843876cb8379ec9727250d7024c3293d6
parentacfc0d872e159590376f0f11d555326e1e052f58 (diff)
downloadbusybox-w32-8042f65398adafbe7931646b0d8833f7b650d010.tar.gz
busybox-w32-8042f65398adafbe7931646b0d8833f7b650d010.tar.bz2
busybox-w32-8042f65398adafbe7931646b0d8833f7b650d010.zip
Run through indent, style
-rw-r--r--util-linux/mount.c114
1 files changed, 66 insertions, 48 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 873d27eb5..829d31666 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -120,9 +120,9 @@ static const struct mount_options mount_options[] = {
120}; 120};
121 121
122static int 122static int
123do_mount(char *specialfile, char *dir, char *filesystemtype, 123do_mount(char *specialfile, char *dir, char *filesystemtype, long flags,
124 long flags, void *string_flags, int useMtab, int fakeIt, 124 void *string_flags, int useMtab, int fakeIt, char *mtab_opts,
125 char *mtab_opts, int mount_all) 125 int mount_all)
126{ 126{
127 int status = 0; 127 int status = 0;
128 128
@@ -158,8 +158,9 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
158 MS_RDONLY, string_flags); 158 MS_RDONLY, string_flags);
159 } 159 }
160 /* Don't whine about already mounted filesystems when mounting all. */ 160 /* Don't whine about already mounted filesystems when mounting all. */
161 if (status < 0 && errno == EBUSY && mount_all) 161 if (status < 0 && errno == EBUSY && mount_all) {
162 return TRUE; 162 return TRUE;
163 }
163 } 164 }
164 165
165 166
@@ -204,8 +205,9 @@ static void parse_mount_options(char *options, int *flags, char **strflags)
204 char *comma = strchr(options, ','); 205 char *comma = strchr(options, ',');
205 const struct mount_options *f = mount_options; 206 const struct mount_options *f = mount_options;
206 207
207 if (comma) 208 if (comma) {
208 *comma = '\0'; 209 *comma = '\0';
210 }
209 211
210 while (f->name != 0) { 212 while (f->name != 0) {
211 if (strcasecmp(f->name, options) == 0) { 213 if (strcasecmp(f->name, options) == 0) {
@@ -224,8 +226,10 @@ static void parse_mount_options(char *options, int *flags, char **strflags)
224 } 226 }
225#endif 227#endif
226 if (!gotone) { 228 if (!gotone) {
227 if (**strflags) /* have previous parsed options */ 229 if (**strflags) {
230 /* have previous parsed options */
228 paste_str(strflags, ","); 231 paste_str(strflags, ",");
232 }
229 paste_str(strflags, options); 233 paste_str(strflags, options);
230 } 234 }
231 if (comma) { 235 if (comma) {
@@ -237,10 +241,10 @@ static void parse_mount_options(char *options, int *flags, char **strflags)
237 } 241 }
238} 242}
239 243
240static int 244static int mount_one(char *blockDevice, char *directory, char *filesystemType,
241mount_one(char *blockDevice, char *directory, char *filesystemType, 245 unsigned long flags, char *string_flags, int useMtab,
242 unsigned long flags, char *string_flags, int useMtab, int fakeIt, 246 int fakeIt, char *mtab_opts, int whineOnErrors,
243 char *mtab_opts, int whineOnErrors, int mount_all) 247 int mount_all)
244{ 248{
245 int status = 0; 249 int status = 0;
246 250
@@ -265,11 +269,13 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
265 } 269 }
266 } 270 }
267 if (!*noauto_fstype) { 271 if (!*noauto_fstype) {
268 status = do_mount(blockDevice, directory, filesystemType, 272 status =
269 flags | MS_MGC_VAL, string_flags, 273 do_mount(blockDevice, directory, filesystemType,
270 useMtab, fakeIt, mtab_opts, mount_all); 274 flags | MS_MGC_VAL, string_flags, useMtab,
271 if (status) 275 fakeIt, mtab_opts, mount_all);
276 if (status) {
272 break; 277 break;
278 }
273 } 279 }
274 } 280 }
275 } 281 }
@@ -283,16 +289,17 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
283 289
284 if (f) { 290 if (f) {
285 while (fgets(buf, sizeof(buf), f)) { 291 while (fgets(buf, sizeof(buf), f)) {
286 if (*buf == '*') 292 if (*buf == '*') {
287 read_proc = 1; 293 read_proc = 1;
288 else if (*buf == '#') 294 } else if (*buf == '#') {
289 continue; 295 continue;
290 else { 296 } else {
291 filesystemType = buf; 297 filesystemType = buf;
292 298
293 /* Add NULL termination to each line */ 299 /* Add NULL termination to each line */
294 while (*filesystemType && !isspace(*filesystemType)) 300 while (*filesystemType && !isspace(*filesystemType)) {
295 filesystemType++; 301 filesystemType++;
302 }
296 *filesystemType = '\0'; 303 *filesystemType = '\0';
297 304
298 filesystemType = buf; 305 filesystemType = buf;
@@ -302,8 +309,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
302 do_mount(blockDevice, directory, filesystemType, 309 do_mount(blockDevice, directory, filesystemType,
303 flags | MS_MGC_VAL, string_flags, 310 flags | MS_MGC_VAL, string_flags,
304 useMtab, fakeIt, mtab_opts, mount_all); 311 useMtab, fakeIt, mtab_opts, mount_all);
305 if (status) 312 if (status) {
306 break; 313 break;
314 }
307 } 315 }
308 316
309 } 317 }
@@ -319,18 +327,21 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
319 if (*filesystemType == '\t') { /* Not a nodev filesystem */ 327 if (*filesystemType == '\t') { /* Not a nodev filesystem */
320 328
321 /* Add NULL termination to each line */ 329 /* Add NULL termination to each line */
322 while (*filesystemType && *filesystemType != '\n') 330 while (*filesystemType && *filesystemType != '\n') {
323 filesystemType++; 331 filesystemType++;
332 }
324 *filesystemType = '\0'; 333 *filesystemType = '\0';
325 334
326 filesystemType = buf; 335 filesystemType = buf;
327 filesystemType++; /* hop past tab */ 336 filesystemType++; /* hop past tab */
328 337
329 status = do_mount(blockDevice, directory, filesystemType, 338 status =
330 flags | MS_MGC_VAL, string_flags, 339 do_mount(blockDevice, directory, filesystemType,
331 useMtab, fakeIt, mtab_opts, mount_all); 340 flags | MS_MGC_VAL, string_flags, useMtab,
332 if (status) 341 fakeIt, mtab_opts, mount_all);
342 if (status) {
333 break; 343 break;
344 }
334 } 345 }
335 } 346 }
336 } 347 }
@@ -338,9 +349,10 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
338 } 349 }
339#endif 350#endif
340 else { 351 else {
341 status = do_mount(blockDevice, directory, filesystemType, 352 status =
342 flags | MS_MGC_VAL, string_flags, useMtab, 353 do_mount(blockDevice, directory, filesystemType,
343 fakeIt, mtab_opts, mount_all); 354 flags | MS_MGC_VAL, string_flags, useMtab, fakeIt,
355 mtab_opts, mount_all);
344 } 356 }
345 357
346 if (!status) { 358 if (!status) {
@@ -361,20 +373,23 @@ static void show_mounts(char *onlytype)
361 373
362 /* open device */ 374 /* open device */
363 fd = open(device, O_RDONLY); 375 fd = open(device, O_RDONLY);
364 if (fd < 0) 376 if (fd < 0) {
365 perror_msg_and_die("open failed for `%s'", device); 377 perror_msg_and_die("open failed for `%s'", device);
378 }
366 379
367 /* How many mounted filesystems? We need to know to 380 /* How many mounted filesystems? We need to know to
368 * allocate enough space for later... */ 381 * allocate enough space for later... */
369 numfilesystems = ioctl(fd, DEVMTAB_COUNT_MOUNTS); 382 numfilesystems = ioctl(fd, DEVMTAB_COUNT_MOUNTS);
370 if (numfilesystems < 0) 383 if (numfilesystems < 0) {
371 perror_msg_and_die("\nDEVMTAB_COUNT_MOUNTS"); 384 perror_msg_and_die("\nDEVMTAB_COUNT_MOUNTS");
385 }
372 mntentlist = 386 mntentlist =
373 (struct k_mntent *) xcalloc(numfilesystems, sizeof(struct k_mntent)); 387 (struct k_mntent *) xcalloc(numfilesystems, sizeof(struct k_mntent));
374 388
375 /* Grab the list of mounted filesystems */ 389 /* Grab the list of mounted filesystems */
376 if (ioctl(fd, DEVMTAB_GET_MOUNTS, mntentlist) < 0) 390 if (ioctl(fd, DEVMTAB_GET_MOUNTS, mntentlist) < 0) {
377 perror_msg_and_die("\nDEVMTAB_GET_MOUNTS"); 391 perror_msg_and_die("\nDEVMTAB_GET_MOUNTS");
392 }
378 393
379 for (i = 0; i < numfilesystems; i++) { 394 for (i = 0; i < numfilesystems; i++) {
380 if (!onlytype || (strcmp(mntentlist[i].mnt_type, onlytype) == 0)) { 395 if (!onlytype || (strcmp(mntentlist[i].mnt_type, onlytype) == 0)) {
@@ -408,8 +423,9 @@ static void show_mounts(char *onlytype)
408 m->mnt_type, m->mnt_opts); 423 m->mnt_type, m->mnt_opts);
409 } 424 }
410#ifdef CONFIG_FEATURE_CLEAN_UP 425#ifdef CONFIG_FEATURE_CLEAN_UP
411 if (blockDevice != m->mnt_fsname) 426 if (blockDevice != m->mnt_fsname) {
412 free(blockDevice); 427 free(blockDevice);
428 }
413#endif 429#endif
414 } 430 }
415 endmntent(mountTable); 431 endmntent(mountTable);
@@ -470,8 +486,9 @@ extern int mount_main(int argc, char **argv)
470 } 486 }
471 } 487 }
472 488
473 if (!all && optind == argc) 489 if (!all && (optind == argc)) {
474 show_mounts(got_filesystemType ? filesystemType : 0); 490 show_mounts(got_filesystemType ? filesystemType : NULL);
491 }
475 492
476 if (optind < argc) { 493 if (optind < argc) {
477 /* if device is a filename get its real path */ 494 /* if device is a filename get its real path */
@@ -494,10 +511,9 @@ extern int mount_main(int argc, char **argv)
494 perror_msg_and_die("\nCannot read /etc/fstab"); 511 perror_msg_and_die("\nCannot read /etc/fstab");
495 512
496 while ((m = getmntent(f)) != NULL) { 513 while ((m = getmntent(f)) != NULL) {
497 if (!all && optind + 1 == argc && ((strcmp(device, m->mnt_fsname) 514 if (!all && (optind + 1 == argc)
498 != 0) 515 && ((strcmp(device, m->mnt_fsname) != 0)
499 && (strcmp(device, m->mnt_dir) 516 && (strcmp(device, m->mnt_dir) != 0))) {
500 != 0))) {
501 continue; 517 continue;
502 } 518 }
503 519
@@ -523,27 +539,29 @@ extern int mount_main(int argc, char **argv)
523#ifdef CONFIG_NFSMOUNT 539#ifdef CONFIG_NFSMOUNT
524 if (strchr(device, ':') != NULL) { 540 if (strchr(device, ':') != NULL) {
525 filesystemType = "nfs"; 541 filesystemType = "nfs";
526 if (nfsmount(device, directory, &flags, &extra_opts, 542 if (nfsmount
527 &string_flags, 1)) { 543 (device, directory, &flags, &extra_opts, &string_flags,
544 1)) {
528 perror_msg("nfsmount failed"); 545 perror_msg("nfsmount failed");
529 rc = EXIT_FAILURE; 546 rc = EXIT_FAILURE;
530 } 547 }
531 } 548 }
532#endif 549#endif
533 if (!mount_one(device, directory, filesystemType, flags, 550 if (!mount_one
534 string_flags, useMtab, fakeIt, extra_opts, TRUE, 551 (device, directory, filesystemType, flags, string_flags,
535 all)) 552 useMtab, fakeIt, extra_opts, TRUE, all)) {
536 rc = EXIT_FAILURE; 553 rc = EXIT_FAILURE;
537 554 }
538 if (!all) 555 if (!all) {
539 break; 556 break;
557 }
540 } 558 }
541 if (f) 559 if (f) {
542 endmntent(f); 560 endmntent(f);
543 561 }
544 if (!all && f && m == NULL) 562 if (!all && f && m == NULL) {
545 fprintf(stderr, "Can't find %s in /etc/fstab\n", device); 563 fprintf(stderr, "Can't find %s in /etc/fstab\n", device);
546 564 }
547 return rc; 565 return rc;
548 } 566 }
549 567