Skip to contentSkip to conversation

lib/tst_test.sh: Make tst_umount work with argument that

PATCH Superseded Leo Liang 3 participants 4 messages Jul 15, 2021 – Jul 16, 2021

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Leo Liang

author
#0 lore raw

PATCH v2 1/2 lib/tst_test.sh: Make tst_umount work with argument that

/proc/mounts shows the mount point without terminating slashes, e.g. ~ $ cat /proc/mounts
xxx /root/cgroup cgroup rw,relatime,cpu 0 0

So current tst_umount would not work with argument that has terminating slash, e.g. tst_umount cgroup/ would give "The device is not mounted".

Fix this by using mountpoint command instead of grepping /proc/mounts.

---
 testcases/lib/tst_test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/lib/tst_test.sh +1 -1
index c6aa2c487..7e77711f1 100644
@@ -282,7 +282,7 @@ tst_umount()
 
 	[ -z "$device" ] && return
 
-	if ! grep -q "$device" /proc/mounts; then
+	if ! mountpoint -q "$device"; then
 		tst_res TINFO "The $device is not mounted, skipping umount"
 		return
 	fi
Signature · 1 line
2.17.0
#1 lore raw

PATCH v2 1/2 lib/tst_test.sh: Make tst_umount work with argument that

Hi Leo

Quoted 19 lines

/proc/mounts shows the mount point without terminating slashes, e.g. ~ $ cat /proc/mounts
xxx /root/cgroup cgroup rw,relatime,cpu 0 0

So current tst_umount would not work with argument that has terminating slash, e.g. tst_umount cgroup/ would give "The device is not mounted".

Fix this by using mountpoint command instead of grepping /proc/mounts.

---
  testcases/lib/tst_test.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
testcases/lib/tst_test.sh +0 -0
index c6aa2c487..7e77711f1 100644

testcases/lib/tst_test.sh tst_umount() · line 285

Quoted 5 lines
testcases/lib/tst_test.sh +1 -1
@@ -282,7 +282,7 @@ tst_umount()
 
  	[ -z "$device" ]&&  return
 
-	if ! grep -q "$device" /proc/mounts; then
+	if ! mountpoint -q "$device"; then

Honestly speaking, I don't want to introduce mountpoint command. we can just filter the last "/" string for $device.

Best Regards
Yang Xu

Quoted 3 lines
testcases/lib/tst_test.sh +0 -0
  		tst_res TINFO "The $device is not mounted, skipping umount"
  		return
  	fi
author
#2 lore raw

PATCH v2 1/2 lib/tst_test.sh: Make tst_umount work with argument that

Hi Yang,

Quoted 23 lines · On Fri, Jul 16, 2021 at 09:23:01AM +0800, [email protected] wrote:

Hi Leo

Quoted 22 lines

/proc/mounts shows the mount point without terminating slashes, e.g. ~ $ cat /proc/mounts
xxx /root/cgroup cgroup rw,relatime,cpu 0 0

So current tst_umount would not work with argument that has terminating slash, e.g. tst_umount cgroup/ would give "The device is not mounted".

Fix this by using mountpoint command instead of grepping /proc/mounts.

---
  testcases/lib/tst_test.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
testcases/lib/tst_test.sh +0 -0
index c6aa2c487..7e77711f1 100644
@@ -282,7 +282,7 @@ tst_umount()
 
  	[ -z "$device" ]&&  return
 
Quoted 7 lines

testcases/lib/tst_test.sh tst_umount() · line 285

Quoted 2 lines
testcases/lib/tst_test.sh +1 -1
-	if ! grep -q "$device" /proc/mounts; then
+	if ! mountpoint -q "$device"; then

Honestly speaking, I don't want to introduce mountpoint command. we can just filter the last "/" string for $device.

Best Regards
Yang Xu

Got it!
I'll send a v3 patch with this approach:
Filtering out the '/' when determining whether a $device is mounted. Thanks!

Best regards,
Leo

Quoted 3 lines
Quoted 3 lines
testcases/lib/tst_test.sh +0 -0
  		tst_res TINFO "The $device is not mounted, skipping umount"
  		return
  	fi
#3 lore raw

PATCH v2 1/2 lib/tst_test.sh: Make tst_umount work with argument that

In reply to [email protected]

Hi all,

Quoted 21 lines

Hi Leo

Quoted 19 lines

/proc/mounts shows the mount point without terminating slashes, e.g. ~ $ cat /proc/mounts
xxx /root/cgroup cgroup rw,relatime,cpu 0 0

So current tst_umount would not work with argument that has terminating slash, e.g. tst_umount cgroup/ would give "The device is not mounted".

Fix this by using mountpoint command instead of grepping /proc/mounts.

---
  testcases/lib/tst_test.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
testcases/lib/tst_test.sh +0 -0
index c6aa2c487..7e77711f1 100644
@@ -282,7 +282,7 @@ tst_umount()
Quoted 6 lines

testcases/lib/tst_test.sh tst_umount() · line 285

Quoted 4 lines
testcases/lib/tst_test.sh +1 -1
  	[ -z "$device" ]&&  return
 
-	if ! grep -q "$device" /proc/mounts; then
+	if ! mountpoint -q "$device"; then

Honestly speaking, I don't want to introduce mountpoint command. we can just filter the last "/" string for $device.

+1, please no any unnecessary dependency.

Kind regards,
Petr

Quoted 2 lines

Best Regards
Yang Xu