Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3169407iob; Mon, 16 May 2022 15:00:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzC/JeaS1ffsChA2XnRZYOZCoHmo9IfNckSvFtA/V6tpIslnwtls9lnrafI+YypUBAyWPGY X-Received: by 2002:a62:b515:0:b0:50a:3d51:671e with SMTP id y21-20020a62b515000000b0050a3d51671emr19209141pfe.48.1652738434124; Mon, 16 May 2022 15:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652738434; cv=none; d=google.com; s=arc-20160816; b=eVkLEegu/hGCQIGLKO/TETKjehYlgWgSHSOypxA7k4q6kju1OYXSjbtSUNcWzNOcy7 /8PWIkuxEboaIEYsKUBKwurxoRkX+T0LjFlc1HJn1vIqyxI3/EjSmTQQcMqfvAdmgRwF I/3KUuyL7lX1mdUCX8fXJ2QvoZaDZ1CGH/7JiNusPFcxCnefMZweT2//HhmiZ+V+dfgF 4eUbutMQBnfi2poAX5TzFgsrm9lXOdDSSM624J+JAb8uBFtQ2smggftNuDyi+M7e7aP9 p8RMfPVEC80npAR+Y9xu/zJbjGTCWOGphzkkLzbCgYSgPMrBnPO+esWVGHG7lw+wDJCw dgvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ZRAZ87X3L3JPmycM+t5YYtpINDMnrtSBW0guYw3fx6I=; b=ixrOjxKWCpE3r50uMPdFZ1crVWfT5YkrnUUyZKN9uZ+vo+syuWON2y3yuqwJlp9Fm6 r52OGp+v/QxqDIODwyV8zkKZE/js259vbgcdH7EmN+PVKX/nq6+1xMg4c3mOpkxcMCU0 GKxPlbpG5fn0Mi7dJCaxs95sFXfYzQj/rly0+YDY1rzcuaBT1tNCq96MIIQGfBuPUv8Y vo2+uGNei1R6eyG+XaOfD5RnbHrn3kp2nXRa4qGrCa8JoMu/P8pQQinOf4/PnFG5il8/ kXFvU/aDV4gdI7YPgWNYj/FbtVxf/P15DzsaHsBzXTS3rHq2FxxhHf/ebXGC5rIawtHe U5cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=vkp6bD2b; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o32-20020a17090a0a2300b001df4fca8f27si485550pjo.116.2022.05.16.14.59.30; Mon, 16 May 2022 15:00:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=vkp6bD2b; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243793AbiEPTML (ORCPT + 99 others); Mon, 16 May 2022 15:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231625AbiEPTMK (ORCPT ); Mon, 16 May 2022 15:12:10 -0400 X-Greylist: delayed 953 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 16 May 2022 12:12:09 PDT Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33EC8DEEF for ; Mon, 16 May 2022 12:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=ZRAZ87X3L3JPmycM+t5YYtpINDMnrtSBW0guYw3fx6I=; b=vkp6bD2bncbX G1n6I4sf5KLo4KeQ85IVQy6bXssVuM1Ogqoo6xg6UofQYWgM3Gw6eEHrOF38GjnSIXp6ichkSD2YE gMzXgx8Tz3g485QrbNjsIq1dRZ/lPevPOKEhpeHVJi0BHODiUdFlYa+twvJ85Lfxesu4ritQhzu6i V9A34=; Received: from [172.29.16.86] (helo=finist-vl9.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.94.2) (envelope-from ) id 1nqfrf-00GLdz-I6; Mon, 16 May 2022 20:55:48 +0200 From: Konstantin Khorenko To: linux-nfs@vger.kernel.org Cc: Steve Dickson , Konstantin Khorenko Subject: [PATCH] mountd: Check 'nfsd/clients' directory presence instead of kernel version Date: Mon, 16 May 2022 21:55:55 +0300 Message-Id: <20220516185555.643087-1-khorenko@virtuozzo.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 --- 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 #include #include +#include #include #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