2008-06-05 04:56:30

by NeilBrown

[permalink] [raw]
Subject: [PATCH] nfs-utils: "nfsstat -m" should report nfsv4 mounts too.


nfsstat -m lists all current nfs mounts, with the mount options.
It does this by reading /proc/mounts and looking for mounts of type
"nfs".
It really should check for "nfs4" as well. For simplicity, just check
the first 3 characters of the type.

Signed-off-by: NeilBrown <[email protected]>

diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c
index aa6c961..488c845 100644
--- a/utils/nfsstat/nfsstat.c
+++ b/utils/nfsstat/nfsstat.c
@@ -716,7 +716,7 @@ mounts(const char *name)
if (!(type = strtok(NULL, " \t")))
continue;

- if (strcmp(type, "nfs")) {
+ if (strncmp(type, "nfs", 3)) {
continue;
}



2008-06-05 05:00:12

by NeilBrown

[permalink] [raw]
Subject: Re: [PATCH] nfs-utils: "nfsstat -m" should report nfsv4 mounts too.

On Thursday June 5, [email protected] wrote:
>
> nfsstat -m lists all current nfs mounts, with the mount options.
> It does this by reading /proc/mounts and looking for mounts of type
> "nfs".
> It really should check for "nfs4" as well. For simplicity, just check
> the first 3 characters of the type.
>
> Signed-off-by: NeilBrown <[email protected]>
>
> diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c
> index aa6c961..488c845 100644
> --- a/utils/nfsstat/nfsstat.c
> +++ b/utils/nfsstat/nfsstat.c
> @@ -716,7 +716,7 @@ mounts(const char *name)
> if (!(type = strtok(NULL, " \t")))
> continue;
>
> - if (strcmp(type, "nfs")) {
> + if (strncmp(type, "nfs", 3)) {
> continue;
> }
>

(stupid. stupid. stupid).

That will, of course, report the "nfsd" mount as well, which we don't
want. So let's try again.

NeilBrown


diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c
index aa6c961..d2cca8d 100644
--- a/utils/nfsstat/nfsstat.c
+++ b/utils/nfsstat/nfsstat.c
@@ -716,7 +716,7 @@ mounts(const char *name)
if (!(type = strtok(NULL, " \t")))
continue;

- if (strcmp(type, "nfs")) {
+ if (strcmp(type, "nfs") && strcmp(type,"nfs4")) {
continue;
}


2008-06-05 11:40:43

by Scott Atchley

[permalink] [raw]
Subject: Re: [PATCH] nfs-utils: "nfsstat -m" should report nfsv4 mounts too.

On Jun 5, 2008, at 1:00 AM, Neil Brown wrote:

> That will, of course, report the "nfsd" mount as well, which we don't
> want. So let's try again.
>
> NeilBrown
>
>
> diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c
> index aa6c961..d2cca8d 100644
> --- a/utils/nfsstat/nfsstat.c
> +++ b/utils/nfsstat/nfsstat.c
> @@ -716,7 +716,7 @@ mounts(const char *name)
> if (!(type = strtok(NULL, " \t")))
> continue;
>
> - if (strcmp(type, "nfs")) {
> + if (strcmp(type, "nfs") && strcmp(type,"nfs4")) {
> continue;
> }

Don't you want an OR?

+ if (strcmp(type, "nfs") || strcmp(type,"nfs4")) {

Scott

2008-06-05 12:08:14

by NeilBrown

[permalink] [raw]
Subject: Re: [PATCH] nfs-utils: "nfsstat -m" should report nfsv4 mounts too.

On Thu, June 5, 2008 9:40 pm, Scott Atchley wrote:
> On Jun 5, 2008, at 1:00 AM, Neil Brown wrote:
>
>> That will, of course, report the "nfsd" mount as well, which we don't
>> want. So let's try again.
>>
>> NeilBrown
>>
>>
>> diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c
>> index aa6c961..d2cca8d 100644
>> --- a/utils/nfsstat/nfsstat.c
>> +++ b/utils/nfsstat/nfsstat.c
>> @@ -716,7 +716,7 @@ mounts(const char *name)
>> if (!(type = strtok(NULL, " \t")))
>> continue;
>>
>> - if (strcmp(type, "nfs")) {
>> + if (strcmp(type, "nfs") && strcmp(type,"nfs4")) {
>> continue;
>> }
>
> Don't you want an OR?
>
> + if (strcmp(type, "nfs") || strcmp(type,"nfs4")) {


Thanks for reviewing the patch (always appreciated), but no - I don't
want OR.
What I really want is to eradicate all usages of
if (strcmp(X,Y))
in the world and make them
if (strcmp(X,Y) != 0)

Then it is clearer that it is a "!=" test.
In this case, the condition as I had it means"

If type is not nfs and type is not nfs4
(then continue)
which is what I want.

Your version says:
If type is not nfs or type is not nfs4

and that will always be true.

+ if (strcmp(type, "nfs") != 0 && strcmp(type, "nfs4") != 0)) {


NeilBrown