Signed-off-by: Matus Marhefka <mmarh...@redhat.com> --- include/safe_macros.h | 8 ++++++++ lib/safe_macros.c | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+)
diff --git a/include/safe_macros.h b/include/safe_macros.h index 5ee4d42..4648f2a 100644 --- a/include/safe_macros.h +++ b/include/safe_macros.h @@ -363,6 +363,14 @@ static inline off_t safe_lseek(const char *file, const int lineno, #define SAFE_LSEEK(cleanup_fn, fd, offset, whence) \ safe_lseek(__FILE__, __LINE__, cleanup_fn, (fd), (offset), (whence)) +int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void), + const char *source, const char *target, + const char *filesystemtype, unsigned long mountflags, + const void *data); +#define SAFE_MOUNT(cleanup_fn, source, target, filesystemtype, \ + mountflags, data) \ + safe_mount(__FILE__, __LINE__, (cleanup_fn), (source), (target), \ + (filesystemtype), (mountflags), (data)) #endif /* __SAFE_MACROS_H__ */ #endif /* __TEST_H__ */ diff --git a/lib/safe_macros.c b/lib/safe_macros.c index 76d781f..c949826 100644 --- a/lib/safe_macros.c +++ b/lib/safe_macros.c @@ -4,6 +4,7 @@ #include <sys/resource.h> #include <sys/stat.h> #include <sys/wait.h> +#include <sys/mount.h> #include <errno.h> #include <fcntl.h> #include <libgen.h> @@ -675,3 +676,22 @@ int safe_rename(const char *file, const int lineno, void (*cleanup_fn)(void), return rval; } + +int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void), + const char *source, const char *target, + const char *filesystemtype, unsigned long mountflags, + const void *data) +{ + int rval; + + rval = mount(source, target, filesystemtype, mountflags, data); + + if (rval == -1) { + tst_brkm(TBROK | TERRNO, cleanup_fn, + "%s:%d: mount(%s, %s, %s, %lu, %p) failed", + file, lineno, source, target, filesystemtype, + mountflags, data); + } + + return rval; +} -- 1.8.3.1 ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list