lib/tst_test.sh: Make tst_umount work with argument that has trailing slash
PATCH v3 1/2 lib/tst_test.sh: Make tst_umount work with argument that has trailing slash
/proc/mounts shows the mount point without trailing 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 trailing slash, e.g. tst_umount cgroup/ would give "The device is not mounted".
Fix this by filtering out the trailing slash before grepping /proc/mounts.
--- testcases/lib/tst_test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
testcases/lib/tst_test.sh +2 -1
@@ -282,13 +282,14 @@ tst_umount() [ -z "$device" ] && return + device=${device%/} if ! grep -q "$device" /proc/mounts; then tst_res TINFO "The $device is not mounted, skipping umount" return fi while [ "$i" -lt 50 ]; do - if umount "$device" > /dev/null; then + if umount "$device"/ > /dev/null; then return fi
Signature · 1 line
2.17.0
PATCH v3 1/2 lib/tst_test.sh: Make tst_umount work with argument that has trailing slash
Hi Leo
Quoted 21 lines
/proc/mountsshows the mount point without trailing slashes, e.g. ~ $ cat/proc/mounts
xxx/root/cgroupcgroup rw,relatime,cpu 0 0So current
tst_umountwould not work with argument that has trailing slash, e.g.tst_umountcgroup/ would give "The device is not mounted".Fix this by filtering out the trailing slash before grepping
/proc/mounts.Signed-off-by Leo Yu-Chi Liang<[email protected]>--- testcases/lib/tst_test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)testcases/lib/tst_test.sh +0
-0@@ -282,13 +282,14 @@ tst_umount() [ -z "$device" ]&& return
testcases/lib/tst_test.sh tst_umount() · line 292
Quoted 10 lines
testcases/lib/tst_test.sh +2
-1+ device=${device%/} if ! grep -q "$device" /proc/mounts; then tst_res TINFO "The $device is not mounted, skipping umount" return fi while [ "$i" -lt 50 ]; do - if umount "$device"> /dev/null; then + if umount "$device"/> /dev/null; then
With removing this(we don't need add "/" here), this patch looks good to me
Quoted 3 lines
testcases/lib/tst_test.sh +0
-0return fi
PATCH v3 1/2 lib/tst_test.sh: Make tst_umount work with argument that has trailing slash
Quoted 30 lines
Hi Leo
Quoted 27 lines
/proc/mountsshows the mount point without trailing slashes, e.g. ~ $ cat/proc/mounts
xxx/root/cgroupcgroup rw,relatime,cpu 0 0So current
tst_umountwould not work with argument that has trailing slash, e.g.tst_umountcgroup/ would give "The device is not mounted".Fix this by filtering out the trailing slash before grepping
/proc/mounts.Signed-off-by Leo Yu-Chi Liang<[email protected]>--- testcases/lib/tst_test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)testcases/lib/tst_test.sh +1
-0@@ -282,13 +282,14 @@ tst_umount() [ -z "$device" ]&& return + device=${device%/} if ! grep -q "$device" /proc/mounts; then tst_res TINFO "The $device is not mounted, skipping umount" return fi
Quoted 4 lines
testcases/lib/tst_test.sh tst_umount() · line 291
Quoted 3 lines
testcases/lib/tst_test.sh +1
-1while [ "$i" -lt 50 ]; do - if umount "$device"> /dev/null; then + if umount "$device"/> /dev/null; thenWith removing
this(we don't need add "/" here), this patch looks good to me
+1
Kind regards,
Petr
Quoted 3 lines
Reviewed-by Yang Xu <[email protected]>Quoted 2 lines
testcases/lib/tst_test.sh +0
-0return fi
PATCH v3 1/2 lib/tst_test.sh: Make tst_umount work with argument that has trailing slash
Hi all,
Quoted 30 lines
Quoted 29 lines
Hi Leo
Quoted 27 lines
/proc/mountsshows the mount point without trailing slashes, e.g. ~ $ cat/proc/mounts
xxx/root/cgroupcgroup rw,relatime,cpu 0 0So current
tst_umountwould not work with argument that has trailing slash, e.g.tst_umountcgroup/ would give "The device is not mounted".Fix this by filtering out the trailing slash before grepping
/proc/mounts.Signed-off-by Leo Yu-Chi Liang<[email protected]>--- testcases/lib/tst_test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)testcases/lib/tst_test.sh +1
-0@@ -282,13 +282,14 @@ tst_umount() [ -z "$device" ]&& return + device=${device%/} if ! grep -q "$device" /proc/mounts; then tst_res TINFO "The $device is not mounted, skipping umount" return fi
Quoted 5 lines
Quoted 4 lines
testcases/lib/tst_test.sh tst_umount() · line 291
Quoted 3 lines
testcases/lib/tst_test.sh +1
-1while [ "$i" -lt 50 ]; do - if umount "$device"> /dev/null; then + if umount "$device"/> /dev/null; thenWith removing
this(we don't need add "/" here), this patch looks good to me+1
Actually we need to keep / for next patch, right? (cgroup/)
Thus why not just changing argument for grep?
- if ! grep -q "$device" /proc/mounts; then
+ if ! grep -q "${device%/}" /proc/mounts; then
Kind regards,
Petr
Quoted 8 lines
Reviewed-by Petr Vorel <[email protected]>Kind regards,
PetrQuoted 3 lines
Reviewed-by Yang Xu <[email protected]>Quoted 2 lines
testcases/lib/tst_test.sh +0
-0return fi
PATCH v3 1/2 lib/tst_test.sh: Make tst_umount work with argument that has trailing slash
Hi Petr
Quoted 32 lines
Hi all,
Quoted 29 lines
Quoted 29 lines
Hi Leo
Quoted 27 lines
/proc/mountsshows the mount point without trailing slashes, e.g. ~ $ cat/proc/mounts
xxx/root/cgroupcgroup rw,relatime,cpu 0 0So current
tst_umountwould not work with argument that has trailing slash, e.g.tst_umountcgroup/ would give "The device is not mounted".Fix this by filtering out the trailing slash before grepping
/proc/mounts.Signed-off-by Leo Yu-Chi Liang<[email protected]>--- testcases/lib/tst_test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)testcases/lib/tst_test.sh +1
-0@@ -282,13 +282,14 @@ tst_umount() [ -z "$device" ]&& return + device=${device%/} if ! grep -q "$device" /proc/mounts; then tst_res TINFO "The $device is not mounted, skipping umount" return fi
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
testcases/lib/tst_test.sh tst_umount() · line 291
Quoted 3 lines
testcases/lib/tst_test.sh +1
-1while [ "$i" -lt 50 ]; do - if umount "$device"> /dev/null; then + if umount "$device"/> /dev/null; thenWith removing
this(we don't need add "/" here), this patch looks good to me+1
Actually we need to keep / for next patch, right? (cgroup/)
I guess our ltp tst_umount api should support to umount cgroup or cgroup/ like umount command does.
Review
Quoted 4 lines
Thus why not just changing argument for grep?
(quoted diff) +1
-1- if ! grep -q "$device" /proc/mounts; then + if ! grep -q "${device%/}" /proc/mounts; then
Yes, it is more easier. But I think it still existed the problme when we only use "/" parameters. I guess we should reject this situation.
code maybe as below:
testcases/lib/tst_test.sh +6 -1
@@ -282,7 +282,12 @@ tst_umount() [ -z "$device" ] && return - if ! grep -q "$device" /proc/mounts; then + if [ "$device" = "/" ]; then + tst_res TINFO "We can not umount / directory" + return + fi + + if ! grep -q "${device%/}" /proc/mounts; then tst_res TINFO "The $device is not mounted, skipping umount" return fi
Quoted 13 lines
Kind regards,
PetrQuoted 8 lines
Reviewed-by Petr Vorel<[email protected]>Kind regards,
PetrQuoted 3 lines
Reviewed-by Yang Xu<[email protected]>Quoted 2 lines
testcases/lib/tst_test.sh +0
-0return fi
PATCH v3 1/2 lib/tst_test.sh: Make tst_umount work with argument that has trailing slash
Hi Xu, all,
Quoted 33 lines
Hi Petr
Quoted 31 lines
Hi all,
Quoted 29 lines
Quoted 29 lines
Hi Leo
Quoted 27 lines
/proc/mountsshows the mount point without trailing slashes, e.g. ~ $ cat/proc/mounts
xxx/root/cgroupcgroup rw,relatime,cpu 0 0So current
tst_umountwould not work with argument that has trailing slash, e.g.tst_umountcgroup/ would give "The device is not mounted".Fix this by filtering out the trailing slash before grepping
/proc/mounts.Signed-off-by Leo Yu-Chi Liang<[email protected]>--- testcases/lib/tst_test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)testcases/lib/tst_test.sh +1
-0@@ -282,13 +282,14 @@ tst_umount() [ -z "$device" ]&& return + device=${device%/} if ! grep -q "$device" /proc/mounts; then tst_res TINFO "The $device is not mounted, skipping umount" return fi
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
testcases/lib/tst_test.sh tst_umount() · line 291
Quoted 3 lines
testcases/lib/tst_test.sh +1
-1while [ "$i" -lt 50 ]; do - if umount "$device"> /dev/null; then + if umount "$device"/> /dev/null; thenWith removing
this(we don't need add "/" here), this patch looks good to me+1
Actually we need to keep / for next patch, right? (cgroup/)
I guess our ltp
tst_umountapi should support to umount cgroup or cgroup/ like umount command does.
Also the patch always added trailing /:
+ if umount "$device"/ > /dev/null; then
if we keep that, the second patch wouldn't have to add it to "tst_umount cgroup/" call ("tst_umount cgroup" would be enough).
I'm not sure if we want it. @Cyril?
Quoted 5 lines
testcases/lib/tst_test.sh tst_umount() · line 290
Quoted 3 lines
Thus why not just changing argument for grep?
testcases/lib/tst_test.sh +1
-1- if ! grep -q "$device" /proc/mounts; then + if ! grep -q "${device%/}" /proc/mounts; thenYes, it is more easier. But I think it still existed the problme when we only use "/" parameters. I guess we should reject this situation.
I would not care about it. 1) no test does 'tst_umount /' 2) error reporting would be correct: umount: /: target is busy.
Kind regards,
Petr
Quoted 17 lines
code maybe as below:
testcases/lib/tst_test.sh +6
-1@@ -282,7 +282,12 @@ tst_umount() [ -z "$device" ] && return - if ! grep -q "$device" /proc/mounts; then + if [ "$device" = "/" ]; then + tst_res TINFO "We can not umount / directory" + return + fi + + if ! grep -q "${device%/}" /proc/mounts; then tst_res TINFO "The $device is not mounted, skipping umount" return fi
PATCH v3 1/2 lib/tst_test.sh: Make tst_umount work with argument that has trailing slash
In reply to Leo LiangHi,
...
testcases/lib/tst_test.sh tst_umount() · line 292
Quoted 3 lines
testcases/lib/tst_test.sh +1
-1while [ "$i" -lt 50 ]; do - if umount "$device" > /dev/null; then + if umount "$device"/ > /dev/null; then
nit: although previous is working, I'd prefer "$device/"
Kind regards,
Petr
PATCH v3 1/2 lib/tst_test.sh: Make tst_umount work with argument that has trailing slash
In reply to Petr VorelHi all,
Quoted 32 lines · Petr Vorel
Hi all,
Quoted 29 lines
Quoted 29 lines
Hi Leo
Quoted 27 lines
/proc/mountsshows the mount point without trailing slashes, e.g. ~ $ cat/proc/mounts
xxx/root/cgroupcgroup rw,relatime,cpu 0 0So current
tst_umountwould not work with argument that has trailing slash, e.g.tst_umountcgroup/ would give "The device is not mounted".Fix this by filtering out the trailing slash before grepping
/proc/mounts.Signed-off-by Leo Yu-Chi Liang<[email protected]>--- testcases/lib/tst_test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)testcases/lib/tst_test.sh +1
-0@@ -282,13 +282,14 @@ tst_umount() [ -z "$device" ]&& return + device=${device%/} if ! grep -q "$device" /proc/mounts; then tst_res TINFO "The $device is not mounted, skipping umount" return fi
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
testcases/lib/tst_test.sh tst_umount() · line 291
Quoted 3 lines
testcases/lib/tst_test.sh +1
-1while [ "$i" -lt 50 ]; do - if umount "$device"> /dev/null; then + if umount "$device"/> /dev/null; thenWith removing
this(we don't need add "/" here), this patch looks good to me+1
Actually we need to keep / for next patch, right? (cgroup/)
Yes, I thought so as well, for commit 46172493.
Review
Quoted 3 lines
Thus why not just changing argument for grep?
(quoted diff) +1
-1- if ! grep -q "$device" /proc/mounts; then + if ! grep -q "${device%/}" /proc/mounts; then
Thanks! That's a better way to do it.
Will send a v4 patch later with this modification.
Best regards,
Leo
Quoted 12 lines
Kind regards,
PetrQuoted 8 lines
Reviewed-by Petr Vorel <[email protected]>Kind regards,
PetrQuoted 3 lines
Reviewed-by Yang Xu <[email protected]>Quoted 2 lines
testcases/lib/tst_test.sh +0
-0return fi