Skip to content

Commit e94fdd5

Browse files
committed
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/[email protected] Reviewed-by: Amir Goldstein <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent a89ed67 commit e94fdd5

File tree

2 files changed

+44
-26
lines changed

2 files changed

+44
-26
lines changed

tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,7 @@
1717

1818
#include "../../kselftest.h"
1919
#include "log.h"
20-
21-
static int sys_fsopen(const char *fsname, unsigned int flags)
22-
{
23-
return syscall(__NR_fsopen, fsname, flags);
24-
}
25-
26-
static int sys_fsconfig(int fd, unsigned int cmd, const char *key, const char *value, int aux)
27-
{
28-
return syscall(__NR_fsconfig, fd, cmd, key, value, aux);
29-
}
30-
31-
static int sys_fsmount(int fd, unsigned int flags, unsigned int attr_flags)
32-
{
33-
return syscall(__NR_fsmount, fd, flags, attr_flags);
34-
}
35-
static int sys_mount(const char *src, const char *tgt, const char *fst,
36-
unsigned long flags, const void *data)
37-
{
38-
return syscall(__NR_mount, src, tgt, fst, flags, data);
39-
}
40-
static int sys_move_mount(int from_dfd, const char *from_pathname,
41-
int to_dfd, const char *to_pathname,
42-
unsigned int flags)
43-
{
44-
return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd, to_pathname, flags);
45-
}
20+
#include "wrappers.h"
4621

4722
static long get_file_dev_and_inode(void *addr, struct statx *stx)
4823
{
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
//
3+
#ifndef __SELFTEST_OVERLAYFS_WRAPPERS_H__
4+
#define __SELFTEST_OVERLAYFS_WRAPPERS_H__
5+
6+
#define _GNU_SOURCE
7+
8+
#include <linux/types.h>
9+
#include <linux/mount.h>
10+
#include <sys/syscall.h>
11+
12+
static inline int sys_fsopen(const char *fsname, unsigned int flags)
13+
{
14+
return syscall(__NR_fsopen, fsname, flags);
15+
}
16+
17+
static inline int sys_fsconfig(int fd, unsigned int cmd, const char *key,
18+
const char *value, int aux)
19+
{
20+
return syscall(__NR_fsconfig, fd, cmd, key, value, aux);
21+
}
22+
23+
static inline int sys_fsmount(int fd, unsigned int flags,
24+
unsigned int attr_flags)
25+
{
26+
return syscall(__NR_fsmount, fd, flags, attr_flags);
27+
}
28+
29+
static inline int sys_mount(const char *src, const char *tgt, const char *fst,
30+
unsigned long flags, const void *data)
31+
{
32+
return syscall(__NR_mount, src, tgt, fst, flags, data);
33+
}
34+
35+
static inline int sys_move_mount(int from_dfd, const char *from_pathname,
36+
int to_dfd, const char *to_pathname,
37+
unsigned int flags)
38+
{
39+
return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd,
40+
to_pathname, flags);
41+
}
42+
43+
#endif

0 commit comments

Comments
 (0)