Skip to contentSkip to conversation

xfs_admin: get/set label of mounted filesystem

PATCH Superseded Catherine Hoang 3 participants 5 messages Jan 17, 2023 – Jan 20, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_admin: get/set label of mounted filesystem

Adapt this tool to call xfs_io to get/set the label of a mounted filesystem.

---
 db/xfs_admin.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
db/xfs_admin.sh +6 -3
index b73fb3ad..cc650c42 100755
@@ -29,9 +29,11 @@ do
 	j)	DB_OPTS=$DB_OPTS" -c 'version log2'"
 		require_offline=1
 		;;
-	l)	DB_OPTS=$DB_OPTS" -r -c label";;
+	l)	DB_OPTS=$DB_OPTS" -r -c label"
+		IO_OPTS=$IO_OPTS" -r -c label"
+		;;
 	L)	DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
-		require_offline=1
+		IO_OPTS=$IO_OPTS" -c 'label -s "$OPTARG"'"
 		;;
 	O)	REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
 		require_offline=1
@@ -69,7 +71,8 @@ case $# in
 			fi
 
 			if [ -n "$IO_OPTS" ]; then
-				exec xfs_io -p xfs_admin $IO_OPTS "$mntpt"
+				eval xfs_io -p xfs_admin $IO_OPTS "$mntpt"
+				exit $?
 			fi
 		fi
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 26 lines · Catherine Hoang

Adapt this tool to call xfs_io to get/set the label of a mounted filesystem.

---
 db/xfs_admin.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
db/xfs_admin.sh +4 -2
index b73fb3ad..cc650c42 100755
@@ -29,9 +29,11 @@ do
 	j)	DB_OPTS=$DB_OPTS" -c 'version log2'"
 		require_offline=1
 		;;
-	l)	DB_OPTS=$DB_OPTS" -r -c label";;
+	l)	DB_OPTS=$DB_OPTS" -r -c label"
+		IO_OPTS=$IO_OPTS" -r -c label"
+		;;
 	L)	DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
-		require_offline=1
+		IO_OPTS=$IO_OPTS" -c 'label -s "$OPTARG"'"
 		;;
 	O)	REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
 		require_offline=1

db/xfs_admin.sh case $# in · line 75

Quoted 6 lines
db/xfs_admin.sh +2 -1
@@ -69,7 +71,8 @@ case $# in
 			fi
 
 			if [ -n "$IO_OPTS" ]; then
-				exec xfs_io -p xfs_admin $IO_OPTS "$mntpt"
+				eval xfs_io -p xfs_admin $IO_OPTS "$mntpt"
+				exit $?

I'm curious, why did this change from exec to eval+exit?

Otherwise, this looks good to me.

--D

Quoted 6 lines
db/xfs_admin.sh +0 -0
 			fi
 		fi
 
Signature · 1 line
2.25.1
#2 lore raw
Quoted 31 lines · Darrick J. Wong
Quoted 28 lines · Catherine Hoang

Adapt this tool to call xfs_io to get/set the label of a mounted filesystem.

---
db/xfs_admin.sh | 9 ++++++---

1 file changed, 6 insertions(+), 3 deletions(-)
db/xfs_admin.sh +4 -2
index b73fb3ad..cc650c42 100755
@@ -29,9 +29,11 @@ do
 	j)	DB_OPTS=$DB_OPTS" -c 'version log2'"
 		require_offline=1
 		;;
-	l)	DB_OPTS=$DB_OPTS" -r -c label";;
+	l)	DB_OPTS=$DB_OPTS" -r -c label"
+		IO_OPTS=$IO_OPTS" -r -c label"
+		;;
 	L)	DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
-		require_offline=1
+		IO_OPTS=$IO_OPTS" -c 'label -s "$OPTARG"'"
 		;;
 	O)	REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
 		require_offline=1
@@ -69,7 +71,8 @@ case $# in
 			fi
 
Quoted 6 lines

db/xfs_admin.sh case $# in · line 75

Quoted 4 lines
db/xfs_admin.sh +2 -1
 			if [ -n "$IO_OPTS" ]; then
-				exec xfs_io -p xfs_admin $IO_OPTS "$mntpt"
+				eval xfs_io -p xfs_admin $IO_OPTS "$mntpt"
+				exit $?

I'm curious, why did this change from exec to eval+exit?

For some reason exec doesn’t correctly parse the $IO_OPTS arguments. I get this error when using exec:

# xfs_admin -L test /dev/sda2
test': No such file or directory
Quoted 11 lines

Otherwise, this looks good to me.

--D

Quoted 6 lines
db/xfs_admin.sh +0 -0
 			fi
 		fi
 
Signature · 1 line
2.25.1
#3 lore raw
Quoted 42 lines · Catherine Hoang
Quoted 33 lines

On Jan 17, 2023, at 7:54 PM, Darrick J. Wong <[email protected]> wrote:

Quoted 29 lines · Catherine Hoang

Adapt this tool to call xfs_io to get/set the label of a mounted filesystem.

---
db/xfs_admin.sh | 9 ++++++---

1 file changed, 6 insertions(+), 3 deletions(-)
db/xfs_admin.sh +0 -0
index b73fb3ad..cc650c42 100755
@@ -29,9 +29,11 @@ do

        j)      DB_OPTS=$DB_OPTS" -c 'version log2'" require_offline=1
                ;;
-       l)      DB_OPTS=$DB_OPTS" -r -c label";; +       l)      DB_OPTS=$DB_OPTS" -r -c label"
+               IO_OPTS=$IO_OPTS" -r -c label"
+               ;;
        L)      DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'" -               require_offline=1
+               IO_OPTS=$IO_OPTS" -c 'label -s "$OPTARG"'" ;;
        O)      REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG" require_offline=1

db/xfs_admin.sh +0 -0
@@ -69,7 +71,8 @@ case $# in

                        fi

Quoted 8 lines
Quoted 6 lines

                        if [ -n "$IO_OPTS" ]; then
-                               exec xfs_io -p xfs_admin $IO_OPTS "$mntpt"
+                               eval xfs_io -p xfs_admin $IO_OPTS "$mntpt"
+                               exit $?

I'm curious, why did this change from exec to eval+exit?

Quoted 2 lines

For some reason exec doesn’t correctly parse the $IO_OPTS arguments. I get this error when using exec:

Did some poking around with this. I think you need "$IO_OPTS" to be in quotations like "$mntpt" is. Otherwise the parameters of "label -s test" get separated and passed to xfs_io instead of xfs_admin. It doesnt complain about -s, which it interprets as sync, and "test" becomes the mount point, which of course does not exist.

It doesnt look like your UUID set has merged, which is where the above line of code first appears. And it looks like this patch cannot apply cleanly without it. So I think the cleanest solution might be to fix the quotations in "xfs_io: add fsuuid command", and then add this patch to that set. Maybe just adapt the series title to "xfsprogs: get UUID and label of mounted filesystems".

Otherwise the set is looking really good :-)
Allison

Quoted 15 lines
# xfs_admin -L test /dev/sda2
test': No such file or directory
Quoted 11 lines

Otherwise, this looks good to me.

--D

Quoted 6 lines

                        fi
                fi

Signature · 1 line
2.25.1
#4 lore raw
Quoted 53 lines · Allison Henderson
Quoted 42 lines · Catherine Hoang
Quoted 33 lines

On Jan 17, 2023, at 7:54 PM, Darrick J. Wong <[email protected]> wrote:

Quoted 29 lines · Catherine Hoang

Adapt this tool to call xfs_io to get/set the label of a mounted filesystem.

---
db/xfs_admin.sh | 9 ++++++---

1 file changed, 6 insertions(+), 3 deletions(-)
db/xfs_admin.sh +4 -2
index b73fb3ad..cc650c42 100755
@@ -29,9 +29,11 @@ do
        j)      DB_OPTS=$DB_OPTS" -c 'version log2'"
                require_offline=1
                ;;
-       l)      DB_OPTS=$DB_OPTS" -r -c label";;
+       l)      DB_OPTS=$DB_OPTS" -r -c label"
+               IO_OPTS=$IO_OPTS" -r -c label"
+               ;;
        L)      DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
-               require_offline=1
+               IO_OPTS=$IO_OPTS" -c 'label -s "$OPTARG"'"
                ;;
        O)      REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
                require_offline=1
@@ -69,7 +71,8 @@ case $# in
                        fi
 
Quoted 8 lines
Quoted 6 lines
db/xfs_admin.sh +0 -1
                        if [ -n "$IO_OPTS" ]; then
-                               exec xfs_io -p xfs_admin $IO_OPTS

"$mntpt"
+ eval xfs_io -p xfs_admin $IO_OPTS
"$mntpt"
+ exit $?

I'm curious, why did this change from exec to eval+exit?

Quoted 2 lines

For some reason exec doesn’t correctly parse the $IO_OPTS arguments. I get this error when using exec:

Did some poking around with this. I think you need "$IO_OPTS" to be in quotations like "$mntpt" is. Otherwise the parameters of "label -s test" get separated and passed to xfs_io instead of xfs_admin. It doesnt complain about -s, which it interprets as sync, and "test" becomes the mount point, which of course does not exist.

Quoted 6 lines

It doesnt look like your UUID set has merged, which is where the above line of code first appears. And it looks like this patch cannot apply cleanly without it. So I think the cleanest solution might be to fix the quotations in "xfs_io: add fsuuid command", and then add this patch to that set. Maybe just adapt the series title to "xfsprogs: get UUID and label of mounted filesystems".

Ah that makes sense, thank you! I’ll send out a new patchset with the changes.

Quoted 17 lines

Otherwise the set is looking really good :-)
Allison

Quoted 13 lines
# xfs_admin -L test /dev/sda2
test': No such file or directory
Quoted 10 lines

Otherwise, this looks good to me.

--D

Quoted 5 lines

fi
fi

Signature · 1 line
2.25.1