Skip to contentSkip to conversation

safe_mount: safe_umount: print debug info about the operation

PATCH In review Murphy Zhou 3 participants 6 messages Jun 15, 2023 – Jun 16, 2023 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 safe_mount: safe_umount: print debug info about the operation

Make the source and the target to mount/umount visible. It's good for debugging.

---
v3:
Apply suggestions from Li and Martin. Thanks very much!

 lib/safe_macros.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
lib/safe_macros.c +17 -0
index af6dd0716..26f9136af 100644
@@ -898,7 +898,16 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
 	       const void *data)
 {
 	int rval = -1;
+	char mpath[PATH_MAX];
 
+	if (realpath(target, mpath)) {
+		tst_resm_(file, lineno, TINFO,
+			"Mounting %s to %s fstyp=%s flags=%lx",
+			source, mpath, filesystemtype, mountflags);
+	} else {
+		tst_resm_(file, lineno, TBROK | TERRNO, cleanup_fn,
+			"Cannot resolve the absolute path of %s", target);
+	}
 	/*
 	 * Don't try using the kernel's NTFS driver when mounting NTFS, since
 	 * the kernel's NTFS driver doesn't have proper write support.
@@ -948,6 +957,14 @@ int safe_umount(const char *file, const int lineno, void (*cleanup_fn)(void),
 		const char *target)
 {
 	int rval;
+	char mpath[PATH_MAX];
+
+	if (realpath(target, mpath)) {
+		tst_resm_(file, lineno, TINFO, "Umounting %s", mpath);
+	} else {
+		tst_resm_(file, lineno, TBROK | TERRNO, cleanup_fn,
+			"Cannot resolve the absolute path of %s", target);
+	}
 
 	rval = tst_umount(target);
 
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Patch applied, thanks!

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
In reply to Murphy Zhou
Quoted 19 lines · Murphy Zhou

Make the source and the target to mount/umount visible. It's good for debugging.

---
v3:
Apply suggestions from Li and Martin. Thanks very much!

 lib/safe_macros.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
lib/safe_macros.c +0 -0
index af6dd0716..26f9136af 100644
@@ -898,7 +898,16 @@ int safe_mount(const char *file, const int lineno,
 void (*cleanup_fn)(void),
               const void *data)
 {

lib/safe_macros.c int safe_mount(const char *file, const int lineno, · line 910

Quoted 10 lines
lib/safe_macros.c +7 -0
        int rval = -1;
+       char mpath[PATH_MAX];
 
+       if (realpath(target, mpath)) {
+               tst_resm_(file, lineno, TINFO,
+                       "Mounting %s to %s fstyp=%s flags=%lx",
+                       source, mpath, filesystemtype, mountflags);
+       } else {
+               tst_resm_(file, lineno, TBROK | TERRNO, cleanup_fn,
 

Forget to mention that, this should be tst_brkm_(.., TBROK | TERRNO, ...), I manually fix it and pushed.

Quoted 8 lines
lib/safe_macros.c +2 -0
+                       "Cannot resolve the absolute path of %s", target);
+       }
        /*

* Don't try using the kernel's NTFS driver when mounting NTFS,
since
* the kernel's NTFS driver doesn't have proper write support.

lib/safe_macros.c +0 -0
@@ -948,6 +957,14 @@ int safe_umount(const char *file, const int lineno,
 void (*cleanup_fn)(void),

lib/safe_macros.c int safe_umount(const char *file, const int lineno, · line 967

Quoted 10 lines
lib/safe_macros.c +6 -0
                const char *target)
 {
        int rval;
+       char mpath[PATH_MAX];
+
+       if (realpath(target, mpath)) {
+               tst_resm_(file, lineno, TINFO, "Umounting %s", mpath);
+       } else {
+               tst_resm_(file, lineno, TBROK | TERRNO, cleanup_fn,
 

tst_brkm_()

Quoted 13 lines
lib/safe_macros.c +2 -0
+                       "Cannot resolve the absolute path of %s", target);
+       }
 
        rval = tst_umount(target);

--
2.31.1

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
Quoted 24 lines · Li Wang
Quoted 22 lines · Murphy Zhou

Make the source and the target to mount/umount visible. It's good for debugging.

---
v3:
Apply suggestions from Li and Martin. Thanks very much!

  lib/safe_macros.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
lib/safe_macros.c +1 -0
index af6dd0716..26f9136af 100644
@@ -898,7 +898,16 @@ int safe_mount(const char *file, const int lineno,
 void (*cleanup_fn)(void),
                const void *data)
  {
         int rval = -1;
+       char mpath[PATH_MAX];
 
Quoted 10 lines

lib/safe_macros.c int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),

Quoted 7 lines
lib/safe_macros.c +6 -0
+       if (realpath(target, mpath)) {
+               tst_resm_(file, lineno, TINFO,
+                       "Mounting %s to %s fstyp=%s flags=%lx",
+                       source, mpath, filesystemtype, mountflags);
+       } else {
+               tst_resm_(file, lineno, TBROK | TERRNO, cleanup_fn,
 

Forget to mention that, this should be tst_brkm_(.., TBROK | TERRNO, ...), I manually fix it and pushed.

I thought my review of the v2 patch was clear enough that both branches of this condition should call tst_resm_(... TINFO ...). There is no reason to fail the test here.

Signature · 11 lines
Martin Doucha   [email protected]
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw
Quoted 35 lines · Martin Doucha
Quoted 1 line · Li Wang

On Thu, Jun 15, 2023 at 9:24 AM Murphy Zhou <[email protected]>

Quoted 23 lines · wrote:
Quoted 23 lines

Make the source and the target to mount/umount visible. It's good for debugging.

---
v3:
Apply suggestions from Li and Martin. Thanks very much!

  lib/safe_macros.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
lib/safe_macros.c +1 -0
index af6dd0716..26f9136af 100644
@@ -898,7 +898,16 @@ int safe_mount(const char *file, const int lineno,
 void (*cleanup_fn)(void),
                const void *data)
  {
         int rval = -1;
+       char mpath[PATH_MAX];
 
Quoted 9 lines

lib/safe_macros.c int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),

Quoted 7 lines
lib/safe_macros.c +6 -0
+       if (realpath(target, mpath)) {
+               tst_resm_(file, lineno, TINFO,
+                       "Mounting %s to %s fstyp=%s flags=%lx",
+                       source, mpath, filesystemtype, mountflags);
+       } else {
+               tst_resm_(file, lineno, TBROK | TERRNO, cleanup_fn,
 

Forget to mention that, this should be tst_brkm_(.., TBROK | TERRNO,

Quoted 7 lines

...),

Quoted 1 line

I manually fix it and pushed.

I thought my review of the v2 patch was clear enough that both branches of this condition should call tst_resm_(... TINFO ...). There is no reason to fail the test here.

Ah, sorry for overlooking that. I saw here that used tst_resm_( ...TBRK ...) which is not the correct usage. So I guess he might want tst_brkm_(), but anyway you are right. Let's fix it in a separate patch.

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

My bad.. I should have changed it to TINFO|TERRNO.. Thanks all!

Quoted 54 lines · Li Wang
Quoted 37 lines · Martin Doucha
Quoted 24 lines · Li Wang
Quoted 22 lines · Murphy Zhou

Make the source and the target to mount/umount visible. It's good for debugging.

---
v3:
Apply suggestions from Li and Martin. Thanks very much!

  lib/safe_macros.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
lib/safe_macros.c +1 -0
index af6dd0716..26f9136af 100644
@@ -898,7 +898,16 @@ int safe_mount(const char *file, const int lineno,
 void (*cleanup_fn)(void),
                const void *data)
  {
         int rval = -1;
+       char mpath[PATH_MAX];
 
Quoted 10 lines

lib/safe_macros.c int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),

Quoted 7 lines
lib/safe_macros.c +6 -0
+       if (realpath(target, mpath)) {
+               tst_resm_(file, lineno, TINFO,
+                       "Mounting %s to %s fstyp=%s flags=%lx",
+                       source, mpath, filesystemtype, mountflags);
+       } else {
+               tst_resm_(file, lineno, TBROK | TERRNO, cleanup_fn,
 

Forget to mention that, this should be tst_brkm_(.., TBROK | TERRNO, ...), I manually fix it and pushed.

Quoted 3 lines

I thought my review of the v2 patch was clear enough that both branches of this condition should call tst_resm_(... TINFO ...). There is no reason to fail the test here.

Ah, sorry for overlooking that. I saw here that used tst_resm_( ...TBRK ...) which is not the correct usage. So I guess he might want tst_brkm_(), but anyway you are right. Let's fix it in a separate patch.

--
Regards,
Li Wang

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp