X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=umount.c;h=ab76be4da35db8245c4bfca67102dbc8dd6092b7;hb=3695052813a0c9af6b891387e688fc07e4761c99;hp=89c59f9ee81df3f38f1749e0ca908386c3fee5b6;hpb=cf8c9cf7b9792e9cef3d790c46763712c390c7ed;p=oweals%2Fbusybox.git diff --git a/umount.c b/umount.c index 89c59f9ee..ab76be4da 100644 --- a/umount.c +++ b/umount.c @@ -29,8 +29,8 @@ #include static const char umount_usage[] = -"Usage: umount [flags] filesystem|directory\n" -"Optional Flags:\n" +"Usage: umount [flags] filesystem|directory\n\n" +"Flags:\n" "\t-a:\tUnmount all file systems" #ifdef BB_MTAB " in /etc/mtab\n\t-n:\tDon't erase /etc/mtab entries\n" @@ -73,8 +73,13 @@ umount_all(int useMtab) while ((m = getmntent (mountTable)) != 0) { char *blockDevice = m->mnt_fsname; #if ! defined BB_MTAB - if (strcmp (blockDevice, "/dev/root") == 0) - blockDevice = (getfsfile ("/"))->fs_spec; + if (strcmp (blockDevice, "/dev/root") == 0) { + struct fstab* fstabItem; + fstabItem = getfsfile ("/"); + if (fstabItem != NULL) { + blockDevice = fstabItem->fs_spec; + } + } #endif /* Don't umount /proc when doing umount -a */ if (strcmp (blockDevice, "proc") == 0) @@ -102,13 +107,12 @@ umount_all(int useMtab) extern int umount_main(int argc, char** argv) { - if (argc < 2) { usage( umount_usage); } /* Parse any options */ - while (argc-- > 0 && **(argv++) == '-') { + while (--argc > 0 && **(++argv) == '-') { while (*++(*argv)) switch (**argv) { case 'a': umountAll = TRUE; @@ -124,7 +128,7 @@ umount_main(int argc, char** argv) } - if(umountAll) { + if(umountAll==TRUE) { exit(umount_all(useMtab)); } if ( do_umount(*argv,useMtab) == 0 )