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 <[email protected]>
---
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;
--
2.31.1
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 <[email protected]>
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;