Verified Commit 36c38d77 authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

add optional support for symlink

parent 69fb1421
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -114,6 +114,10 @@ if (NOT USE_OFI_VERBS AND NOT USE_OFI_PSM2 AND NOT USE_CCI AND NOT USE_BMI)
    add_definitions(-DRPC_PROTOCOL="bmi+tcp")
endif()

option(SYMLINK_SUPPORT "Compile with support for symlinks" ON)
if(SYMLINK_SUPPORT)
    add_compile_definitions(HAS_SYMLINKS)
endif()

# Imported target
add_library(RocksDB INTERFACE IMPORTED GLOBAL)
+5 −0
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@ DECLARE_MARGO_RPC_HANDLER(rpc_srv_update_metadentry_size)

DECLARE_MARGO_RPC_HANDLER(rpc_srv_get_dirents)

#ifdef HAS_SYMLINKS
DECLARE_MARGO_RPC_HANDLER(rpc_srv_mk_symlink)
#endif


// data
DECLARE_MARGO_RPC_HANDLER(rpc_srv_read_data)

+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@ namespace hg_tag {
    constexpr auto get_metadentry_size = "rpc_srv_get_metadentry_size";
    constexpr auto update_metadentry_size = "rpc_srv_update_metadentry_size";
    constexpr auto get_dirents = "rpc_srv_get_dirents";
#ifdef HAS_SYMLINKS
    constexpr auto mk_symlink = "rpc_srv_mk_symlink";
#endif
    constexpr auto write_data = "rpc_srv_write_data";
    constexpr auto read_data = "rpc_srv_read_data";
    constexpr auto trunc_data = "rpc_srv_trunc_data";
+16 −0
Original line number Diff line number Diff line
@@ -5,9 +5,13 @@

#include "global/configure.hpp"
#include <sys/types.h>
#include <sys/stat.h>
#include <string>


constexpr mode_t LINK_MODE = ((S_IRWXU | S_IRWXG | S_IRWXO) | S_IFLNK);


class Metadata {
private:
    time_t atime_;         // access time. gets updated on file access unless mounted with noatime
@@ -19,10 +23,17 @@ private:
    nlink_t link_count_;   // number of names for this inode (hardlinks)
    size_t size_;          // size_ in bytes, might be computed instead of stored
    blkcnt_t blocks_;      // allocated file system blocks_
#ifdef HAS_SYMLINKS
    std::string target_path_;  // For links this is the path of the target file
#endif


public:
    Metadata();
    Metadata(mode_t mode);
#ifdef HAS_SYMLINKS
    Metadata(mode_t mode, const std::string& target_path);
#endif
    // Construct from a binary representation of the object
    Metadata(const std::string& binary_str);

@@ -50,6 +61,11 @@ public:
    void size(size_t size_);
    blkcnt_t blocks() const;
    void blocks(blkcnt_t blocks_);
#ifdef HAS_SYMLINKS
    std::string target_path() const;
    void target_path(const std::string& target_path);
    bool is_link() const;
#endif
};


+7 −0
Original line number Diff line number Diff line
@@ -67,6 +67,13 @@ MERCURY_GEN_PROC(rpc_update_metadentry_size_out_t, ((hg_int32_t) (err))
MERCURY_GEN_PROC(rpc_get_metadentry_size_out_t, ((hg_int32_t) (err))
        ((hg_int64_t) (ret_size)))

#ifdef HAS_SYMLINKS
MERCURY_GEN_PROC(rpc_mk_symlink_in_t,
    ((hg_const_string_t) (path))\
    ((hg_const_string_t) (target_path))
)
#endif

// data
MERCURY_GEN_PROC(rpc_read_data_in_t,
                 ((hg_const_string_t) (path))\
Loading