Message ID | 20250415013944.173030-2-wegao@suse.com |
---|---|
State | Accepted |
Headers | show |
Series | ioctl_fiemap01: New test for fiemap ioctl() | expand |
Context | Check | Description |
---|---|---|
acer/debian_stable_s390x-linux-gnu-gcc_s390x | success | success |
acer/debian_stable_aarch64-linux-gnu-gcc_arm64 | success | success |
acer/debian_stable_powerpc64le-linux-gnu-gcc_ppc64el | success | success |
acer/ubuntu_jammy_gcc | success | success |
acer/debian_stable_gcc | success | success |
acer/debian_stable_gcc | success | success |
acer/ubuntu_bionic_gcc | success | success |
acer/quay-io-centos-centos_stream9_gcc | success | success |
acer/debian_testing_gcc | success | success |
acer/debian_testing_clang | success | success |
acer/opensuse-leap_latest_gcc | success | success |
acer/opensuse-archive_42-2_gcc | success | success |
acer/fedora_latest_clang | success | success |
acer/debian_oldstable_clang | success | success |
acer/debian_oldstable_gcc | success | success |
acer/alpine_latest_gcc | success | success |
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h index 3b02f86c7..19504beb5 100644 --- a/include/tst_safe_macros.h +++ b/include/tst_safe_macros.h @@ -12,6 +12,7 @@ #include <sys/time.h> #include <sys/resource.h> #include <sys/stat.h> +#include <sys/statvfs.h> #include <sys/vfs.h> #include <sys/sysinfo.h> #include <sys/uio.h> @@ -503,4 +504,9 @@ char *safe_ptsname(const char *const file, const int lineno, int masterfd); #define SAFE_PTSNAME(masterfd) \ safe_ptsname(__FILE__, __LINE__, (masterfd)) +int safe_statvfs(const char *file, const int lineno, + const char *path, struct statvfs *buf); +#define SAFE_STATVFS(path, buf) \ + safe_statvfs(__FILE__, __LINE__, (path), (buf)) + #endif /* TST_SAFE_MACROS_H__ */ diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c index ba095a621..cdc8c7dd3 100644 --- a/lib/tst_safe_macros.c +++ b/lib/tst_safe_macros.c @@ -810,3 +810,22 @@ char *safe_ptsname(const char *const file, const int lineno, int masterfd) return name; } + +int safe_statvfs(const char *file, const int lineno, + const char *path, struct statvfs *buf) +{ + int rval; + + rval = statvfs(path, buf); + + if (rval == -1) { + tst_brk_(file, lineno, TBROK | TERRNO, + "statvfs(%s,%p) failed", path, buf); + } else if (rval) { + tst_brk_(file, lineno, TBROK | TERRNO, + "Invalid statvfs(%s,%p) return value %d", path, buf, + rval); + } + + return rval; +}