All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v7, 1/4] lib: tst_umount: umount a mount point instead of a device
@ 2021-08-24 12:16 Leo Liang
  2021-08-24 12:56 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Leo Liang @ 2021-08-24 12:16 UTC (permalink / raw)
  To: ltp

Current check inside tst_umount for whehter a device is mounted is ambiguous.
Fix it by checking for the existance of the exact mount point the fs is mounted upon,
and use the mount point instead of the device to do the umount process.
This patch make tst_umount umount TST_MNTPOINT by default,
and reject any argument that does not start with '/'.

Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_test.sh | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 78e2760e7..33015616d 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -279,31 +279,35 @@ tst_mount()
 
 tst_umount()
 {
-	local device="${1:-$TST_DEVICE}"
+	local mntpoint="${1:-$TST_MNTPOINT}"
 	local i=0
 
-	[ -z "$device" ] && return
+	[ -z "$mntpoint" ] && return
 
-	if ! grep -q "$device" /proc/mounts; then
-		tst_res TINFO "The $device is not mounted, skipping umount"
+	if ! echo "$mntpoint" | grep -q ^/; then
+		tst_brk TCONF "The '$mntpoint' is not an absolute path"
+	fi
+
+	if ! grep -q "${mntpoint%/}" /proc/mounts; then
+		tst_res TINFO "The '$mntpoint' is not mounted upon, skipping umount"
 		return
 	fi
 
 	while [ "$i" -lt 50 ]; do
-		if umount "$device" > /dev/null; then
+		if umount "$mntpoint" > /dev/null; then
 			return
 		fi
 
 		i=$((i+1))
 
-		tst_res TINFO "umount($device) failed, try $i ..."
+		tst_res TINFO "umount($mntpoint) failed, try $i ..."
 		tst_res TINFO "Likely gvfsd-trash is probing newly mounted "\
 		              "fs, kill it to speed up tests."
 
 		tst_sleep 100ms
 	done
 
-	tst_res TWARN "Failed to umount($device) after 50 retries"
+	tst_res TWARN "Failed to umount($mntpoint) after 50 retries"
 }
 
 tst_mkfs()
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [LTP] [PATCH v7, 1/4] lib: tst_umount: umount a mount point instead of a device
  2021-08-24 12:16 [LTP] [PATCH v7, 1/4] lib: tst_umount: umount a mount point instead of a device Leo Liang
@ 2021-08-24 12:56 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2021-08-24 12:56 UTC (permalink / raw)
  To: ltp

Hi!
> +		tst_res TINFO "The '$mntpoint' is not mounted upon, skipping umount"
                                                                 ^
								I would
								remove
								this
								'upon'
								here


Otherwise:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-24 12:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 12:16 [LTP] [PATCH v7, 1/4] lib: tst_umount: umount a mount point instead of a device Leo Liang
2021-08-24 12:56 ` Cyril Hrubis

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.