Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5466985ybi; Tue, 28 May 2019 13:38:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeBIMplpc9e/niRNYlgdzGYpIbkVIsnaXiPCM6rNvhJjBxLx2qNwnk5W8TKpD8T51uFjNq X-Received: by 2002:a62:bd0e:: with SMTP id a14mr126030049pff.44.1559075898051; Tue, 28 May 2019 13:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559075898; cv=none; d=google.com; s=arc-20160816; b=I38sO2xzZsiqAGDPyjd9eFNfQERPcYu7+3bcfv9K2Q2WsKTLRs2+aQO2h/rsww9I+g ispcOnH+ryw6fjxpBT2i+WVIBVuY8bNa2gu+BZhWIQH7/iMwUvlWTD/r/kM7mCGxvBXE ZJEpAgSTXoc5++70BbdFhnqMpR+yPwybXL8+cRhgQMuM4Ff6Pd1ZUOp8A79lSMJK08L9 BXlTtRCgKbqSo2UomoeXWy11c647/Nk6hIPWNGPrtl3LKykvhy0xTThWcjCdE1JNC50G iqaHSQTwmvq8gJnxj1XTy9zjpjtX9LTcxmKFJ18pGFfCoup6UR3OOIKiLMBBIVyoxAd4 7Qtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5XCyxEssCkoFUZsF1Xsl+Bt7IoweXokZG+MQ8pRyU00=; b=Cgv4lQz/ZJfPrfFX0Q5FnidsRwWHkXxDWHlhPPa/i3fKzlbJBNO03NviKENd1q42EY i7wyntTLNZTg0LpGV0ECvLOjGuPk1bvizaTZYFkyrjiTLH7JpnnD0deZRL1pmZQyVDYx EYFtFdYJ3g7W2XOvcSPodMA1c2FToctlVItMQc0vncQMF2Qk9rX/GppAi4ozEyT6Rsk/ lW6I0C00I+d4Cdya/KVbvIHWkTxAjSGp4q+ivKGRHGsH5XYBxhmhcLW20yZJc44ZImO6 9ZM4Z+jKuTFL8XArYeR/tokfKhH1E/fgkQduMCXu0fBUOdDLj4BjzENvGSULq4LYqWSg SfoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iYWsyzTp; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f20si10905110pfn.207.2019.05.28.13.38.04; Tue, 28 May 2019 13:38:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iYWsyzTp; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726812AbfE1Ude (ORCPT + 99 others); Tue, 28 May 2019 16:33:34 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:53446 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727075AbfE1Ude (ORCPT ); Tue, 28 May 2019 16:33:34 -0400 Received: by mail-it1-f194.google.com with SMTP id m141so6581279ita.3 for ; Tue, 28 May 2019 13:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5XCyxEssCkoFUZsF1Xsl+Bt7IoweXokZG+MQ8pRyU00=; b=iYWsyzTpesb37ABSyErBixcQaBLSmpgpRKwsTAsc9QS/V7xhiUXaC2YvHyCtnKfv44 713byh221DuRvCrxlYyybI7sgC5nfOpm9qukze53Ug/XmilrnmRico9EO1wVteozRrm0 jMaa0OtY3wvzZb/ibt1YjoXVmZJPJaf782H6Gi+vy5/aDYFaEwhuy2pNTNCdBKkQcRzB a2Z6r8eAKp56sz3jv6QrVL0iqrQwCXgP3PyGlLqhGR49am+GELAFd6aqE6mCRAZVvTmc QusXlujWNCSty+xyAwYVZig6QPnlSV0l4CtG3MCGg5FReAxGYAYslgCRWdcbgsUmq+W1 D9BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5XCyxEssCkoFUZsF1Xsl+Bt7IoweXokZG+MQ8pRyU00=; b=LFT9ZP4aCC0fYH+gy7ybrmmRi7iTYlVW5SfSbPkdeoRXouEHZefnoweFfPr1xxe6oV 7pf5Id2GeiFLu6OAYmRlsM/nyUbzbdYEb6cD36yKWIvJdkctKQJrMb5DLGzYTcUMPBho 6fv6Kq7HQqzBPV5ETLTKFepTZx5pZ+cXk0IOyosHPmzyptmEF4mMvtao4/DZOsAfgTan kBvVyjhJsKznZWac12WQj5EXU6HKJvwQupfb341QGWbhjNCNwT0b8R2oj2RLz2QR6SI5 La9YraahJS69PJ6P9ZPynK6S1Uyafowf/XUtCGZw4efnan3eb50TyCG8akRQeRMnIxqK rljQ== X-Gm-Message-State: APjAAAV5sJa9qNH14Zlfqyjjc2Guzg+5Jixb+IhQqa1cCp/7cQomhfr7 mtMIIraClskbLtpcrMMKbA== X-Received: by 2002:a24:5fc2:: with SMTP id r185mr4444465itb.43.1559075613430; Tue, 28 May 2019 13:33:33 -0700 (PDT) Received: from localhost.localdomain (50-124-247-140.alma.mi.frontiernet.net. [50.124.247.140]) by smtp.gmail.com with ESMTPSA id i141sm53089ite.20.2019.05.28.13.33.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 13:33:32 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: SteveD@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 03/11] Allow callers to check mountpoint status using a custom lstat function Date: Tue, 28 May 2019 16:31:14 -0400 Message-Id: <20190528203122.11401-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190528203122.11401-3-trond.myklebust@hammerspace.com> References: <20190528203122.11401-1-trond.myklebust@hammerspace.com> <20190528203122.11401-2-trond.myklebust@hammerspace.com> <20190528203122.11401-3-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Trond Myklebust --- support/include/misc.h | 7 ++++++- support/misc/mountpoint.c | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/support/include/misc.h b/support/include/misc.h index 06e2a0c7b061..2b0fef26cb11 100644 --- a/support/include/misc.h +++ b/support/include/misc.h @@ -18,7 +18,12 @@ int weakrandomkey(unsigned char *keyout, int len); char *generic_make_pathname(const char *, const char *); _Bool generic_setup_basedir(const char *, const char *, char *, const size_t); -extern int is_mountpoint(char *path); +struct stat; + +extern int check_is_mountpoint(const char *path, + int (mystat)(const char *, struct stat *)); +#define is_mountpoint(path) \ + check_is_mountpoint(path, NULL) /* size of the file pointer buffers for rpc procfs files */ #define RPC_CHAN_BUF_SIZE 32768 diff --git a/support/misc/mountpoint.c b/support/misc/mountpoint.c index 9f9ce44ec1e3..c6217f2458d1 100644 --- a/support/misc/mountpoint.c +++ b/support/misc/mountpoint.c @@ -9,8 +9,10 @@ #include "misc.h" int -is_mountpoint(char *path) +check_is_mountpoint(const char *path, int (mystat)(const char *, struct stat *)) { + if (!mystat) + mystat = lstat; /* Check if 'path' is a current mountpoint. * Possibly we should also check it is the mountpoint of the * filesystem holding the target directory, but there doesn't @@ -26,8 +28,8 @@ is_mountpoint(char *path) dotdot = xmalloc(strlen(path)+4); strcat(strcpy(dotdot, path), "/.."); - if (lstat(path, &stb) != 0 || - lstat(dotdot, &pstb) != 0) + if (mystat(path, &stb) != 0 || + mystat(dotdot, &pstb) != 0) rv = 0; else if (stb.st_dev != pstb.st_dev || -- 2.21.0