Verified Commit 84786227 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)
+4 −0
Original line number Diff line number Diff line
@@ -15,6 +15,10 @@ DECLARE_MARGO_RPC_HANDLER(ipc_srv_fs_config)

DECLARE_MARGO_RPC_HANDLER(rpc_srv_mk_node)

#ifdef HAS_SYMLINKS
DECLARE_MARGO_RPC_HANDLER(rpc_srv_mk_symlink)
#endif

DECLARE_MARGO_RPC_HANDLER(rpc_srv_access)

DECLARE_MARGO_RPC_HANDLER(rpc_srv_stat)
+3 −0
Original line number Diff line number Diff line
@@ -8,6 +8,9 @@ namespace hg_tag {
    constexpr auto fs_config = "ipc_srv_fs_config";
    constexpr auto minimal = "rpc_minimal";
    constexpr auto create = "rpc_srv_mk_node";
#ifdef HAS_SYMLINKS
    constexpr auto mk_symlink = "rpc_srv_mk_symlink";
#endif
    constexpr auto access = "rpc_srv_access";
    constexpr auto stat = "rpc_srv_stat";
    constexpr auto remove = "rpc_srv_rm_node";
+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
};


+10 −2
Original line number Diff line number Diff line
@@ -18,7 +18,15 @@ MERCURY_GEN_PROC(rpc_err_out_t, ((hg_int32_t) (err)))
// Metadentry
MERCURY_GEN_PROC(rpc_mk_node_in_t,
    ((hg_const_string_t) (path))\
((uint32_t) (mode)))
    ((uint32_t) (mode))\
)

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

MERCURY_GEN_PROC(rpc_access_in_t,
                 ((hg_const_string_t) (path))\
Loading