2021-02-01 23:04:28

by Steve Dickson

[permalink] [raw]
Subject: [PATCH 1/2] mountd: Cleanup how config options are read in

Signed-off-by: Steve Dickson <[email protected]>
---
utils/mountd/mountd.c | 49 +++++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c
index 07bcdc5a..988e51c5 100644
--- a/utils/mountd/mountd.c
+++ b/utils/mountd/mountd.c
@@ -661,30 +661,17 @@ get_exportlist(void)
return elist;
}

-int
-main(int argc, char **argv)
+int vers;
+int port = 0;
+int descriptors = 0;
+
+inline static void
+read_mount_conf(char **argv)
{
- char *progname;
char *s;
- unsigned int listeners = 0;
- int foreground = 0;
- int port = 0;
- int descriptors = 0;
- int c;
- int vers;
- struct sigaction sa;
- struct rlimit rlim;
-
- /* Set the basename */
- if ((progname = strrchr(argv[0], '/')) != NULL)
- progname++;
- else
- progname = argv[0];
-
- /* Initialize logging. */
- xlog_open(progname);

conf_init_file(NFS_CONFFILE);
+
xlog_from_conffile("mountd");
manage_gids = conf_get_bool("mountd", "manage-gids", manage_gids);
descriptors = conf_get_num("mountd", "descriptors", descriptors);
@@ -714,7 +701,29 @@ main(int argc, char **argv)
else
NFSCTL_VERUNSET(nfs_version, vers);
}
+}
+
+int
+main(int argc, char **argv)
+{
+ char *progname;
+ unsigned int listeners = 0;
+ int foreground = 0;
+ int c;
+ struct sigaction sa;
+ struct rlimit rlim;
+
+ /* Set the basename */
+ if ((progname = strrchr(argv[0], '/')) != NULL)
+ progname++;
+ else
+ progname = argv[0];
+
+ /* Initialize logging. */
+ xlog_open(progname);

+ /* Read in config setting */
+ read_mount_conf(argv);

/* Parse the command line options and arguments. */
opterr = 0;
--
2.29.2


2021-02-02 17:13:05

by Steve Dickson

[permalink] [raw]
Subject: Re: [PATCH 1/2] mountd: Cleanup how config options are read in



On 2/1/21 6:01 PM, Steve Dickson wrote:
> Signed-off-by: Steve Dickson <[email protected]>
Committed... (tag: nfs-utils-2-5-3-rc5)

steved.
> ---
> utils/mountd/mountd.c | 49 +++++++++++++++++++++++++------------------
> 1 file changed, 29 insertions(+), 20 deletions(-)
>
> diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c
> index 07bcdc5a..988e51c5 100644
> --- a/utils/mountd/mountd.c
> +++ b/utils/mountd/mountd.c
> @@ -661,30 +661,17 @@ get_exportlist(void)
> return elist;
> }
>
> -int
> -main(int argc, char **argv)
> +int vers;
> +int port = 0;
> +int descriptors = 0;
> +
> +inline static void
> +read_mount_conf(char **argv)
> {
> - char *progname;
> char *s;
> - unsigned int listeners = 0;
> - int foreground = 0;
> - int port = 0;
> - int descriptors = 0;
> - int c;
> - int vers;
> - struct sigaction sa;
> - struct rlimit rlim;
> -
> - /* Set the basename */
> - if ((progname = strrchr(argv[0], '/')) != NULL)
> - progname++;
> - else
> - progname = argv[0];
> -
> - /* Initialize logging. */
> - xlog_open(progname);
>
> conf_init_file(NFS_CONFFILE);
> +
> xlog_from_conffile("mountd");
> manage_gids = conf_get_bool("mountd", "manage-gids", manage_gids);
> descriptors = conf_get_num("mountd", "descriptors", descriptors);
> @@ -714,7 +701,29 @@ main(int argc, char **argv)
> else
> NFSCTL_VERUNSET(nfs_version, vers);
> }
> +}
> +
> +int
> +main(int argc, char **argv)
> +{
> + char *progname;
> + unsigned int listeners = 0;
> + int foreground = 0;
> + int c;
> + struct sigaction sa;
> + struct rlimit rlim;
> +
> + /* Set the basename */
> + if ((progname = strrchr(argv[0], '/')) != NULL)
> + progname++;
> + else
> + progname = argv[0];
> +
> + /* Initialize logging. */
> + xlog_open(progname);
>
> + /* Read in config setting */
> + read_mount_conf(argv);
>
> /* Parse the command line options and arguments. */
> opterr = 0;
>