Skip to content

Commit

Permalink
safe_mount: safe_umount: print debug info about the operation
Browse files Browse the repository at this point in the history
Make the source and the target to mount/umount visible. It's
good for debugging.

Suggested-by: Martin Doucha <[email protected]>
Signed-off-by: Murphy Zhou <[email protected]>
Reviewed-by: Li Wang <[email protected]>
  • Loading branch information
Murphy Zhou authored and wangli5665 committed Jun 16, 2023
1 parent 97c2fdb commit 3490c28
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/safe_macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_brkm_(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.
Expand Down Expand Up @@ -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_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
"Cannot resolve the absolute path of %s", target);
}

rval = tst_umount(target);

Expand Down

0 comments on commit 3490c28

Please sign in to comment.