Verified Commit 395e9329 authored by Ramon Nou's avatar Ramon Nou Committed by Marc Vef
Browse files

Library finish

parent 9f5e4f34
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -32,16 +32,17 @@ cmake_minimum_required(VERSION 3.13)
project(
    GekkoFS
    VERSION 0.9.2
    LANGUAGES ASM CXX C
)

enable_testing()

if (NOT CMAKE_COMPILER_IS_GNUCC)
    message(FATAL_ERROR "The choosen C compiler is not gcc and is not supported")
endif ()
if (NOT CMAKE_COMPILER_IS_GNUCXX)
    message(FATAL_ERROR "The choosen C++ compiler is not g++ and is not supported")
endif ()
#if (NOT CMAKE_COMPILER_IS_GNUCC)
 #   message(FATAL_ERROR "The choosen C compiler is not gcc and is not supported")
#endif ()
#if (NOT CMAKE_COMPILER_IS_GNUCXX)
#    message(FATAL_ERROR "The choosen C++ compiler is not g++ and is not supported")
#endif ()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+35 −31
Original line number Diff line number Diff line
@@ -47,54 +47,58 @@ using namespace std;

/* Function exported from GekkoFS LD_PRELOAD, code needs to be compiled with
 * -fPIC */
extern "C" int gkfs_init()
    __attribute__((weak));
extern "C" int
gkfs_init() __attribute__((weak));

extern "C" int gkfs_end()
    __attribute__((weak));
extern "C" int
gkfs_end() __attribute__((weak));

void init_preload() {};
void destroy_preload() {};
void
init_preload(){};
void
destroy_preload(){};

void write_file(std::string filename){
  // Opem File
void
write_file(std::string filename) {
    // Open File
    int fd = gkfs::syscall::gkfs_open(filename, S_IRWXU, O_RDWR | O_CREAT);

    cout << "FD open  " << fd << endl;
    char* buf = "testing";

  // int size = gkfs::syscall::gkfs_write(fd, buf, 7);
    int size = gkfs::syscall::gkfs_write(fd, buf, 7);

 //  cout << "FD size" << size << endl;
    cout << "FD size" << size << endl;

    gkfs::syscall::gkfs_close(fd);

}


void read_file(std::string filename){
void
read_file(std::string filename) {
    int fdread = gkfs::syscall::gkfs_open(filename, S_IRWXU, O_RDONLY);
  char *bufread = "TESTING\0";
    if(fdread == -1)
        return;
    char* bufread = (char*) malloc(10);
    int sizeread = gkfs::syscall::gkfs_read(fdread, bufread, 7);

    cout << "Reading : " << sizeread << " --> " << bufread << endl;

    gkfs::syscall::gkfs_close(fdread);

}
int main(int argc, char **argv) {
int
main(int argc, char** argv) {
    cout << "GekkoFS Client library test" << endl;

    auto res = gkfs_init();

    cout << "Init result " << res << endl;

  //write_file ("/test.tmp"); 
    write_file("/test.tmp");

    read_file("/test.tmp");

    res = gkfs_end();

    cout << "End result " << res << endl;

}
+26 −0
Original line number Diff line number Diff line
@@ -54,3 +54,29 @@ target_sources(
         syscalls/detail/syscall_info.h
)

target_sources(
  gkfs_user_lib
  PUBLIC gkfs_functions.hpp
         env.hpp
         hooks.hpp
         intercept.hpp
         logging.hpp
         make_array.hpp
         open_file_map.hpp
         open_dir.hpp
         path.hpp
         preload.hpp
         preload_context.hpp
         preload_util.hpp
         rpc/rpc_types.hpp
         rpc/forward_management.hpp
         rpc/forward_metadata.hpp
         rpc/forward_data.hpp
         syscalls/args.hpp
         syscalls/decoder.hpp
         syscalls/errno.hpp
         syscalls/rets.hpp
         syscalls/syscall.hpp
         syscalls/detail/syscall_info.h
         void_syscall_intercept.hpp
)
+1 −0
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ gkfs_close(unsigned int fd);
int
gkfs_rename(const std::string& old_path, const std::string& new_path);
#endif // HAS_RENAME

} // namespace gkfs::syscall

// gkfs_getsingleserverdir is using extern "C" to demangle it for C usage
+6 −0
Original line number Diff line number Diff line
@@ -36,7 +36,13 @@ extern "C" {
#include <sys/stat.h>
#include <sys/syscall.h>
}

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


/*
 * For PowerPC, syscall_no_intercept_wrapper() is defined in the
Loading