[LTP] [PATCH 1/3] quotactl: Move do_mount() to header
Petr Vorel
pvorel@suse.cz
Wed Feb 23 16:32:41 CET 2022
This allows do_mount() to be reusable in quotactl08.c and quotactl09.c.
Add inline keyword to it and to the other two functions (to follow LTP
convention).
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
.../kernel/syscalls/quotactl/quotactl04.c | 25 ++-----------------
.../syscalls/quotactl/quotactl_syscall_var.h | 25 +++++++++++++++++--
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c
index 55da282705..f45ee43960 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl04.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl04.c
@@ -25,7 +25,6 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
-#include <sys/mount.h>
#include "tst_test.h"
#include "quotactl_syscall_var.h"
@@ -95,28 +94,6 @@ static struct tcase {
};
-static void do_mount(const char *source, const char *target,
- const char *filesystemtype, unsigned long mountflags,
- const void *data)
-{
- TEST(mount(source, target, filesystemtype, mountflags, data));
-
- if (TST_RET == -1 && TST_ERR == ESRCH)
- tst_brk(TCONF, "Kernel or device does not support FS quotas");
-
- if (TST_RET == -1) {
- tst_brk(TBROK | TTERRNO, "mount(%s, %s, %s, %lu, %p) failed",
- source, target, filesystemtype, mountflags, data);
- }
-
- if (TST_RET) {
- tst_brk(TBROK | TTERRNO, "mount(%s, %s, %s, %lu, %p) failed",
- source, target, filesystemtype, mountflags, data);
- }
-
- mount_flag = 1;
-}
-
static void setup(void)
{
const char *const fs_opts[] = {"-I 256", "-O quota,project", NULL};
@@ -124,6 +101,8 @@ static void setup(void)
quotactl_info();
SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+ mount_flag = 1;
+
fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
}
diff --git a/testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h b/testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h
index 3d1a2c8f5a..ba25fd9936 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h
+++ b/testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h
@@ -7,6 +7,7 @@
#ifndef LTP_QUOTACTL_SYSCALL_VAR_H
#define LTP_QUOTACTL_SYSCALL_VAR_H
+#include <sys/mount.h>
#include "lapi/quotactl.h"
#define QUOTACTL_SYSCALL_VARIANTS 2
@@ -14,14 +15,14 @@
static int fd = -1;
-static int do_quotactl(int fd, int cmd, const char *special, int id, caddr_t addr)
+static inline int do_quotactl(int fd, int cmd, const char *special, int id, caddr_t addr)
{
if (tst_variant == 0)
return quotactl(cmd, special, id, addr);
return quotactl_fd(fd, cmd, id, addr);
}
-static void quotactl_info(void)
+static inline void quotactl_info(void)
{
if (tst_variant == 0)
tst_res(TINFO, "Test quotactl()");
@@ -29,4 +30,24 @@ static void quotactl_info(void)
tst_res(TINFO, "Test quotactl_fd()");
}
+static inline void do_mount(const char *source, const char *target,
+ const char *filesystemtype, unsigned long mountflags,
+ const void *data)
+{
+ TEST(mount(source, target, filesystemtype, mountflags, data));
+
+ if (TST_RET == -1 && TST_ERR == ESRCH)
+ tst_brk(TCONF, "Kernel or device does not support FS quotas");
+
+ if (TST_RET == -1) {
+ tst_brk(TBROK | TTERRNO, "mount(%s, %s, %s, %lu, %p) failed",
+ source, target, filesystemtype, mountflags, data);
+ }
+
+ if (TST_RET) {
+ tst_brk(TBROK | TTERRNO, "mount(%s, %s, %s, %lu, %p) failed",
+ source, target, filesystemtype, mountflags, data);
+ }
+}
+
#endif /* LTP_QUOTACTL_SYSCALL_VAR_H */
--
2.35.1
More information about the ltp
mailing list