Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmds] Show usage on bad options to mount command #1666

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions elkscmd/sys_utils/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ static void show(void)
show_mount(i);
}

static void usage(void)
static int usage(void)
{
errmsg("usage: mount [-a][-q][-t type] [-o ro|remount,{rw|ro}] <device> <directory>\n");
return 1;
}

int main(int argc, char **argv)
Expand Down Expand Up @@ -133,8 +134,7 @@ int main(int argc, char **argv)

case 'o':
if ((argc <= 0) || (**argv == '-')) {
errmsg("mount: missing option string\n");
return 1;
return usage();
}

option = *argv++;
Expand All @@ -145,15 +145,13 @@ int main(int argc, char **argv)
else if (!strcmp(option, "remount,ro"))
flags |= MS_REMOUNT|MS_RDONLY;
else {
errmsg("mount: bad option string\n");
return 1;
return usage();
}
argc--;
break;

default:
errmsg("mount: unknown option\n");
return 1;
return usage();
}
}

Expand All @@ -163,8 +161,7 @@ int main(int argc, char **argv)
}

if (argc != 2) {
usage();
return 1;
return usage();
}

if (flags == 0 && type == 0)
Expand Down