From: Catherine Hoang <catherine.hoang@oracle.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH v2 2/2] xfs_admin: get UUID of mounted filesystem
Date: Mon, 19 Dec 2022 10:18:24 -0800 [thread overview]
Message-ID: <20221219181824.25157-3-catherine.hoang@oracle.com> (raw)
In-Reply-To: <20221219181824.25157-1-catherine.hoang@oracle.com>
Adapt this tool to call xfs_io to retrieve the UUID of a mounted filesystem.
This is a precursor to enabling xfs_admin to set the UUID of a mounted
filesystem.
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
---
db/xfs_admin.sh | 27 +++++++++++++++++++++++----
man/man8/xfs_admin.8 | 4 ++++
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
index 409975b2..cc9a2150 100755
--- a/db/xfs_admin.sh
+++ b/db/xfs_admin.sh
@@ -6,10 +6,12 @@
status=0
DB_OPTS=""
+DB_EXTRA_OPTS=""
+IO_OPTS=""
REPAIR_OPTS=""
REPAIR_DEV_OPTS=""
LOG_OPTS=""
-USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
+USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] [mountpoint|device] [logdev]"
while getopts "c:efjlL:O:pr:uU:V" c
do
@@ -23,7 +25,8 @@ do
O) REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG";;
p) DB_OPTS=$DB_OPTS" -c 'version projid32bit'";;
r) REPAIR_DEV_OPTS=" -r '$OPTARG'";;
- u) DB_OPTS=$DB_OPTS" -r -c uuid";;
+ u) DB_EXTRA_OPTS=$DB_EXTRA_OPTS" -r -c uuid";
+ IO_OPTS=$IO_OPTS" -r -c fsuuid";;
U) DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'";;
V) xfs_db -p xfs_admin -V
status=$?
@@ -38,14 +41,30 @@ set -- extra $@
shift $OPTIND
case $# in
1|2)
+ # Target either a device or mountpoint, not both
+ if [ -n "$(findmnt -t xfs -T $1)" ]; then
+ if [ -n "$DB_OPTS" ] || [ -n "$REPAIR_OPTS" ]; then
+ echo "Offline options target a device, not mountpoint."
+ exit 2
+ fi
+ DB_EXTRA_OPTS=""
+ else
+ IO_OPTS=""
+ fi
+
# Pick up the log device, if present
if [ -n "$2" ]; then
LOG_OPTS=" -l '$2'"
fi
- if [ -n "$DB_OPTS" ]
+ if [ -n "$DB_OPTS" ] || [ -n "$DB_EXTRA_OPTS" ]
+ then
+ eval xfs_db -x -p xfs_admin $LOG_OPTS $DB_OPTS $DB_EXTRA_OPTS "$1"
+ status=$?
+ fi
+ if [ -n "$IO_OPTS" ]
then
- eval xfs_db -x -p xfs_admin $LOG_OPTS $DB_OPTS "$1"
+ eval xfs_io -x -p xfs_admin $IO_OPTS "$1"
status=$?
fi
if [ -n "$REPAIR_OPTS" ]
diff --git a/man/man8/xfs_admin.8 b/man/man8/xfs_admin.8
index 4794d677..2c7ddc15 100644
--- a/man/man8/xfs_admin.8
+++ b/man/man8/xfs_admin.8
@@ -19,7 +19,11 @@ xfs_admin \- change parameters of an XFS filesystem
.B \-r
.I rtdev
]
+[
+.I mount-point
+|
.I device
+]
[
.I logdev
]
--
2.25.1
next prev parent reply other threads:[~2022-12-19 18:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-19 18:18 [PATCH v2 0/2] get UUID of mounted filesystems Catherine Hoang
2022-12-19 18:18 ` [PATCH v2 1/2] xfs_io: add fsuuid command Catherine Hoang
2022-12-20 21:55 ` Darrick J. Wong
2022-12-21 7:11 ` Catherine Hoang
2022-12-21 16:24 ` Darrick J. Wong
2022-12-19 18:18 ` Catherine Hoang [this message]
2022-12-20 22:29 ` [PATCH v2 2/2] xfs_admin: get UUID of mounted filesystem Darrick J. Wong
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=20221219181824.25157-3-catherine.hoang@oracle.com \
--to=catherine.hoang@oracle.com \
--cc=linux-xfs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.