Skip to content

Commit 3490c28

Browse files
Murphy Zhouwangli5665
Murphy Zhou
authored andcommitted
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. Suggested-by: Martin Doucha <mdoucha@suse.cz> Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com> Reviewed-by: Li Wang <liwang@redhat.com>
1 parent 97c2fdb commit 3490c28

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/safe_macros.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,16 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
898898
const void *data)
899899
{
900900
int rval = -1;
901+
char mpath[PATH_MAX];
901902

903+
if (realpath(target, mpath)) {
904+
tst_resm_(file, lineno, TINFO,
905+
"Mounting %s to %s fstyp=%s flags=%lx",
906+
source, mpath, filesystemtype, mountflags);
907+
} else {
908+
tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
909+
"Cannot resolve the absolute path of %s", target);
910+
}
902911
/*
903912
* Don't try using the kernel's NTFS driver when mounting NTFS, since
904913
* 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),
948957
const char *target)
949958
{
950959
int rval;
960+
char mpath[PATH_MAX];
961+
962+
if (realpath(target, mpath)) {
963+
tst_resm_(file, lineno, TINFO, "Umounting %s", mpath);
964+
} else {
965+
tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
966+
"Cannot resolve the absolute path of %s", target);
967+
}
951968

952969
rval = tst_umount(target);
953970

0 commit comments

Comments
 (0)