Commit 3a5ec0b3 authored by Tunahan Kaya's avatar Tunahan Kaya
Browse files

potential way to replace errno with leaf result<T> (incomplete draft)

parent 3ec49584
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -193,7 +193,6 @@ set(INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include")
include_directories(
    ${INCLUDE_DIR}
    ${CMAKE_BINARY_DIR}/include
    ${CMAKE_SOURCE_DIR}/external/leaf
)

include(GNUInstallDirs)

external/leaf/all.hpp

0 → 100644
+4709 −0

File added.

Preview size limit exceeded, changes collapsed.

+11 −11
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

#include <client/open_file_map.hpp>
#include <global/metadata.hpp>
#include "../../external/leaf/result.hpp"
#include "../../external/leaf/all.hpp"

struct statfs;
struct statvfs;
@@ -25,13 +25,13 @@ struct linux_dirent64;

namespace gkfs::syscall {

boost::leaf::result<T>
boost::leaf::result<int>
gkfs_open(const std::string& path, mode_t mode, int flags);

int
boost::leaf::result<int>
gkfs_create(const std::string& path, mode_t mode);

int
boost::leaf::result<int>
gkfs_remove(const std::string& path);

// Implementation of access,
@@ -41,14 +41,14 @@ gkfs_access(const std::string& path, int mask, bool follow_links = true);

// Implementation of stat,
// Follow links is true by default
int
boost::leaf::result<int>
gkfs_stat(const std::string& path, struct stat* buf, bool follow_links = true);

// Implementation of statx, it uses the normal stat and maps the information to
// the statx structure Follow links is true by default
#ifdef STATX_TYPE

int
boost::leaf::result<int>
gkfs_statx(int dirfd, const std::string& path, int flags, unsigned int mask,
           struct statx* buf, bool follow_links = true);

@@ -67,10 +67,10 @@ off64_t
gkfs_lseek(std::shared_ptr<gkfs::filemap::OpenFile> gkfs_fd, off64_t offset,
           unsigned int whence);

int
boost::leaf::result<int>
gkfs_truncate(const std::string& path, off_t offset);

int
boost::leaf::result<int>
gkfs_truncate(const std::string& path, off_t old_size, off_t new_size);

int
@@ -84,7 +84,7 @@ gkfs_dup2(int oldfd, int newfd);
int
gkfs_mk_symlink(const std::string& path, const std::string& target_path);

int
boost::leaf::result<int>
gkfs_readlink(const std::string& path, char* buf, int bufsize);

#endif
@@ -121,7 +121,7 @@ gkfs_readv(int fd, const struct iovec* iov, int iovcnt);
ssize_t
gkfs_preadv(int fd, const struct iovec* iov, int iovcnt, off_t offset);

int
boost::leaf::result<int>
gkfs_opendir(const std::string& path);

int
@@ -131,7 +131,7 @@ int
gkfs_getdents64(unsigned int fd, struct linux_dirent64* dirp,
                unsigned int count);

int
boost::leaf::result<int>
gkfs_rmdir(const std::string& path);

} // namespace gkfs::syscall
+2 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <iostream>
#include <map>
#include <type_traits>
#include "leaf/all.hpp"

namespace gkfs::metadata {

@@ -55,7 +56,7 @@ to_underlying(E e) {
    return static_cast<typename std::underlying_type<E>::type>(e);
}

std::shared_ptr<gkfs::metadata::Metadata>
boost::leaf::result<std::shared_ptr<gkfs::metadata::Metadata>>
get_metadata(const std::string& path, bool follow_links = false);

int
+5 −1
Original line number Diff line number Diff line
@@ -59,15 +59,17 @@ set(PRELOAD_LINK_LIBRARIES
    hermes
    fmt::fmt
    Boost::boost
    spdlog
    Threads::Threads
    Date::TZ
    )
set(PRELOAD_INCLUDE_DIRS
    ${ABT_INCLUDE_DIRS}
    ${MARGO_INCLUDE_DIRS}
    external/leaf
    )

add_library(gkfs_intercept SHARED ${PRELOAD_SRC} ${PRELOAD_HEADERS})
add_library(gkfs_intercept SHARED ${PRELOAD_SRC} ${PRELOAD_HEADERS} test_leaf.cpp)

target_link_libraries(gkfs_intercept
    arithmetic
@@ -75,6 +77,8 @@ target_link_libraries(gkfs_intercept

target_include_directories(gkfs_intercept PRIVATE ${PRELOAD_INCLUDE_DIRS})

target_include_directories(gkfs_intercept PRIVATE "../../external/leaf")

install(TARGETS gkfs_intercept
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Loading