mountd.nfs: Better error diagnostics for the mount command (take 2)
Subsystems (2)
cover mountd.nfs: Better error diagnostics for the mount command (take 2)
[I incorporated the comments from the code review of the previous patches]
The following two patches add better error diagnostics when invalid protocol version are given and when the network protocol can not be determined.
Steve Dickson (2):
mount: silently fails when bad option values are given mount.nfs: silently fails when the network protocol is not found
utils/mount/network.c | 39 ++++++++++++++++++++++++++++++++++----- utils/mount/nfsumount.c | 4 +--- utils/mount/stropts.c | 16 +++++++++++----- 3 files changed, 46 insertions(+), 13 deletions(-)
PATCH 1/2 mount: silently fails when bad option values are given
mount.nfs should not only fail when an invalid option values are supplied (as it does), it should also print a diagnostic message identifying the problem
--- utils/mount/network.c | 20 ++++++++++++++++++-- utils/mount/nfsumount.c | 4 +--- 2 files changed, 19 insertions(+), 5 deletions(-)
utils/mount/network.c +18 -2
@@ -1212,6 +1212,8 @@ nfs_nfs_program(struct mount_options *options, unsigned long *program)return 1 ; }case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'nfsprog=' option" ), + progname);return 0 ; }
@@ -1251,9 +1253,12 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version) }return 0 ;case PO_NOT_FOUND : -nfs_error (_ ("%s: option parsing error\n" ), +nfs_error (_ ("%s: parsing error on 'vers=' option\n" ), progname); +return 0 ;case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'vers=' option" ), + progname);return 0 ; }case 4 :/* nfsvers */
@@ -1265,9 +1270,12 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version) }return 0 ;case PO_NOT_FOUND : -nfs_error (_ ("%s: option parsing error\n" ), +nfs_error (_ ("%s: parsing error on 'nfsvers=' option\n" ), progname); +return 0 ;case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'nfsvers=' option" ), + progname);return 0 ; } }
@@ -1336,6 +1344,8 @@ nfs_nfs_port(struct mount_options *options, unsigned long *port)return 1 ; }case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'port=' option" ), + progname);return 0 ; }
@@ -1423,6 +1433,8 @@ nfs_mount_program(struct mount_options *options, unsigned long *program)return 1 ; }case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'mountprog=' option" ), + progname);return 0 ; }
@@ -1452,6 +1464,8 @@ nfs_mount_version(struct mount_options *options, unsigned long *version)return 1 ; }case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'mountvers=' option" ), + progname);return 0 ; }
@@ -1510,6 +1524,8 @@ nfs_mount_port(struct mount_options *options, unsigned long *port)return 1 ; }case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'mountport=' option" ), + progname);return 0 ; }
utils/mount/nfsumount.c +1 -3
@@ -179,10 +179,8 @@ static int nfs_umount_do_umnt(struct mount_options *options,struct pmap nfs_pmap, mnt_pmap;sa_family_t family; -if (!nfs_options2pmap (options, &nfs_pmap, &mnt_pmap)) { -nfs_error (_ ("%s: bad mount options" ), progname); +if (!nfs_options2pmap (options, &nfs_pmap, &mnt_pmap))return EX_FAIL ; - }/* Skip UMNT call for vers=4 mounts */ if (nfs_pmap.pm_vers ==4 )
Signature · 1 line
1.6.6.1
Re: [PATCH 1/2] mount: silently fails when bad option values are given
Quoted 15 lines · Steve Dickson
mount.nfs should not only fail when an invalid option values are supplied (as it does), it should also print a diagnostic message identifying the problem
Signed-off-by Steve Dickson<[email protected]>--- utils/mount/network.c | 20 ++++++++++++++++++-- utils/mount/nfsumount.c | 4 +--- 2 files changed, 19 insertions(+), 5 deletions(-)utils/mount/network.c +0
-0
utils/mount/network.c nfs_nfs_program(struct mount_options *options, unsigned long *program) · line 1213
Quoted 2 lines
utils/mount/network.c +0
-0@@ -1212,6 +1212,8 @@ nfs_nfs_program(struct mount_options *options, unsigned long *program)return 1 ; }
Another missed fall-through.
Quoted 9 lines
utils/mount/network.c +2
-0case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'nfsprog=' option" ), + progname);return 0 ; }@@ -1251,9 +1253,12 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version) }return 0 ;
utils/mount/network.c nfs_nfs_version(struct mount_options *options, unsigned long *version) · line 1263
Quoted 10 lines
utils/mount/network.c +4
-1case PO_NOT_FOUND : -nfs_error (_ ("%s: option parsing error\n" ), +nfs_error (_ ("%s: parsing error on 'vers=' option\n" ), progname); +return 0 ;case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'vers=' option" ), + progname);return 0 ; }
What I meant before is that, with this new code, this error diagnostic is displayed for "vers=booger" but not for "vers=12". I think it should be displayed in both cases.
Quoted 16 lines
utils/mount/network.c +4
-1case 4 :/* nfsvers */ @@ -1265,9 +1270,12 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version) }return 0 ;case PO_NOT_FOUND : -nfs_error (_ ("%s: option parsing error\n" ), +nfs_error (_ ("%s: parsing error on 'nfsvers=' option\n" ), progname); +return 0 ;case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'nfsvers=' option" ), + progname);return 0 ; } }
utils/mount/network.c nfs_nfs_port(struct mount_options *options, unsigned long *port) · line 1345
Quoted 2 lines
utils/mount/network.c +0
-0@@ -1336,6 +1344,8 @@ nfs_nfs_port(struct mount_options *options, unsigned long *port)return 1 ; }
Another missed fall-through.
utils/mount/network.c nfs_nfs_port(struct mount_options *options, unsigned long *port) · line 1350
Quoted 5 lines
utils/mount/network.c +2
-0case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'port=' option" ), + progname);return 0 ; }
And here, an error diagnostic is displayed for "port=crikey" but not for "port=-17".
utils/mount/network.c nfs_mount_program(struct mount_options *options, unsigned long *program) · line 1434
Quoted 3 lines
utils/mount/network.c +0
-0@@ -1423,6 +1433,8 @@ nfs_mount_program(struct mount_options *options, unsigned long *program)return 1 ; }
Another missed fall-through.
utils/mount/network.c nfs_mount_version(struct mount_options *options, unsigned long *version) · line 1465
Quoted 9 lines
utils/mount/network.c +2
-0case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'mountprog=' option" ), + progname);return 0 ; }@@ -1452,6 +1464,8 @@ nfs_mount_version(struct mount_options *options, unsigned long *version)return 1 ; }
Ditto.
utils/mount/network.c nfs_mount_port(struct mount_options *options, unsigned long *port) · line 1525
Quoted 9 lines
utils/mount/network.c +2
-0case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'mountvers=' option" ), + progname);return 0 ; }@@ -1510,6 +1524,8 @@ nfs_mount_port(struct mount_options *options, unsigned long *port)return 1 ; }
Ditto.
Quoted 22 lines
utils/mount/network.c +2
-0case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'mountport=' option" ), + progname);return 0 ; }utils/mount/nfsumount.c +1
-3@@ -179,10 +179,8 @@ static int nfs_umount_do_umnt(struct mount_options *options,struct pmap nfs_pmap, mnt_pmap;sa_family_t family; -if (!nfs_options2pmap (options,&nfs_pmap,&mnt_pmap)) { -nfs_error (_ ("%s: bad mount options" ), progname); +if (!nfs_options2pmap (options,&nfs_pmap,&mnt_pmap))return EX_FAIL ; - }/* Skip UMNT call for vers=4 mounts */ if (nfs_pmap.pm_vers ==4 )
Re: [PATCH 1/2] mount: silently fails when bad option values are given
Quoted 11 lines · Chuck Lever
Quoted 10 lines · Steve Dickson
mount.nfs should not only fail when an invalid option values are supplied (as it does), it should also print a diagnostic message identifying the problem
Signed-off-by Steve Dickson<[email protected]>--- utils/mount/network.c | 20 ++++++++++++++++++-- utils/mount/nfsumount.c | 4 +--- 2 files changed, 19 insertions(+), 5 deletions(-)
Quoted 10 lines
utils/mount/network.c nfs_nfs_program(struct mount_options *options, · line 1214
Quoted 8 lines
utils/mount/network.c +0
-0@@ -1212,6 +1212,8 @@ nfs_nfs_program(struct mount_options *options, unsigned long *program)return 1 ; }Another missed fall-through.
I realized this.. but if tmp <= 0, then the given value is invalid so an error message should be displayed.
Quoted 17 lines
Quoted 17 lines
utils/mount/network.c +4
-1case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'nfsprog=' option" ), + progname);return 0 ; }@@ -1251,9 +1253,12 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version) }return 0 ;case PO_NOT_FOUND : -nfs_error (_ ("%s: option parsing error\n" ), +nfs_error (_ ("%s: parsing error on 'vers=' option\n" ), progname); +return 0 ;case PO_BAD_VALUE :
Quoted 8 lines
utils/mount/network.c nfs_nfs_version(struct mount_options *options, unsigned long *version) · line 1263
Quoted 4 lines
utils/mount/network.c +2
-0+nfs_error (_ ("%s: invalid value for 'vers=' option" ), + progname);return 0 ; }What I meant before is that, with this new code, this error diagnostic is displayed for "vers=booger" but not for "vers=12". I think it should be displayed in both cases.
ah... This is not only routine where PO_FOUND is returned but the value is invalid...
Quoted 15 lines
Quoted 15 lines
case 4: /* nfsvers */utils/mount/network.c +4
-1@@ -1265,9 +1270,12 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version) }return 0 ;case PO_NOT_FOUND : -nfs_error (_ ("%s: option parsing error\n" ), +nfs_error (_ ("%s: parsing error on 'nfsvers=' option\n" ), progname); +return 0 ;case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'nfsvers=' option" ), + progname);return 0 ;
Quoted 8 lines
utils/mount/network.c nfs_nfs_port(struct mount_options *options, · line 1346
Quoted 6 lines
utils/mount/network.c +0
-0}}utils/mount/network.c +0
-0@@ -1336,6 +1344,8 @@ nfs_nfs_port(struct mount_options *options, unsigned long *port)return 1 ; }Another missed fall-through.
again known...
Quoted 10 lines
utils/mount/network.c nfs_nfs_port(struct mount_options *options, unsigned long *port) · line 1350
Quoted 6 lines
utils/mount/network.c +2
-0case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'port=' option" ), + progname);return 0 ; }And here, an error diagnostic is displayed for "port=crikey" but not for "port=-17".
Quoted 6 lines
utils/mount/network.c nfs_mount_program(struct mount_options *options, · line 1435
Quoted 4 lines
utils/mount/network.c +0
-0@@ -1423,6 +1433,8 @@ nfs_mount_program(struct mount_options *options, unsigned long *program)return 1 ; }Another missed fall-through.
Same as above...
Quoted 7 lines
Quoted 7 lines
utils/mount/network.c +2
-0case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'mountprog=' option" ), + progname);return 0 ; }
Quoted 6 lines
utils/mount/network.c nfs_mount_version(struct mount_options *options, · line 1466
Quoted 4 lines
utils/mount/network.c +0
-0@@ -1452,6 +1464,8 @@ nfs_mount_version(struct mount_options *options, unsigned long *version)return 1 ; }Ditto.
Ditto... :-)
Quoted 7 lines
Quoted 7 lines
utils/mount/network.c +2
-0case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'mountvers=' option" ), + progname);return 0 ; }
Quoted 6 lines
utils/mount/network.c nfs_mount_port(struct mount_options *options, · line 1526
Quoted 4 lines
utils/mount/network.c +0
-0@@ -1510,6 +1524,8 @@ nfs_mount_port(struct mount_options *options, unsigned long *port)return 1 ; }Ditto.
Double Ditto.. :-)
steved.
Quoted 25 lines
Quoted 24 lines
utils/mount/network.c +2
-0case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'mountport=' option" ), + progname);return 0 ; }utils/mount/nfsumount.c +1
-3@@ -179,10 +179,8 @@ static int nfs_umount_do_umnt(structmount_options *options, struct pmap nfs_pmap, mnt_pmap;sa_family_t family; -if (!nfs_options2pmap (options,&nfs_pmap,&mnt_pmap)) { -nfs_error (_ ("%s: bad mount options" ), progname); +if (!nfs_options2pmap (options,&nfs_pmap,&mnt_pmap))return EX_FAIL ; - }/* Skip UMNT call for vers=4 mounts */ if (nfs_pmap.pm_vers == 4)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 1/2] mount: silently fails when bad option values are given
Quoted 52 lines · Steve Dickson
Quoted 11 lines · Chuck Lever
Quoted 10 lines · Steve Dickson
mount.nfs should not only fail when an invalid option values are supplied (as it does), it should also print a diagnostic message identifying the problem
Signed-off-by Steve Dickson<[email protected]>--- utils/mount/network.c | 20 ++++++++++++++++++-- utils/mount/nfsumount.c | 4 +--- 2 files changed, 19 insertions(+), 5 deletions(-)Quoted 10 lines
utils/mount/network.c nfs_nfs_program(struct mount_options *options, · line 1214
Quoted 8 lines
utils/mount/network.c +0
-0@@ -1212,6 +1212,8 @@ nfs_nfs_program(struct mount_options *options, unsigned long *program)return 1 ; }Another missed fall-through.
I realized this.. but if tmp<= 0, then the given value is invalid so an error message should be displayed.
Quoted 17 lines
Quoted 17 lines
utils/mount/network.c +4
-1case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'nfsprog=' option" ), + progname);return 0 ; }@@ -1251,9 +1253,12 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version) }return 0 ;case PO_NOT_FOUND : -nfs_error (_ ("%s: option parsing error\n" ), +nfs_error (_ ("%s: parsing error on 'vers=' option\n" ), progname); +return 0 ;case PO_BAD_VALUE :Quoted 8 lines
utils/mount/network.c nfs_nfs_version(struct mount_options *options, unsigned long *version) · line 1263
Quoted 4 lines
utils/mount/network.c +2
-0+nfs_error (_ ("%s: invalid value for 'vers=' option" ), + progname);return 0 ; }What I meant before is that, with this new code, this error diagnostic is displayed for "vers=booger" but not for "vers=12". I think it should be displayed in both cases.
Quoted 2 lines
ah... This is not only routine where
PO_FOUNDis returned but the value is invalid...
PO_FOUND here means the option was a keyword/value pair, and the value was numeric (but not necessarily a legal value for this option, so the caller has to do some range checking). PO_BAD_VALUE means the option was a keyword/value pair, and the value wasn't numeric, and is thus definitely not valid.
PO_NOT_FOUND probably means the option was found, but the option isn't specified as a keyword/value; ie. "vers" by itself rather than "vers=n".
(Although you should check that, my recollection may be rusty). Also
invalid, and should be reported.
Or, PO_NOT_FOUND could mean the option wasn't found at all, but since po_rightmost() found it, that would be a software bug in this case.
Re: [PATCH 1/2] mount: silently fails when bad option values are given
Quoted 62 lines · Chuck Lever
Quoted 52 lines · Steve Dickson
Quoted 11 lines · Chuck Lever
Quoted 10 lines · Steve Dickson
mount.nfs should not only fail when an invalid option values are supplied (as it does), it should also print a diagnostic message identifying the problem
Signed-off-by Steve Dickson<[email protected]>--- utils/mount/network.c | 20 ++++++++++++++++++-- utils/mount/nfsumount.c | 4 +--- 2 files changed, 19 insertions(+), 5 deletions(-)Quoted 10 lines
utils/mount/network.c nfs_nfs_program(struct mount_options *options, · line 1214
Quoted 8 lines
utils/mount/network.c +0
-0@@ -1212,6 +1212,8 @@ nfs_nfs_program(struct mount_options *options, unsigned long *program)return 1 ; }Another missed fall-through.
I realized this.. but if tmp<= 0, then the given value is invalid so an error message should be displayed.
Quoted 17 lines
Quoted 17 lines
utils/mount/network.c +4
-1case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'nfsprog=' option" ), + progname);return 0 ; }@@ -1251,9 +1253,12 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version) }return 0 ;case PO_NOT_FOUND : -nfs_error (_ ("%s: option parsing error\n" ), +nfs_error (_ ("%s: parsing error on 'vers=' option\n" ), progname); +return 0 ;case PO_BAD_VALUE :Quoted 8 lines
utils/mount/network.c nfs_nfs_version(struct mount_options *options, unsigned long *version) · line 1263
Quoted 4 lines
utils/mount/network.c +2
-0+nfs_error (_ ("%s: invalid value for 'vers=' option" ), + progname);return 0 ; }What I meant before is that, with this new code, this error diagnostic is displayed for "vers=booger" but not for "vers=12". I think it should be displayed in both cases.
Quoted 2 lines
ah... This is not only routine where
PO_FOUNDis returned but the value is invalid...
PO_FOUNDhere means the option was a keyword/value pair, and the value was numeric (but not necessarily a legal value for this option, so the caller has to do some range checking).PO_BAD_VALUEmeans the option was a keyword/value pair, and the value wasn't numeric, and is thus definitely not valid.
Quoted 7 lines
PO_NOT_FOUNDprobably means the option was found, but the option isn't specified as a keyword/value; ie. "vers" by itself rather than "vers=n".
(Although you should check that, my recollection may be rusty). Also
invalid, and should be reported.Or,
PO_NOT_FOUNDcould mean the option wasn't found at all, but sincepo_rightmost()found it, that would be a software bug in this case.
I believe I'm understanding the logic... Whether the given value is either a PO_BAD_VALUE (should be an integer and its not) or a value that is out of range (the PO_FOUND cause), the given value is still "invalid"...
PO_NOT_FOUND value is basically a parsing error and if its not recoverable as with some cases, we should generate a message...
So as long as we identify the above three cases and give a pointer to the incorrect option, I think that will be fine...
steved.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 1/2] mount: silently fails when bad option values are given
Quoted 77 lines · Steve Dickson
Quoted 62 lines · Chuck Lever
Quoted 52 lines · Steve Dickson
Quoted 11 lines · Chuck Lever
Quoted 10 lines · Steve Dickson
mount.nfs should not only fail when an invalid option values are supplied (as it does), it should also print a diagnostic message identifying the problem
Signed-off-by Steve Dickson<[email protected]>--- utils/mount/network.c | 20 ++++++++++++++++++-- utils/mount/nfsumount.c | 4 +--- 2 files changed, 19 insertions(+), 5 deletions(-)Quoted 10 lines
utils/mount/network.c nfs_nfs_program(struct mount_options *options, · line 1214
Quoted 8 lines
utils/mount/network.c +0
-0@@ -1212,6 +1212,8 @@ nfs_nfs_program(struct mount_options *options, unsigned long *program)return 1 ; }Another missed fall-through.
I realized this.. but if tmp<= 0, then the given value is invalid so an error message should be displayed.
Quoted 17 lines
Quoted 17 lines
utils/mount/network.c +4
-1case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'nfsprog=' option" ), + progname);return 0 ; }@@ -1251,9 +1253,12 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version) }return 0 ;case PO_NOT_FOUND : -nfs_error (_ ("%s: option parsing error\n" ), +nfs_error (_ ("%s: parsing error on 'vers=' option\n" ), progname); +return 0 ;case PO_BAD_VALUE :Quoted 8 lines
utils/mount/network.c nfs_nfs_version(struct mount_options *options, · line 1264
Quoted 4 lines
utils/mount/network.c +2
-0+nfs_error (_ ("%s: invalid value for 'vers=' option" ), + progname);return 0 ; }What I meant before is that, with this new code, this error diagnostic is displayed for "vers=booger" but not for "vers=12". I think it should be displayed in both cases.
Quoted 2 lines
ah... This is not only routine where
PO_FOUNDis returned but the value is invalid...
PO_FOUNDhere means the option was a keyword/value pair, and the value was numeric (but not necessarily a legal value for this option, so the caller has to do some range checking).PO_BAD_VALUEmeans the option was a keyword/value pair, and the value wasn't numeric, and is thus definitely not valid.Quoted 7 lines
PO_NOT_FOUNDprobably means the option was found, but the option isn't specified as a keyword/value; ie. "vers" by itself rather than "vers=n".
(Although you should check that, my recollection may be rusty). Also
invalid, and should be reported.Or,
PO_NOT_FOUNDcould mean the option wasn't found at all, but sincepo_rightmost()found it, that would be a software bug in this case.I believe I'm understanding the logic... Whether the given value is either a
PO_BAD_VALUE(should be an integer and its not) or a value that is out of range (thePO_FOUNDcause), the given value is still "invalid"...
Quoted 5 lines
PO_NOT_FOUNDvalue is basically a parsing error and if its not recoverable as with some cases, we should generate a message...So as long as we identify the above three cases and give a pointer to the incorrect option, I think that will be fine...
Agreed. At this point in nfs_nfs_version() and friends, though, I don't think there's any difference between any of these cases, so you might be OK with an even simpler patch that just does:
/*FALLTHROUGH*/
default:
nfs_error(_("%s: bad xxx option"), progname);What do you think?
Re: [PATCH 1/2] mount: silently fails when bad option values are given
Quoted 90 lines · Chuck Lever
Quoted 78 lines · Steve Dickson
Quoted 63 lines · Chuck Lever
Quoted 53 lines · Steve Dickson
Quoted 11 lines · Chuck Lever
Quoted 10 lines · Steve Dickson
mount.nfs should not only fail when an invalid option values are supplied (as it does), it should also print a diagnostic message identifying the problem
Signed-off-by Steve Dickson<[email protected]>--- utils/mount/network.c | 20 ++++++++++++++++++-- utils/mount/nfsumount.c | 4 +--- 2 files changed, 19 insertions(+), 5 deletions(-)Quoted 10 lines
utils/mount/network.c nfs_nfs_program(struct mount_options *options, · line 1214
Quoted 8 lines
utils/mount/network.c +0
-0@@ -1212,6 +1212,8 @@ nfs_nfs_program(struct mount_options *options, unsigned long *program)return 1 ; }Another missed fall-through.
I realized this.. but if tmp<= 0, then the given value is invalid so an error message should be displayed.
Quoted 18 lines
Quoted 18 lines
utils/mount/network.c +5
-1case PO_BAD_VALUE : +nfs_error (_ ("%s: invalid value for 'nfsprog=' option" ), + progname);return 0 ; }@@ -1251,9 +1253,12 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version) }return 0 ;case PO_NOT_FOUND : -nfs_error (_ ("%s: option parsing error\n" ), +nfs_error (_ ("%s: parsing error on 'vers=' option\n" ), progname); +return 0 ;case PO_BAD_VALUE : + nfs_error(_("%s: invalid value for 'vers=' option"),Quoted 8 lines
utils/mount/network.c nfs_nfs_version(struct mount_options *options, · line 1264
Quoted 3 lines
utils/mount/network.c +1
-0+ progname);return 0 ; }What I meant before is that, with this new code, this error diagnostic is displayed for "vers=booger" but not for "vers=12". I think it should
be displayed in both cases.Quoted 2 lines
ah... This is not only routine where
PO_FOUNDis returned but the value is invalid...
PO_FOUNDhere means the option was a keyword/value pair, and the value was numeric (but not necessarily a legal value for this option, so the caller has to do some range checking).PO_BAD_VALUEmeans the option was a keyword/value pair, and the value wasn't numeric, and is thus definitely not valid.Quoted 7 lines
PO_NOT_FOUNDprobably means the option was found, but the option isn't specified as a keyword/value; ie. "vers" by itself rather than "vers=n".
(Although you should check that, my recollection may be rusty). Also
invalid, and should be reported.Or,
PO_NOT_FOUNDcould mean the option wasn't found at all, but sincepo_rightmost()found it, that would be a software bug in this case.I believe I'm understanding the logic... Whether the given value is either a
PO_BAD_VALUE(should be an integer and its not) or a value that is out of range (thePO_FOUNDcause), the given value is still "invalid"...Quoted 6 lines
PO_NOT_FOUNDvalue is basically a parsing error and if its not recoverable as
with some cases, we should generate a message...So as long as we identify the above three cases and give a pointer to the incorrect option, I think that will be fine...
Agreed. At this point in
nfs_nfs_version()and friends, though, I don't think there's any difference between any of these cases, so you might be OK with an even simpler patch that just does:
Quoted 5 lines
/*FALLTHROUGH*/ default: nfs_error(_("%s: bad xxx option"), progname);What do you think?
Basically that's what I did... Please see the latest version...
steved.
P.S. Thanks for taking the time!!
PATCH 2/2 mount.nfs: silently fails when the network protocol is not found
In reply to Steve Dicksonmount.nfs should display some type of error diagnostics when the network protocol can not be determined.
--- utils/mount/network.c | 19 ++++++++++++++++--- utils/mount/stropts.c | 16 +++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-)
utils/mount/network.c +16 -3
@@ -1311,6 +1311,8 @@ nfs_nfs_protocol(struct mount_options *options, unsigned long *protocol)if (option !=NULL ) {if (!nfs_get_proto (option, &family, protocol)) { errno =EPROTONOSUPPORT ; +nfs_error (_ ("%s: Failed to find '%s' protocol" ), + progname, option);return 0 ; }return 1 ;
@@ -1399,8 +1401,13 @@ int nfs_nfs_proto_family(struct mount_options *options,case 2 :/* proto */ option =po_get (options,"proto" );if (option !=NULL && - !nfs_get_proto (option, &tmp_family, &protocol)) - goto out_err; + !nfs_get_proto (option, &tmp_family, &protocol)) { + +nfs_error (_ ("%s: Failed to find '%s' protocol" ), + progname, option); + errno =EPROTONOSUPPORT ; +return 0 ; + } }if (!nfs_verify_family (tmp_family))
@@ -1492,6 +1499,8 @@ nfs_mount_protocol(struct mount_options *options, unsigned long *protocol)if (option !=NULL ) {if (!nfs_get_proto (option, &family, protocol)) { errno =EPROTONOSUPPORT ; +nfs_error (_ ("%s: Failed to find '%s' protocol" ), + progname, option);return 0 ; }return 1 ;
@@ -1551,8 +1560,12 @@ int nfs_mount_proto_family(struct mount_options *options, option =po_get (options,"mountproto" );if (option !=NULL ) { -if (!nfs_get_proto (option, &tmp_family, &protocol)) +if (!nfs_get_proto (option, &tmp_family, &protocol)) { +nfs_error (_ ("%s: Failed to find '%s' protocol" ), + progname, option); + errno =EPROTONOSUPPORT ; goto out_err; + }if (!nfs_verify_family (tmp_family)) goto out_err; *family = tmp_family;
utils/mount/stropts.c +11 -5
@@ -538,7 +538,10 @@ nfs_rewrite_pmap_mount_options(struct mount_options *options)if (!nfs_construct_new_options (options, nfs_saddr, &nfs_pmap, mnt_saddr, &mnt_pmap)) { - errno =EINVAL ; +if (rpc_createerr.cf_stat ==RPC_UNKNOWNPROTO ) + errno =EPROTONOSUPPORT ; +else + errno =EINVAL ;return 0 ; }
@@ -586,18 +589,21 @@ static int nfs_do_mount_v3v2(struct nfsmount_info *mi, errno =ENOMEM ;return result; } - + errno =0 ;if (!nfs_append_addr_option (sap, salen, options)) { - errno =EINVAL ; +if (errno ==0 ) + errno =EINVAL ; goto out_fail; }if (!nfs_fix_mounthost_option (options, mi->hostname)) { - errno =EINVAL ; +if (errno ==0 ) + errno =EINVAL ; goto out_fail; }if (!mi->fake && !nfs_verify_lock_option (options)) { - errno =EINVAL ; +if (errno ==0 ) + errno =EINVAL ; goto out_fail; }
Signature · 1 line
1.6.6.1
Re: [PATCH 2/2] mount.nfs: silently fails when the network protocol is not found
Quoted 14 lines · Steve Dickson
mount.nfs should display some type of error diagnostics when the network protocol can not be determined.
Signed-off-by Steve Dickson<[email protected]>--- utils/mount/network.c | 19 ++++++++++++++++--- utils/mount/stropts.c | 16 +++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-)utils/mount/network.c +0
-0
utils/mount/network.c nfs_nfs_protocol(struct mount_options *options, unsigned long *protocol) · line 1315
Quoted 5 lines
utils/mount/network.c +2
-0@@ -1311,6 +1311,8 @@ nfs_nfs_protocol(struct mount_options *options, unsigned long *protocol)if (option !=NULL ) {if (!nfs_get_proto (option,&family, protocol)) { errno =EPROTONOSUPPORT ; +nfs_error (_ ("%s: Failed to find '%s' protocol" ), + progname, option);
Set the errno _after_ calling nfs_error(), which could set it to something else. nfs_error() does call C library functions which may alter errno, after all.
Quoted 20 lines
utils/mount/network.c +7
-2return 0 ; }return 1 ;@@ -1399,8 +1401,13 @@ int nfs_nfs_proto_family(struct mount_options *options,case 2 :/* proto */ option =po_get (options,"proto" );if (option !=NULL && - !nfs_get_proto (option,&tmp_family,&protocol)) - goto out_err; + !nfs_get_proto (option,&tmp_family,&protocol)) { + +nfs_error (_ ("%s: Failed to find '%s' protocol" ), + progname, option); + errno =EPROTONOSUPPORT ; +return 0 ; + } }if (!nfs_verify_family (tmp_family))
utils/mount/network.c nfs_mount_protocol(struct mount_options *options, unsigned long *protocol) · line 1503
Quoted 5 lines
utils/mount/network.c +2
-0@@ -1492,6 +1499,8 @@ nfs_mount_protocol(struct mount_options *options, unsigned long *protocol)if (option !=NULL ) {if (!nfs_get_proto (option,&family, protocol)) { errno =EPROTONOSUPPORT ; +nfs_error (_ ("%s: Failed to find '%s' protocol" ), + progname, option);
Ditto.
Quoted 4 lines
utils/mount/network.c +0
-0return 0 ; }return 1 ;
utils/mount/network.c int nfs_mount_proto_family(struct mount_options *options, · line 1568
Quoted 10 lines
utils/mount/network.c +5
-1@@ -1551,8 +1560,12 @@ int nfs_mount_proto_family(struct mount_options *options, option =po_get (options,"mountproto" );if (option !=NULL ) { -if (!nfs_get_proto (option,&tmp_family,&protocol)) +if (!nfs_get_proto (option,&tmp_family,&protocol)) { +nfs_error (_ ("%s: Failed to find '%s' protocol" ), + progname, option); + errno =EPROTONOSUPPORT ; goto out_err; + }
Does out_err also clobber errno here as well?
Quoted 20 lines
utils/mount/network.c +0
-0if (!nfs_verify_family (tmp_family)) goto out_err; *family = tmp_family;utils/mount/stropts.c +4
-1@@ -538,7 +538,10 @@ nfs_rewrite_pmap_mount_options(struct mount_options *options)if (!nfs_construct_new_options (options, nfs_saddr,&nfs_pmap, mnt_saddr,&mnt_pmap)) { - errno =EINVAL ; +if (rpc_createerr.cf_stat ==RPC_UNKNOWNPROTO ) + errno =EPROTONOSUPPORT ; +else + errno =EINVAL ;return 0 ; }
utils/mount/stropts.c static int nfs_do_mount_v3v2(struct nfsmount_info *mi, · line 596
Quoted 10 lines
utils/mount/stropts.c +3
-2@@ -586,18 +589,21 @@ static int nfs_do_mount_v3v2(struct nfsmount_info *mi, errno =ENOMEM ;return result; } - + errno =0 ;if (!nfs_append_addr_option (sap, salen, options)) { - errno =EINVAL ; +if (errno ==0 ) + errno =EINVAL ; goto out_fail;
What I meant before is that the errno should really be set right where the error is detected, not long afterwards in some other part of the code.
Currently it looks like nfs_append_addr_option() sets the errno sometimes, and sometimes it doesn't and the errno is set here. I think the code would make more sense overall if the errno was always appropriately set by the time nfs_append_addr_option() returns.
Likewise for nfs_construct_new_options() above.
Quoted 5 lines
utils/mount/stropts.c +1
-1}if (!nfs_fix_mounthost_option (options, mi->hostname)) { - errno =EINVAL ; +if (errno ==0 )
utils/mount/stropts.c static int nfs_do_mount_v3v2(struct nfsmount_info *mi, · line 609
Quoted 10 lines
utils/mount/stropts.c +3
-1+ errno =EINVAL ; goto out_fail; }if (!mi->fake&& !nfs_verify_lock_option (options)) { - errno =EINVAL ; +if (errno ==0 ) + errno =EINVAL ; goto out_fail; }
Likewise for these two.
Re: [PATCH 2/2] mount.nfs: silently fails when the network protocol is not found
Quoted 10 lines · Chuck Lever
Quoted 9 lines · Steve Dickson
mount.nfs should display some type of error diagnostics when the network protocol can not be determined.
Signed-off-by Steve Dickson<[email protected]>--- utils/mount/network.c | 19 ++++++++++++++++--- utils/mount/stropts.c | 16 +++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-)
Quoted 15 lines
utils/mount/network.c nfs_nfs_protocol(struct mount_options *options, · line 1316
Quoted 11 lines
utils/mount/network.c +2
-0@@ -1311,6 +1311,8 @@ nfs_nfs_protocol(struct mount_options *options, unsigned long *protocol)if (option !=NULL ) {if (!nfs_get_proto (option,&family, protocol)) { errno =EPROTONOSUPPORT ; +nfs_error (_ ("%s: Failed to find '%s' protocol" ), + progname, option);Set the errno _after_ calling
nfs_error(), which could set it to something else.nfs_error()does call C library functions which may alter errno, after all.
point.
Quoted 37 lines
Quoted 22 lines
utils/mount/network.c +0
-0return 0 ; }return 1;utils/mount/network.c +7
-2@@ -1399,8 +1401,13 @@ int nfs_nfs_proto_family(struct mount_options *options, case 2: /* proto */ option =po_get (options,"proto" );if (option !=NULL && - !nfs_get_proto (option,&tmp_family,&protocol)) - goto out_err; + !nfs_get_proto (option,&tmp_family,&protocol)) { + +nfs_error (_ ("%s: Failed to find '%s' protocol" ), + progname, option); + errno =EPROTONOSUPPORT ; +return 0 ; + } }if (!nfs_verify_family(tmp_family))
utils/mount/network.c nfs_mount_protocol(struct mount_options · line 1504
Quoted 6 lines
utils/mount/network.c +2
-0@@ -1492,6 +1499,8 @@ nfs_mount_protocol(struct mount_options *options, unsigned long *protocol)if (option !=NULL ) {if (!nfs_get_proto (option,&family, protocol)) { errno =EPROTONOSUPPORT ; +nfs_error (_ ("%s: Failed to find '%s' protocol" ), + progname, option);Ditto.
Quoted 6 lines
utils/mount/network.c +0
-0return 0 ; }return 1;utils/mount/network.c +0
-0@@ -1551,8 +1560,12 @@ int nfs_mount_proto_family(struct mount_options *options,
Quoted 11 lines
utils/mount/network.c int nfs_mount_proto_family(struct mount_options *options, · line 1568
Quoted 9 lines
utils/mount/network.c +5
-1option =po_get (options,"mountproto" );if (option !=NULL ) { -if (!nfs_get_proto (option,&tmp_family,&protocol)) +if (!nfs_get_proto (option,&tmp_family,&protocol)) { +nfs_error (_ ("%s: Failed to find '%s' protocol" ), + progname, option); + errno =EPROTONOSUPPORT ; goto out_err; + }Does
out_erralso clobber errno here as well?
Ah... I thought I fixed that...
Quoted 60 lines
Quoted 23 lines
utils/mount/network.c +0
-0if (!nfs_verify_family (tmp_family)) goto out_err;*family = tmp_family;utils/mount/stropts.c +4
-1@@ -538,7 +538,10 @@ nfs_rewrite_pmap_mount_options(struct mount_options *options)if (!nfs_construct_new_options (options, nfs_saddr,&nfs_pmap, mnt_saddr,&mnt_pmap)) { - errno =EINVAL ; +if (rpc_createerr.cf_stat ==RPC_UNKNOWNPROTO ) + errno =EPROTONOSUPPORT ; +else + errno =EINVAL ;return 0 ; }@@ -586,18 +589,21 @@ static int nfs_do_mount_v3v2(struct nfsmount_info *mi,utils/mount/stropts.c static int nfs_do_mount_v3v2(struct · line 597
Quoted 10 lines
utils/mount/stropts.c +3
-2errno =ENOMEM ;return result; } - + errno =0 ;if (!nfs_append_addr_option (sap, salen, options)) { - errno =EINVAL ; +if (errno ==0 ) + errno =EINVAL ; goto out_fail;What I meant before is that the errno should really be set right where the error is detected, not long afterwards in some other part of the code.
Currently it looks like
nfs_append_addr_option()sets the errno sometimes, and sometimes it doesn't and the errno is set here. I think the code would make more sense overall if the errno was always appropriately set by the timenfs_append_addr_option()returns.Likewise for
nfs_construct_new_options()above.Quoted 5 lines
utils/mount/stropts.c +0
-1}if (!nfs_fix_mounthost_option (options, mi->hostname)) { - errno =EINVAL ;utils/mount/stropts.c static int nfs_do_mount_v3v2(struct nfsmount_info *mi, · line 608
Quoted 10 lines
utils/mount/stropts.c +4
-1+if (errno ==0 ) + errno =EINVAL ; goto out_fail; }if (!mi->fake&& !nfs_verify_lock_option (options)) { - errno =EINVAL ; +if (errno ==0 ) + errno =EINVAL ; goto out_fail; }
Quoted 1 line
Likewise for these two.
Understood... Please remember the original patch was for when the network protocol can not be found... While I agree with the need of the clean, that is a bit out of the scope the original patch...
I'm all for going back and doing this clean up... but a this particular moment I need to fix this bug and move on..
steved.