2023-11-20 02:51:48

by NeilBrown

[permalink] [raw]
Subject: [PATCH nfs-utils] exportfs: remove warning if neither subtree_check or no_subtree_check is given


This warning was only ever intended as a transitional aid.
It doesn't serve any purpose any longer. Let's remove it.

Also clean up some white-space issues.

Signed-off-by: NeilBrown <[email protected]>
---
support/export/export.c | 2 +-
support/export/xtab.c | 2 +-
support/include/nfslib.h | 2 +-
support/nfs/exports.c | 43 +++++++++++++++++-----------------------
4 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/support/export/export.c b/support/export/export.c
index 3e48c42def19..100912cb29c3 100644
--- a/support/export/export.c
+++ b/support/export/export.c
@@ -119,7 +119,7 @@ export_read(char *fname, int ignore_hosts)
int reexport_found = 0;

setexportent(fname, "r");
- while ((eep = getexportent(0,1)) != NULL) {
+ while ((eep = getexportent(0)) != NULL) {
exp = export_lookup(eep->e_hostname, eep->e_path, ignore_hosts);
if (!exp) {
if (export_create(eep, 0))
diff --git a/support/export/xtab.c b/support/export/xtab.c
index e210ca99d574..282f15bc79cd 100644
--- a/support/export/xtab.c
+++ b/support/export/xtab.c
@@ -47,7 +47,7 @@ xtab_read(char *xtab, char *lockfn, int is_export)
setexportent(xtab, "r");
if (is_export == 1)
v4root_needed = 1;
- while ((xp = getexportent(is_export==0, 0)) != NULL) {
+ while ((xp = getexportent(is_export==0)) != NULL) {
if (!(exp = export_lookup(xp->e_hostname, xp->e_path, is_export != 1)) &&
!(exp = export_create(xp, is_export!=1))) {
if(xp->e_hostname) {
diff --git a/support/include/nfslib.h b/support/include/nfslib.h
index bdbde78d9ebd..eff2a486307f 100644
--- a/support/include/nfslib.h
+++ b/support/include/nfslib.h
@@ -111,7 +111,7 @@ struct rmtabent {
* configuration file parsing
*/
void setexportent(char *fname, char *type);
-struct exportent * getexportent(int,int);
+struct exportent * getexportent(int);
void secinfo_show(FILE *fp, struct exportent *ep);
void xprtsecinfo_show(FILE *fp, struct exportent *ep);
void putexportent(struct exportent *xep);
diff --git a/support/nfs/exports.c b/support/nfs/exports.c
index 15dc574cc21a..a6816e60d62e 100644
--- a/support/nfs/exports.c
+++ b/support/nfs/exports.c
@@ -59,7 +59,7 @@ static int *squids = NULL, nsquids = 0,

static int getexport(char *exp, int len);
static int getpath(char *path, int len);
-static int parseopts(char *cp, struct exportent *ep, int warn, int *had_subtree_opt_ptr);
+static int parseopts(char *cp, struct exportent *ep, int *had_subtree_opt_ptr);
static int parsesquash(char *list, int **idp, int *lenp, char **ep);
static int parsenum(char **cpp);
static void freesquash(void);
@@ -109,7 +109,7 @@ static void init_exportent (struct exportent *ee, int fromkernel)
}

struct exportent *
-getexportent(int fromkernel, int fromexports)
+getexportent(int fromkernel)
{
static struct exportent ee, def_ee;
char exp[512], *hostname;
@@ -147,7 +147,7 @@ getexportent(int fromkernel, int fromexports)
* we're not reading from the kernel.
*/
if (exp[0] == '-' && !fromkernel) {
- if (parseopts(exp + 1, &def_ee, 0, &has_default_subtree_opts) < 0)
+ if (parseopts(exp + 1, &def_ee, &has_default_subtree_opts) < 0)
return NULL;

has_default_opts = 1;
@@ -185,20 +185,20 @@ getexportent(int fromkernel, int fromexports)
}
ee.e_hostname = xstrdup(hostname);

- if (parseopts(opt, &ee, fromexports && !has_default_subtree_opts, NULL) < 0) {
- if(ee.e_hostname)
- {
- xfree(ee.e_hostname);
- ee.e_hostname=NULL;
- }
- if(ee.e_uuid)
- {
- xfree(ee.e_uuid);
- ee.e_uuid=NULL;
- }
+ if (parseopts(opt, &ee, NULL) < 0) {
+ if(ee.e_hostname)
+ {
+ xfree(ee.e_hostname);
+ ee.e_hostname=NULL;
+ }
+ if(ee.e_uuid)
+ {
+ xfree(ee.e_uuid);
+ ee.e_uuid=NULL;
+ }

return NULL;
- }
+ }
/* resolve symlinks */
if (realpath(ee.e_path, rpath) != NULL) {
rpath[sizeof (rpath) - 1] = '\0';
@@ -433,7 +433,7 @@ mkexportent(char *hname, char *path, char *options)
}
strncpy(ee.e_path, path, sizeof (ee.e_path));
ee.e_path[sizeof (ee.e_path) - 1] = '\0';
- if (parseopts(options, &ee, 0, NULL) < 0)
+ if (parseopts(options, &ee, NULL) < 0)
return NULL;
return &ee;
}
@@ -441,7 +441,7 @@ mkexportent(char *hname, char *path, char *options)
int
updateexportent(struct exportent *eep, char *options)
{
- if (parseopts(options, eep, 0, NULL) < 0)
+ if (parseopts(options, eep, NULL) < 0)
return 0;
return 1;
}
@@ -632,7 +632,7 @@ void fix_pseudoflavor_flags(struct exportent *ep)
* Parse option string pointed to by cp and set mount options accordingly.
*/
static int
-parseopts(char *cp, struct exportent *ep, int warn, int *had_subtree_opt_ptr)
+parseopts(char *cp, struct exportent *ep, int *had_subtree_opt_ptr)
{
int had_subtree_opt = 0;
char *flname = efname?efname:"command line";
@@ -852,13 +852,6 @@ bad_option:
ep->e_nsqgids = nsqgids;

out:
- if (warn && !had_subtree_opt)
- xlog(L_WARNING, "%s [%d]: Neither 'subtree_check' or 'no_subtree_check' specified for export \"%s:%s\".\n"
- " Assuming default behaviour ('no_subtree_check').\n"
- " NOTE: this default has changed since nfs-utils version 1.0.x\n",
-
- flname, flline,
- ep->e_hostname, ep->e_path);
if (had_subtree_opt_ptr)
*had_subtree_opt_ptr = had_subtree_opt;

--
2.42.0


2023-11-29 12:33:44

by Steve Dickson

[permalink] [raw]
Subject: Re: [PATCH nfs-utils] exportfs: remove warning if neither subtree_check or no_subtree_check is given



On 11/19/23 9:51 PM, NeilBrown wrote:
>
> This warning was only ever intended as a transitional aid.
> It doesn't serve any purpose any longer. Let's remove it.
>
> Also clean up some white-space issues.
>
> Signed-off-by: NeilBrown <[email protected]>
Committed... (tag: nfs-utils-2-7-1-rc1)

steved
> ---
> support/export/export.c | 2 +-
> support/export/xtab.c | 2 +-
> support/include/nfslib.h | 2 +-
> support/nfs/exports.c | 43 +++++++++++++++++-----------------------
> 4 files changed, 21 insertions(+), 28 deletions(-)
>
> diff --git a/support/export/export.c b/support/export/export.c
> index 3e48c42def19..100912cb29c3 100644
> --- a/support/export/export.c
> +++ b/support/export/export.c
> @@ -119,7 +119,7 @@ export_read(char *fname, int ignore_hosts)
> int reexport_found = 0;
>
> setexportent(fname, "r");
> - while ((eep = getexportent(0,1)) != NULL) {
> + while ((eep = getexportent(0)) != NULL) {
> exp = export_lookup(eep->e_hostname, eep->e_path, ignore_hosts);
> if (!exp) {
> if (export_create(eep, 0))
> diff --git a/support/export/xtab.c b/support/export/xtab.c
> index e210ca99d574..282f15bc79cd 100644
> --- a/support/export/xtab.c
> +++ b/support/export/xtab.c
> @@ -47,7 +47,7 @@ xtab_read(char *xtab, char *lockfn, int is_export)
> setexportent(xtab, "r");
> if (is_export == 1)
> v4root_needed = 1;
> - while ((xp = getexportent(is_export==0, 0)) != NULL) {
> + while ((xp = getexportent(is_export==0)) != NULL) {
> if (!(exp = export_lookup(xp->e_hostname, xp->e_path, is_export != 1)) &&
> !(exp = export_create(xp, is_export!=1))) {
> if(xp->e_hostname) {
> diff --git a/support/include/nfslib.h b/support/include/nfslib.h
> index bdbde78d9ebd..eff2a486307f 100644
> --- a/support/include/nfslib.h
> +++ b/support/include/nfslib.h
> @@ -111,7 +111,7 @@ struct rmtabent {
> * configuration file parsing
> */
> void setexportent(char *fname, char *type);
> -struct exportent * getexportent(int,int);
> +struct exportent * getexportent(int);
> void secinfo_show(FILE *fp, struct exportent *ep);
> void xprtsecinfo_show(FILE *fp, struct exportent *ep);
> void putexportent(struct exportent *xep);
> diff --git a/support/nfs/exports.c b/support/nfs/exports.c
> index 15dc574cc21a..a6816e60d62e 100644
> --- a/support/nfs/exports.c
> +++ b/support/nfs/exports.c
> @@ -59,7 +59,7 @@ static int *squids = NULL, nsquids = 0,
>
> static int getexport(char *exp, int len);
> static int getpath(char *path, int len);
> -static int parseopts(char *cp, struct exportent *ep, int warn, int *had_subtree_opt_ptr);
> +static int parseopts(char *cp, struct exportent *ep, int *had_subtree_opt_ptr);
> static int parsesquash(char *list, int **idp, int *lenp, char **ep);
> static int parsenum(char **cpp);
> static void freesquash(void);
> @@ -109,7 +109,7 @@ static void init_exportent (struct exportent *ee, int fromkernel)
> }
>
> struct exportent *
> -getexportent(int fromkernel, int fromexports)
> +getexportent(int fromkernel)
> {
> static struct exportent ee, def_ee;
> char exp[512], *hostname;
> @@ -147,7 +147,7 @@ getexportent(int fromkernel, int fromexports)
> * we're not reading from the kernel.
> */
> if (exp[0] == '-' && !fromkernel) {
> - if (parseopts(exp + 1, &def_ee, 0, &has_default_subtree_opts) < 0)
> + if (parseopts(exp + 1, &def_ee, &has_default_subtree_opts) < 0)
> return NULL;
>
> has_default_opts = 1;
> @@ -185,20 +185,20 @@ getexportent(int fromkernel, int fromexports)
> }
> ee.e_hostname = xstrdup(hostname);
>
> - if (parseopts(opt, &ee, fromexports && !has_default_subtree_opts, NULL) < 0) {
> - if(ee.e_hostname)
> - {
> - xfree(ee.e_hostname);
> - ee.e_hostname=NULL;
> - }
> - if(ee.e_uuid)
> - {
> - xfree(ee.e_uuid);
> - ee.e_uuid=NULL;
> - }
> + if (parseopts(opt, &ee, NULL) < 0) {
> + if(ee.e_hostname)
> + {
> + xfree(ee.e_hostname);
> + ee.e_hostname=NULL;
> + }
> + if(ee.e_uuid)
> + {
> + xfree(ee.e_uuid);
> + ee.e_uuid=NULL;
> + }
>
> return NULL;
> - }
> + }
> /* resolve symlinks */
> if (realpath(ee.e_path, rpath) != NULL) {
> rpath[sizeof (rpath) - 1] = '\0';
> @@ -433,7 +433,7 @@ mkexportent(char *hname, char *path, char *options)
> }
> strncpy(ee.e_path, path, sizeof (ee.e_path));
> ee.e_path[sizeof (ee.e_path) - 1] = '\0';
> - if (parseopts(options, &ee, 0, NULL) < 0)
> + if (parseopts(options, &ee, NULL) < 0)
> return NULL;
> return &ee;
> }
> @@ -441,7 +441,7 @@ mkexportent(char *hname, char *path, char *options)
> int
> updateexportent(struct exportent *eep, char *options)
> {
> - if (parseopts(options, eep, 0, NULL) < 0)
> + if (parseopts(options, eep, NULL) < 0)
> return 0;
> return 1;
> }
> @@ -632,7 +632,7 @@ void fix_pseudoflavor_flags(struct exportent *ep)
> * Parse option string pointed to by cp and set mount options accordingly.
> */
> static int
> -parseopts(char *cp, struct exportent *ep, int warn, int *had_subtree_opt_ptr)
> +parseopts(char *cp, struct exportent *ep, int *had_subtree_opt_ptr)
> {
> int had_subtree_opt = 0;
> char *flname = efname?efname:"command line";
> @@ -852,13 +852,6 @@ bad_option:
> ep->e_nsqgids = nsqgids;
>
> out:
> - if (warn && !had_subtree_opt)
> - xlog(L_WARNING, "%s [%d]: Neither 'subtree_check' or 'no_subtree_check' specified for export \"%s:%s\".\n"
> - " Assuming default behaviour ('no_subtree_check').\n"
> - " NOTE: this default has changed since nfs-utils version 1.0.x\n",
> -
> - flname, flline,
> - ep->e_hostname, ep->e_path);
> if (had_subtree_opt_ptr)
> *had_subtree_opt_ptr = had_subtree_opt;
>