LIBC interception

Support for libc interception

Edited by Ramon Nou

Merge request reports

Loading
+7 −1
Changes for CMake/gkfs-options.cmake: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -241,6 +241,13 @@ gkfs_define_option(
    DEFAULT_VALUE ON
)

#build libc
gkfs_define_option(
    GKFS_BUILD_LIBC_INTERCEPTION
    HELP_TEXT "Compile libc interception"
    DEFAULT_VALUE ON
)

# use old resolve function
gkfs_define_option(
    GKFS_USE_LEGACY_PATH_RESOLVE
@@ -287,7 +294,6 @@ gkfs_define_option(
    DESCRIPTION "Compile with lstat usage in path resolve"
)


################################################################################
# Options and variables that control how GekkoFS behaves internally
################################################################################
+3 −0
Changes for include/client/gkfs_functions.hpp: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ gkfs_open(const std::string& path, mode_t mode, int flags);
int
gkfs_create(const std::string& path, mode_t mode);

int
gkfs_libcremove(const std::string& path);

int
gkfs_remove(const std::string& path);

+74 −0
Changes for include/client/gkfs_libc.hpp: 74 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
  Copyright 2018-2025, Barcelona Supercomputing Center (BSC), Spain
  Copyright 2015-2025, 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.

  This software was partially supported by the
  the European Union’s Horizon 2020 JTI-EuroHPC research and
  innovation programme, by the project ADMIRE (Project ID: 956748,
  admire-eurohpc.eu)

  This project was partially promoted by the Ministry for Digital Transformation
  and the Civil Service, within the framework of the Recovery,
  Transformation and Resilience Plan - Funded by the European Union
  -NextGenerationEU.

  This file is part of GekkoFS' POSIX interface.

  GekkoFS' POSIX interface is free software: you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation, either version 3 of the License,
  or (at your option) any later version.

  GekkoFS' POSIX interface is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License
  along with GekkoFS' POSIX interface.  If not, see
  <https://www.gnu.org/licenses/>.

  SPDX-License-Identifier: LGPL-3.0-or-later
*/


#ifdef __cplusplus
extern "C" {
#endif

#include <dlfcn.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/statvfs.h>

#include <sys/types.h>
#include <dirent.h>


#ifndef _STAT_VER
#define _STAT_VER 0
#endif

struct __dirstream {
    int fd; // File descriptor.
    //__libc_lock_define (, lock) // Mutex lock for this structure. //TODO
    size_t allocation; // Space allocated for the block.
    size_t size;       // Total valid data in the block.
    size_t offset;     // Current offset into the block.
    off_t filepos;     // Position of next entry to read.
    // Directory block.
    char* path;
    char data[1] __attribute__((aligned(__alignof__(void*))));
}; // Originally its 0, but C++ does not permit it

#ifdef __cplusplus
}
#endif
+0 −4
Changes for include/client/hooks.hpp: 0 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -47,11 +47,7 @@ extern "C" {
#include <sys/syscall.h>
}

#ifndef BYPASS_SYSCALL
#include <libsyscall_intercept_hook_point.h>
#else
#include <client/void_syscall_intercept.hpp>
#endif

#include <client/intercept.hpp>

+1 −4
Changes for include/client/logging.hpp: 1 added line, 4 removed lines.
Original line number Diff line number Diff line
@@ -40,11 +40,8 @@
#ifndef LIBGKFS_LOGGING_HPP
#define LIBGKFS_LOGGING_HPP

#ifndef BYPASS_SYSCALL

#include <libsyscall_intercept_hook_point.h>
#else
#include <client/void_syscall_intercept.hpp>
#endif

#include <type_traits>
#include <client/make_array.hpp>
Loading
Loading