On 2/23/20 10:43 PM, Jianhong.Yin wrote:
> From: Jianhong Yin <[email protected]>
>
> 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 <[email protected]>
Committed...
steved.
> ---
> utils/mount/mount.c | 10 +++++-----
> 1 file 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...
> */
>