Commit df1524a9 authored by Ramon Nou's avatar Ramon Nou
Browse files

Merge branch 'sys_intercept_reb' into 'dev'

Sys intercept

See merge request !10
parents 70acd5f8 015435b6
Pipeline #332 passed with stages
in 7 minutes and 39 seconds
find_package(PkgConfig)
pkg_check_modules(PC_Syscall_intercept QUIET libsyscall_intercept)
find_path(Syscall_intercept_INCLUDE_DIR
NAMES libsyscall_intercept_hook_point.h
PATHS ${PC_Syscall_intercept_INCLUDE_DIRS}
)
find_library(Syscall_intercept_LIBRARY
NAMES syscall_intercept
PATHS ${PC_Syscall_intercept_LIBRARY_DIRS}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Syscall_intercept
DEFAULT_MSG
Syscall_intercept_INCLUDE_DIR
Syscall_intercept_LIBRARY
)
if(Syscall_intercept_FOUND)
set(Syscall_intercept_LIBRARIES ${Syscall_intercept_LIBRARY})
set(Syscall_intercept_INCLUDE_DIRS ${Syscall_intercept_INCLUDE_DIR})
set(Syscall_intercept_DEFINITIONS ${PC_Syscall_intercept_CFLAGS_OTHER})
if(NOT TARGET Syscall_intercept::Syscall_intercept)
add_library(Syscall_intercept::Syscall_intercept UNKNOWN IMPORTED)
set_target_properties(Syscall_intercept::Syscall_intercept PROPERTIES
IMPORTED_LOCATION "${Syscall_intercept_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_Syscall_intercept_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${Syscall_intercept_INCLUDE_DIR}"
)
endif()
endif()
mark_as_advanced(
Syscall_intercept_INCLUDE_DIR
Syscall_intercept_LIBRARY
)
......@@ -83,6 +83,7 @@ find_package(RocksDB REQUIRED)
find_package(Mercury REQUIRED)
find_package(Abt REQUIRED)
find_package(Margo REQUIRED)
find_package(Syscall_intercept REQUIRED)
# boost dependencies, system is required for filesystem
find_package(Boost 1.53 REQUIRED
......
......@@ -135,7 +135,7 @@ GKFS_LOG_LEVEL={off,critical,err,warn,info,debug,trace} to set the trace level v
Numbers from 0-6 may also be used where as 0 is off and 6 represents trace.
### Acknoledgment
### Acknowledgment
This software was partially supported by the EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).
......
......@@ -65,7 +65,9 @@ ssize_t adafs_read(int fd, void* buf, size_t count);
int adafs_opendir(const std::string& path);
struct dirent * adafs_readdir(int fd);
int getdents(unsigned int fd,
struct linux_dirent *dirp,
unsigned int count);
int adafs_rmdir(const std::string& path);
......
/*
Copyright 2018-2019, Barcelona Supercomputing Center (BSC), Spain
Copyright 2015-2019, Johannes Gutenberg Universitaet Mainz, Germany
This software was partially supported by the
EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).
This software was partially supported by the
ADA-FS project under the SPPEXA project funded by the DFG.
SPDX-License-Identifier: MIT
*/
#ifndef IFS_HOOKS_HPP
#define IFS_HOOKS_HPP
#include <fcntl.h>
int hook_openat(int dirfd, const char *cpath, int flags, mode_t mode);
int hook_close(int fd);
int hook_stat(const char* path, struct stat* buf);
int hook_lstat(const char* path, struct stat* buf);
int hook_fstat(unsigned int fd, struct stat* buf);
int hook_fstatat(int dirfd, const char * cpath, struct stat * buf, int flags);
int hook_read(unsigned int fd, void* buf, size_t count);
int hook_pread(unsigned int fd, char * buf, size_t count, loff_t pos);
int hook_write(unsigned int fd, const char * buf, size_t count);
int hook_pwrite(unsigned int fd, const char * buf, size_t count, loff_t pos);
int hook_writev(unsigned long fd, const struct iovec * iov, unsigned long iovcnt);
int hook_pwritev(unsigned long fd, const struct iovec * iov, unsigned long iovcnt,
unsigned long pos_l, unsigned long pos_h);
int hook_unlinkat(int dirfd, const char * cpath, int flags);
int hook_symlinkat(const char * oldname, int newdfd, const char * newname);
int hook_access(const char* path, int mask);
int hook_faccessat(int dirfd, const char * cpath, int mode);
int hook_lseek(unsigned int fd, off_t offset, unsigned int whence);
int hook_truncate(const char *path, long length);
int hook_ftruncate(unsigned int fd, unsigned long length);
int hook_dup(unsigned int fd);
int hook_dup2(unsigned int oldfd, unsigned int newfd);
int hook_dup3(unsigned int oldfd, unsigned int newfd, int flags);
int hook_getdents(unsigned int fd, struct linux_dirent *dirp, unsigned int count);
int hook_mkdirat(int dirfd, const char * cpath, mode_t mode);
int hook_fchmodat(int dirfd, const char* path, mode_t mode);
int hook_fchmod(unsigned int dirfd, mode_t mode);
int hook_chdir(const char* path);
int hook_fchdir(unsigned int fd);
int hook_getcwd(char * buf, unsigned long size);
int hook_readlinkat(int dirfd, const char * cpath, char * buf, int bufsiz);
int hook_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
int hook_renameat(int olddfd, const char * oldname, int newdfd, const char * newname,
unsigned int flags);
int hook_statfs(const char * path, struct statfs * buf);
int hook_fstatfs(unsigned int fd, struct statfs * buf);
#endif
/*
Copyright 2018-2019, Barcelona Supercomputing Center (BSC), Spain
Copyright 2015-2019, Johannes Gutenberg Universitaet Mainz, Germany
This software was partially supported by the
EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).
This software was partially supported by the
ADA-FS project under the SPPEXA project funded by the DFG.
SPDX-License-Identifier: MIT
*/
#ifndef IFS_INTERCEPT_HPP
#define IFS_INTERCEPT_HPP
int
hook_guard_wrapper(long syscall_number,
long arg0, long arg1, long arg2,
long arg3, long arg4, long arg5,
long *syscall_return_value);
void start_interception();
void stop_interception();
#endif
......@@ -23,28 +23,25 @@
#include <client/open_file_map.hpp>
class OpenDir: public OpenFile {
class DirEntry {
private:
std::string name_;
FileType type_;
public:
DirEntry(const std::string& name, const FileType type);
const std::string& name();
FileType type();
};
class DirEntry {
public:
std::string name;
FileType type;
DirEntry(const std::string& name, const FileType type);
};
class OpenDir: public OpenFile {
private:
std::vector<DirEntry> entries;
struct dirent dirent_;
bool is_dirent_valid;
void update_dirent(unsigned int pos);
public:
OpenDir(const std::string& path);
void add(const std::string& name, const FileType& type);
struct dirent * readdir();
const DirEntry& getdent(unsigned int pos);
size_t size();
};
......
......@@ -45,7 +45,7 @@ protected:
FileType type_;
std::string path_;
std::array<bool, static_cast<int>(OpenFile_flags::flag_count)> flags_ = {false};
off64_t pos_;
unsigned long pos_;
std::mutex pos_mutex_;
std::mutex flag_mutex_;
......@@ -61,9 +61,9 @@ public:
void path(const std::string& path_);
off64_t pos();
unsigned long pos();
void pos(off64_t pos_);
void pos(unsigned long pos_);
bool get_flag(OpenFile_flags flag);
......
/*
Copyright 2018-2019, Barcelona Supercomputing Center (BSC), Spain
Copyright 2015-2019, Johannes Gutenberg Universitaet Mainz, Germany
This software was partially supported by the
EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).
This software was partially supported by the
ADA-FS project under the SPPEXA project funded by the DFG.
SPDX-License-Identifier: MIT
*/
#ifndef IFS_PASSTHROUGH_HPP
#define IFS_PASSTHROUGH_HPP
#define LIBC_FUNC_NAME(FNAME) libc_##FNAME
#define LIBC_FUNC(FNAME, ...) \
((reinterpret_cast<decltype(&FNAME)>(libc_##FNAME))(__VA_ARGS__))
extern void* LIBC_FUNC_NAME(open);
extern void* LIBC_FUNC_NAME(openat);
extern void* LIBC_FUNC_NAME(fopen);
extern void* LIBC_FUNC_NAME(fopen64);
extern void* LIBC_FUNC_NAME(fread);
extern void* LIBC_FUNC_NAME(fwrite);
extern void* LIBC_FUNC_NAME(fclose);
extern void* LIBC_FUNC_NAME(clearerr);
extern void* LIBC_FUNC_NAME(feof);
extern void* LIBC_FUNC_NAME(ferror);
extern void* LIBC_FUNC_NAME(fileno);
extern void* LIBC_FUNC_NAME(fflush);
extern void* LIBC_FUNC_NAME(__fpurge);
extern void* LIBC_FUNC_NAME(setbuf);
extern void* LIBC_FUNC_NAME(setbuffer);
extern void* LIBC_FUNC_NAME(setlinebuf);
extern void* LIBC_FUNC_NAME(setvbuf);
extern void* LIBC_FUNC_NAME(putc);
extern void* LIBC_FUNC_NAME(fputc);
extern void* LIBC_FUNC_NAME(fputs);
extern void* LIBC_FUNC_NAME(getc);
extern void* LIBC_FUNC_NAME(fgetc);
extern void* LIBC_FUNC_NAME(fgets);
extern void* LIBC_FUNC_NAME(ungetc);
extern void* LIBC_FUNC_NAME(fseek);
extern void* LIBC_FUNC_NAME(mkdir);
extern void* LIBC_FUNC_NAME(mkdirat);
extern void* LIBC_FUNC_NAME(unlink);
extern void* LIBC_FUNC_NAME(unlinkat);
extern void* LIBC_FUNC_NAME(rmdir);
extern void* LIBC_FUNC_NAME(close);
extern void* LIBC_FUNC_NAME(access);
extern void* LIBC_FUNC_NAME(faccessat);
extern void* LIBC_FUNC_NAME(__xstat);
extern void* LIBC_FUNC_NAME(__xstat64);
extern void* LIBC_FUNC_NAME(__fxstat);
extern void* LIBC_FUNC_NAME(__fxstat64);
extern void* LIBC_FUNC_NAME(__fxstatat);
extern void* LIBC_FUNC_NAME(__fxstatat64);
extern void* LIBC_FUNC_NAME(__lxstat);
extern void* LIBC_FUNC_NAME(__lxstat64);
extern void* LIBC_FUNC_NAME(statfs);
extern void* LIBC_FUNC_NAME(fstatfs);
extern void* LIBC_FUNC_NAME(statvfs);
extern void* LIBC_FUNC_NAME(fstatvfs);
extern void* LIBC_FUNC_NAME(write);
extern void* LIBC_FUNC_NAME(pwrite);
extern void* LIBC_FUNC_NAME(pwrite64);
extern void* LIBC_FUNC_NAME(writev);
extern void* LIBC_FUNC_NAME(read);
extern void* LIBC_FUNC_NAME(pread);
extern void* LIBC_FUNC_NAME(pread64);
extern void* LIBC_FUNC_NAME(readv);
extern void* LIBC_FUNC_NAME(lseek);
extern void* LIBC_FUNC_NAME(lseek64);
extern void* LIBC_FUNC_NAME(fsync);
extern void* LIBC_FUNC_NAME(fdatasync);
extern void* LIBC_FUNC_NAME(truncate);
extern void* LIBC_FUNC_NAME(ftruncate);
extern void* LIBC_FUNC_NAME(fcntl);
extern void* LIBC_FUNC_NAME(dup);
extern void* LIBC_FUNC_NAME(dup2);
extern void* LIBC_FUNC_NAME(dup3);
extern void* LIBC_FUNC_NAME(dirfd);
extern void* LIBC_FUNC_NAME(opendir);
extern void* LIBC_FUNC_NAME(fdopendir);
extern void* LIBC_FUNC_NAME(readdir);
extern void* LIBC_FUNC_NAME(closedir);
extern void* LIBC_FUNC_NAME(chmod);
extern void* LIBC_FUNC_NAME(fchmod);
extern void* LIBC_FUNC_NAME(fchmodat);
extern void* LIBC_FUNC_NAME(chdir);
extern void* LIBC_FUNC_NAME(fchdir);
extern void* LIBC_FUNC_NAME(getcwd);
extern void* LIBC_FUNC_NAME(get_current_dir_name);
extern void* LIBC_FUNC_NAME(link);
extern void* LIBC_FUNC_NAME(linkat);
extern void* LIBC_FUNC_NAME(symlinkat);
extern void* LIBC_FUNC_NAME(readlinkat);
extern void* LIBC_FUNC_NAME(realpath);
void init_passthrough_if_needed();
#endif //IFS_PASSTHROUGH_HPP
/*
Copyright 2018-2019, Barcelona Supercomputing Center (BSC), Spain
Copyright 2015-2019, Johannes Gutenberg Universitaet Mainz, Germany
This software was partially supported by the
EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).
This software was partially supported by the
ADA-FS project under the SPPEXA project funded by the DFG.
SPDX-License-Identifier: MIT
*/
#ifndef IFS_SYSCALL_NAMES_HPP
#define IFS_SYSCALL_NAMES_HPP
const char* syscall_names[] = {
"read",
"write",
"open",
"close",
"stat",
"fstat",
"lstat",
"poll",
"lseek",
"mmap",
"mprotect",
"munmap",
"brk",
"rt_sigaction",
"rt_sigprocmask",
"rt_sigreturn",
"ioctl",
"pread64",
"pwrite64",
"readv",
"writev",
"access",
"pipe",
"select",
"sched_yield",
"mremap",
"msync",
"mincore",
"madvise",
"shmget",
"shmat",
"shmctl",
"dup",
"dup2",
"pause",
"nanosleep",
"getitimer",
"alarm",
"setitimer",
"getpid",
"sendfile",
"socket",
"connect",
"accept",
"sendto",
"recvfrom",
"sendmsg",
"recvmsg",
"shutdown",
"bind",
"listen",
"getsockname",
"getpeername",
"socketpair",
"setsockopt",
"getsockopt",
"clone",
"fork",
"vfork",
"execve",
"exit",
"wait4",
"kill",
"uname",
"semget",
"semop",
"semctl",
"shmdt",
"msgget",
"msgsnd",
"msgrcv",
"msgctl",
"fcntl",
"flock",
"fsync",
"fdatasync",
"truncate",
"ftruncate",
"getdents",
"getcwd",
"chdir",
"fchdir",
"rename",
"mkdir",
"rmdir",
"creat",
"link",
"unlink",
"symlink",
"readlink",
"chmod",
"fchmod",
"chown",
"fchown",
"lchown",
"umask",
"gettimeofday",
"getrlimit",
"getrusage",
"sysinfo",
"times",
"ptrace",
"getuid",
"syslog",
"getgid",
"setuid",
"setgid",
"geteuid",
"getegid",
"setpgid",
"getppid",
"getpgrp",
"setsid",
"setreuid",
"setregid",
"getgroups",
"setgroups",
"setresuid",
"getresuid",
"setresgid",
"getresgid",
"getpgid",
"setfsuid",
"setfsgid",
"getsid",
"capget",
"capset",
"rt_sigpending",
"rt_sigtimedwait",
"rt_sigqueueinfo",
"rt_sigsuspend",
"sigaltstack",
"utime",
"mknod",
"uselib",
"personality",
"ustat",
"statfs",
"fstatfs",
"sysfs",
"getpriority",
"setpriority",
"sched_setparam",
"sched_getparam",
"sched_setscheduler",
"sched_getscheduler",
"sched_get_priority_max",
"sched_get_priority_min",
"sched_rr_get_interval",
"mlock",
"munlock",
"mlockall",
"munlockall",
"vhangup",
"modify_ldt",
"pivot_root",
"_sysctl",
"prctl",
"arch_prctl",
"adjtimex",
"setrlimit",
"chroot",
"sync",
"acct",
"settimeofday",
"mount",
"umount2",
"swapon",
"swapoff",
"reboot",
"sethostname",
"setdomainname",
"iopl",
"ioperm",
"create_module",
"init_module",
"delete_module",
"get_kernel_syms",
"query_module",
"quotactl",
"nfsservctl",
"getpmsg",
"putpmsg",
"afs_syscall",
"tuxcall",
"security",
"gettid",
"readahead",
"setxattr",
"lsetxattr",
"fsetxattr",
"getxattr",
"lgetxattr",
"fgetxattr",
"listxattr",
"llistxattr",
"flistxattr",
"removexattr",
"lremovexattr",
"fremovexattr",
"tkill",
"time",
"futex",
"sched_setaffinity",
"sched_getaffinity",
"set_thread_area",
"io_setup",
"io_destroy",
"io_getevents",
"io_submit",
"io_cancel",
"get_thread_area",
"lookup_dcookie",
"epoll_create",
"epoll_ctl_old",
"epoll_wait_old",
"remap_file_pages",
"getdents64",
"set_tid_address",
"restart_syscall",
"semtimedop",
"fadvise64",
"timer_create",
"timer_settime",
"timer_gettime",
"timer_getoverrun",
"timer_delete",
"clock_settime",
"clock_gettime",
"clock_getres",
"clock_nanosleep",
"exit_group",
"epoll_wait",
"epoll_ctl",
"tgkill",
"utimes",
"vserver",
"mbind",
"set_mempolicy",
"get_mempolicy",
"mq_open",
"mq_unlink",
"mq_timedsend",