[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-nfs
Subject:    Re: [PATCH] mountd: Check 'nfsd/clients' directory presence instead of kernel version
From:       Steve Dickson <steved () redhat ! com>
Date:       2022-05-26 17:33:27
Message-ID: 75ee3189-22fe-48ca-9e04-69648b300b6a () redhat ! com
[Download RAW message or body]



On 5/16/22 2:55 PM, Konstantin Khorenko wrote:
> Kernel major version does not always provide 100% certainty about
> presence or absence of a feature, for example:
>   - some distros backport feature from mainstream kernel to older kernels
>   - if NFS server is run inside a system container the reported kernel
>     version inside the container may be faked
> 
> So let's determine the feature presence by checking
> '/proc/fs/nfsd/clients/' directory presence instead of checking the
> kernel version.
> 
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
Committed... (tag: nfs-utils-2-6-2-rc5)

steved.
> ---
>   support/export/v4clients.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/support/export/v4clients.c b/support/export/v4clients.c
> index 5e4f1058..5f15b614 100644
> --- a/support/export/v4clients.c
> +++ b/support/export/v4clients.c
> @@ -8,9 +8,9 @@
>   #include <unistd.h>
>   #include <stdlib.h>
>   #include <sys/inotify.h>
> +#include <sys/stat.h>
>   #include <errno.h>
>   #include "export.h"
> -#include "version.h"
>   
>   /* search.h declares 'struct entry' and nfs_prot.h
>    * does too.  Easiest fix is to trick search.h into
> @@ -24,7 +24,10 @@ static int clients_fd = -1;
>   
>   void v4clients_init(void)
>   {
> -	if (linux_version_code() < MAKE_VERSION(5, 3, 0))
> +	struct stat sb;
> +
> +	if (!stat("/proc/fs/nfsd/clients", &sb) == 0 ||
> +	    !S_ISDIR(sb.st_mode))
>   		return;
>   	if (clients_fd >= 0)
>   		return;

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic