Path: blob/master/tools/testing/selftests/filesystems/wrappers.h
26298 views
// SPDX-License-Identifier: GPL-2.01//2#ifndef __SELFTEST_OVERLAYFS_WRAPPERS_H__3#define __SELFTEST_OVERLAYFS_WRAPPERS_H__45#define _GNU_SOURCE67#include <linux/types.h>8#include <linux/mount.h>9#include <sys/syscall.h>1011#ifndef STATX_MNT_ID_UNIQUE12#define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */13#endif1415static inline int sys_fsopen(const char *fsname, unsigned int flags)16{17return syscall(__NR_fsopen, fsname, flags);18}1920static inline int sys_fsconfig(int fd, unsigned int cmd, const char *key,21const char *value, int aux)22{23return syscall(__NR_fsconfig, fd, cmd, key, value, aux);24}2526static inline int sys_fsmount(int fd, unsigned int flags,27unsigned int attr_flags)28{29return syscall(__NR_fsmount, fd, flags, attr_flags);30}3132static inline int sys_mount(const char *src, const char *tgt, const char *fst,33unsigned long flags, const void *data)34{35return syscall(__NR_mount, src, tgt, fst, flags, data);36}3738#ifndef MOVE_MOUNT_F_EMPTY_PATH39#define MOVE_MOUNT_F_EMPTY_PATH 0x00000004 /* Empty from path permitted */40#endif4142#ifndef MOVE_MOUNT_T_EMPTY_PATH43#define MOVE_MOUNT_T_EMPTY_PATH 0x00000040 /* Empty to path permitted */44#endif4546#ifndef __NR_move_mount47#if defined __alpha__48#define __NR_move_mount 53949#elif defined _MIPS_SIM50#if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */51#define __NR_move_mount 442952#endif53#if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */54#define __NR_move_mount 642955#endif56#if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */57#define __NR_move_mount 542958#endif59#else60#define __NR_move_mount 42961#endif62#endif6364static inline int sys_move_mount(int from_dfd, const char *from_pathname,65int to_dfd, const char *to_pathname,66unsigned int flags)67{68return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd,69to_pathname, flags);70}7172#ifndef OPEN_TREE_CLONE73#define OPEN_TREE_CLONE 174#endif7576#ifndef OPEN_TREE_CLOEXEC77#define OPEN_TREE_CLOEXEC O_CLOEXEC78#endif7980#ifndef AT_RECURSIVE81#define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */82#endif8384#ifndef __NR_open_tree85#if defined __alpha__86#define __NR_open_tree 53887#elif defined _MIPS_SIM88#if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */89#define __NR_open_tree 442890#endif91#if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */92#define __NR_open_tree 642893#endif94#if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */95#define __NR_open_tree 542896#endif97#else98#define __NR_open_tree 42899#endif100#endif101102static inline int sys_open_tree(int dfd, const char *filename, unsigned int flags)103{104return syscall(__NR_open_tree, dfd, filename, flags);105}106107#endif108109110