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> --- db/xfs_admin.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh index 409975b2..0dcb9940 100755 --- a/db/xfs_admin.sh +++ b/db/xfs_admin.sh @@ -6,6 +6,8 @@ status=0 DB_OPTS="" +DB_EXTRA_OPTS="" +IO_OPTS="" REPAIR_OPTS="" REPAIR_DEV_OPTS="" LOG_OPTS="" @@ -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,26 @@ set -- extra $@ shift $OPTIND case $# in 1|2) + # Use xfs_io if mounted and xfs_db if not mounted + if [ -n "$(findmnt -t xfs -T $1)" ]; then + 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" ] -- 2.25.1