diff options
author | Jianhong Yin <yin-jianhong@163.com> | 2020-02-27 10:39:22 -0500 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2020-02-27 10:39:22 -0500 |
commit | f9a7d4a9cc4e359f4f706bb85d01ba4324eac8b6 (patch) | |
tree | 8f7cb577bdc933c5a831ab20ea44d1218247e6fa | |
parent | 10589ca13ade4967ed46be2b8a69aa9cc9d017ac (diff) | |
download | nfs-utils-f9a7d4a9cc4e359f4f706bb85d01ba4324eac8b6.tar.gz |
mount.c: fix args parse error
argc number checking should be after getopt_long(), otherwise
we'll get follow result:
'''
~]# mount.nfs -V
usage: mount.nfs remotetarget dir [-rvVwfnsh] [-o nfsoptions]
options:
-r Mount file system readonly
-v Verbose
-V Print version
-w Mount file system read-write
-f Fake mount, do not actually mount
-n Do not update /etc/mtab
-s Tolerate sloppy mount options rather than fail
-h Print this help
nfsoptions Refer to mount.nfs(8) or nfs(5)
'''
after fix:
'''
~]# mount.nfs -V
mount.nfs: (linux nfs-utils 2.4.3)
'''
Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | utils/mount/mount.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/utils/mount/mount.c b/utils/mount/mount.c index 2be3dc2f..b98f9e00 100644 --- a/utils/mount/mount.c +++ b/utils/mount/mount.c @@ -393,11 +393,6 @@ int main(int argc, char *argv[]) if(!strncmp(progname, "umount", strlen("umount"))) exit(nfsumount(argc, argv)); - if ((argc < 3)) { - mount_usage(); - exit(EX_USAGE); - } - mount_config_init(progname); while ((c = getopt_long(argc, argv, "rvVwfno:hs", @@ -437,6 +432,11 @@ int main(int argc, char *argv[]) } } + if ((argc < 3)) { + mount_usage(); + exit(EX_USAGE); + } + /* * Extra non-option words at the end are bogus... */ |