[PATCH v2 2/2] xfs_admin: get UUID of mounted filesystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Reviewed-by: Allison Henderson <allison.henderson@xxxxxxxxxx>
---
 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




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux