Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp892533pxt; Fri, 6 Aug 2021 17:11:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4ClWa9gK8vvMWkcOPkv4PpfiHcOL3dV73glz2R0FwYau70DflJ+Zvvdwm7sLes5mEjbFe X-Received: by 2002:a5e:d905:: with SMTP id n5mr247031iop.136.1628295077379; Fri, 06 Aug 2021 17:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628295077; cv=none; d=google.com; s=arc-20160816; b=A63Sgqwha4DdxdLB77HbYTJVNbvWyELLuX995ZSP13vdvcNajodsxabasc48tZMnL+ Q9xXIcGT21Gp6S9roKboTHsje8uj75FNad5cxtcP19YDt8j5v1+aXtcc9+VbcqHLJ1p/ 7Z1QfbwkX8dirwxxz3s3m1HmewgjBw7vjLj2iaAx64HwacDrGoqzJYlXth5VZV15td35 BwQTMdXsiyyYqRU01KtKBh5b5hJysLyxyFSh/5uNvE5AlGFDVQie5RLBppv/An8EeN88 geGt25U6G50wLYg3mAkuAeVTcuyp8q7HTVimvU+8Id4Yp2/EMgJXW8wi1TZTXLEg5MaI g8OA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=xBbv87HeL7vxd5hlOBy/XvTz1626I03fsVDJ5SL9qM0=; b=ZXEPq0ZopTVbvSkiS8w/XWCnL58GLSIzj5kpSaae9dV7kPdKRmdCsrnaTCOSYUnruk Uym45t7AbRKrmhGKvUN6jqEWKfOeV0azF8wZYKxXg7UYEnU3ZnaPcmmU2SWb8yEawo83 yiJglWW97rAob3zKXYI6IT6GY3Mzq0XVDUaB+uEurEM1S8fHjs2naoRFjgVvx84SzK4g JTVfW74e8iKObVWWHDjjA43RTMvVtY6kz8vC5FPeFi5U1kIEPU4b7RlXIifxgB1vLzZc l65ni6pYq8sOZJk8AUmRAGfr6FwHPpOri6uhSmndv27trYFixoZA2QJqyCglEtL/4Q7w skAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m2S4bNoE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id e123si4706353iof.100.2021.08.06.17.11.05; Fri, 06 Aug 2021 17:11:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m2S4bNoE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 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 S244832AbhHFUSA (ORCPT + 99 others); Fri, 6 Aug 2021 16:18:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232908AbhHFUR7 (ORCPT ); Fri, 6 Aug 2021 16:17:59 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D73BCC0613CF for ; Fri, 6 Aug 2021 13:17:42 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id h27so7363373qtu.9 for ; Fri, 06 Aug 2021 13:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xBbv87HeL7vxd5hlOBy/XvTz1626I03fsVDJ5SL9qM0=; b=m2S4bNoEmHwYy/ReroU37YgQCGvNKWkDyUL9Se26iwa6z4yQyZyM6MFM7M7pQsWq/+ ataVpe2vxFKhSiSAVMJLbBO3J8SKsWqjc3HEx6W94kt7lpz8ph2yOjUWeDhpJXsROVXC Z4IaVt9S38wRGIFdPd/1DQDLSb7j+AVtrKq9rtUAvbj/L+qwjKlw2GwkEygwfFHPiY5R FGZmHroHLRsdxrvESjOgobL2N4FUBLzWAcJ6GzwnIyR57F7dDB5o7Z2MZdiN84rhLYEj jhGQsy83/ZUxhI+ohx8GsYt/ZqRh0V+QSLwNHtrFVo4BlKpoMdWVdsoJYMjqSO2HFqmi YjSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xBbv87HeL7vxd5hlOBy/XvTz1626I03fsVDJ5SL9qM0=; b=EWjIOuSlE1eNdO6lphJbvwt6d2zTQHQ1b2tTsNsc+CYss7iVYDS8AHl5Tt/2cMsKps PbUE7jaQf355bupAP0LdqBYpmITOBw43PpzrGD1IvG+eriwJXurHOPgt0MIBpY2nGGeL wGwddnD43sYjKuQ/ypJIT6qWSXhmHVEyaTjZT6JEJMnrmhmd1IRddI4Z1jx8CGMzGcPe RBSrQkRB6gAV3ETImFBdsgZjgMj3T8BuQAP2wOrksSzZMtzWj2I7IVMrY8eSvBsm1aeA +GsVgw9lf+5sjWOnOmriLvXGbcOLrtU38AQ8eM8WfWnEdiuuUoNqeheWMA3oZ8gbmGXy AKCA== X-Gm-Message-State: AOAM532h0LLQLgudSC446lMZrgXl168lkx/10hfv7pIrlIbzrr9cm3lx gWPyUJQvXwKptEnpeUCHqrv1mMVYXKoBPQ== X-Received: by 2002:ac8:7a98:: with SMTP id x24mr10561530qtr.42.1628281061931; Fri, 06 Aug 2021 13:17:41 -0700 (PDT) Received: from localhost.localdomain ([2601:401:100:a3a:aa6d:aaff:fe2e:8a6a]) by smtp.gmail.com with ESMTPSA id g11sm3705720qtk.91.2021.08.06.13.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Aug 2021 13:17:41 -0700 (PDT) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: steved@redhat.com, linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v2 1/9] nfs-sysfs: Add an nfs-sysfs.py tool Date: Fri, 6 Aug 2021 16:17:31 -0400 Message-Id: <20210806201739.472806-2-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210806201739.472806-1-Anna.Schumaker@Netapp.com> References: <20210806201739.472806-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker This will be used to print and manipulate the sunrpc sysfs directory files. Running without arguments prints both usage information and the location of the sunrpc sysfs directory. Signed-off-by: Anna Schumaker --- .gitignore | 2 ++ tools/nfs-sysfs/nfs-sysfs.py | 13 +++++++++++++ tools/nfs-sysfs/sysfs.py | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100755 tools/nfs-sysfs/nfs-sysfs.py create mode 100644 tools/nfs-sysfs/sysfs.py diff --git a/.gitignore b/.gitignore index c89d1cd2583d..a476bd20bc3b 100644 --- a/.gitignore +++ b/.gitignore @@ -84,3 +84,5 @@ systemd/rpc-gssd.service cscope.* # generic editor backup et al *~ +# python bytecode +__pycache__ diff --git a/tools/nfs-sysfs/nfs-sysfs.py b/tools/nfs-sysfs/nfs-sysfs.py new file mode 100755 index 000000000000..8ff59ea9e81b --- /dev/null +++ b/tools/nfs-sysfs/nfs-sysfs.py @@ -0,0 +1,13 @@ +#!/usr/bin/python +import argparse +import sysfs + +parser = argparse.ArgumentParser() + +def show_small_help(args): + parser.print_usage() + print("sunrpc dir:", sysfs.SUNRPC) +parser.set_defaults(func=show_small_help) + +args = parser.parse_args() +args.func(args) diff --git a/tools/nfs-sysfs/sysfs.py b/tools/nfs-sysfs/sysfs.py new file mode 100644 index 000000000000..0b358f57bb28 --- /dev/null +++ b/tools/nfs-sysfs/sysfs.py @@ -0,0 +1,18 @@ +import pathlib +import sys + +MOUNT = None +with open("/proc/mounts", 'r') as f: + for line in f: + if "sysfs" in line: + MOUNT = line.split()[1] + break + +if MOUNT == None: + print("ERROR: sysfs is not mounted") + sys.exit(1) + +SUNRPC = pathlib.Path(MOUNT) / "kernel" / "sunrpc" +if not SUNRPC.is_dir(): + print("ERROR: sysfs does not have sunrpc directory") + sys.exit(1) -- 2.32.0