selftests: use shared header

So that we don't have to redefine the same system calls over and over.

Link: https://lore.kernel.org/r/20241014-work-overlayfs-v3-4-32b3fed1286e@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Christian Brauner 2024-10-14 11:40:59 +02:00
parent a89ed67d3c
commit e94fdd5d9a
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
2 changed files with 44 additions and 26 deletions

View File

@ -17,32 +17,7 @@
#include "../../kselftest.h"
#include "log.h"
static int sys_fsopen(const char *fsname, unsigned int flags)
{
return syscall(__NR_fsopen, fsname, flags);
}
static int sys_fsconfig(int fd, unsigned int cmd, const char *key, const char *value, int aux)
{
return syscall(__NR_fsconfig, fd, cmd, key, value, aux);
}
static int sys_fsmount(int fd, unsigned int flags, unsigned int attr_flags)
{
return syscall(__NR_fsmount, fd, flags, attr_flags);
}
static int sys_mount(const char *src, const char *tgt, const char *fst,
unsigned long flags, const void *data)
{
return syscall(__NR_mount, src, tgt, fst, flags, data);
}
static int sys_move_mount(int from_dfd, const char *from_pathname,
int to_dfd, const char *to_pathname,
unsigned int flags)
{
return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd, to_pathname, flags);
}
#include "wrappers.h"
static long get_file_dev_and_inode(void *addr, struct statx *stx)
{

View File

@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-2.0
//
#ifndef __SELFTEST_OVERLAYFS_WRAPPERS_H__
#define __SELFTEST_OVERLAYFS_WRAPPERS_H__
#define _GNU_SOURCE
#include <linux/types.h>
#include <linux/mount.h>
#include <sys/syscall.h>
static inline int sys_fsopen(const char *fsname, unsigned int flags)
{
return syscall(__NR_fsopen, fsname, flags);
}
static inline int sys_fsconfig(int fd, unsigned int cmd, const char *key,
const char *value, int aux)
{
return syscall(__NR_fsconfig, fd, cmd, key, value, aux);
}
static inline int sys_fsmount(int fd, unsigned int flags,
unsigned int attr_flags)
{
return syscall(__NR_fsmount, fd, flags, attr_flags);
}
static inline int sys_mount(const char *src, const char *tgt, const char *fst,
unsigned long flags, const void *data)
{
return syscall(__NR_mount, src, tgt, fst, flags, data);
}
static inline int sys_move_mount(int from_dfd, const char *from_pathname,
int to_dfd, const char *to_pathname,
unsigned int flags)
{
return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd,
to_pathname, flags);
}
#endif