Unverified Commit 1963eee8 authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

syscall_intercept

parent 70acd5f8
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
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
)
+1 −0
Original line number Diff line number Diff line
@@ -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
+22 −0
Original line number Diff line number Diff line
/*
  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);

#endif
+26 −0
Original line number Diff line number Diff line
/*
  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

include/client/passthrough.hpp

deleted100644 → 0
+0 −131
Original line number Diff line number Diff line
/*
  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
Loading