From: schumaker.anna@gmail.com
To: linux-nfs@vger.kernel.org
Cc: Anna.Schumaker@Netapp.com
Subject: [RFC PATCH 1/6] nfs-sysfs: Add an nfs-sysfs.py tool
Date: Tue, 8 Jun 2021 13:46:52 -0400 [thread overview]
Message-ID: <20210608174657.603256-2-Anna.Schumaker@Netapp.com> (raw)
In-Reply-To: <20210608174657.603256-1-Anna.Schumaker@Netapp.com>
From: Anna Schumaker <Anna.Schumaker@Netapp.com>
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 <Anna.Schumaker@Netapp.com>
---
tools/nfs-sysfs/nfs-sysfs.py | 13 +++++++++++++
tools/nfs-sysfs/sysfs.py | 18 ++++++++++++++++++
2 files changed, 31 insertions(+)
create mode 100755 tools/nfs-sysfs/nfs-sysfs.py
create mode 100644 tools/nfs-sysfs/sysfs.py
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
next prev parent reply other threads:[~2021-06-08 17:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-08 17:46 [RFC PATCH 0/6] Add a tool for using the new sysfs files schumaker.anna
2021-06-08 17:46 ` schumaker.anna [this message]
2021-06-08 17:46 ` [RFC PATCH 2/6] nfs-sysfs.py: Add a command for printing xprt switch information schumaker.anna
2021-06-08 17:46 ` [RFC PATCH 3/6] nfs-sysfs.py: Add a command for printing individual xprts schumaker.anna
2021-06-08 17:46 ` [RFC PATCH 4/6] nfs-sysfs.py: Add a command for printing rpc-client information schumaker.anna
2021-06-08 17:46 ` [RFC PATCH 5/6] nfs-sysfs.py: Add a command for changing xprt dstaddr schumaker.anna
2021-06-08 17:46 ` [RFC PATCH 6/6] nfs-sysfs.py: Add a command for changing xprt-switch dstaddrs schumaker.anna
2021-06-14 13:19 ` [RFC PATCH 0/6] Add a tool for using the new sysfs files Steve Dickson
2021-06-14 13:42 ` Anna Schumaker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210608174657.603256-2-Anna.Schumaker@Netapp.com \
--to=schumaker.anna@gmail.com \
--cc=Anna.Schumaker@Netapp.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox