Commit e1c21da7 authored by Ramon Nou's avatar Ramon Nou
Browse files

SYMLINK support, (need to revise RENAME support), solved bugs with follow_links

parent a8f4a32b
Loading
Loading
Loading
Loading
+122 −0
Original line number Diff line number Diff line
@@ -1343,6 +1343,128 @@ struct mk_symlink {

#endif // HAS_SYMLINKS


#ifdef HAS_RENAME

//==============================================================================
// definitions for rename
struct rename {

    // forward declarations of public input/output types for this RPC
    class input;

    class output;

    // traits used so that the engine knows what to do with the RPC
    using self_type = rename;
    using handle_type = hermes::rpc_handle<self_type>;
    using input_type = input;
    using output_type = output;
    using mercury_input_type = rpc_rename_in_t;
    using mercury_output_type = rpc_err_out_t;

    // RPC public identifier
    // (N.B: we reuse the same IDs assigned by Margo so that the daemon
    // understands Hermes RPCs)
    constexpr static const uint64_t public_id = 40;

    // RPC internal Mercury identifier
    constexpr static const hg_id_t mercury_id = 0;

    // RPC name
    constexpr static const auto name = gkfs::rpc::tag::rename;

    // requires response?
    constexpr static const auto requires_response = true;

    // Mercury callback to serialize input arguments
    constexpr static const auto mercury_in_proc_cb =
            HG_GEN_PROC_NAME(rpc_rename_in_t);

    // Mercury callback to serialize output arguments
    constexpr static const auto mercury_out_proc_cb =
            HG_GEN_PROC_NAME(rpc_err_out_t);

    class input {

        template <typename ExecutionContext>
        friend hg_return_t
        hermes::detail::post_to_mercury(ExecutionContext*);

    public:
        input(const std::string& path, const std::string& target_path)
            : m_path(path), m_target_path(target_path) {}

        input(input&& rhs) = default;

        input(const input& other) = default;

        input&
        operator=(input&& rhs) = default;

        input&
        operator=(const input& other) = default;

        std::string
        path() const {
            return m_path;
        }

        std::string
        target_path() const {
            return m_target_path;
        }

        explicit input(const rpc_rename_in_t& other)
            : m_path(other.path), m_target_path(other.target_path) {}

        explicit
        operator rpc_rename_in_t() {
            return {m_path.c_str(), m_target_path.c_str()};
        }

    private:
        std::string m_path;
        std::string m_target_path;
    };

    class output {

        template <typename ExecutionContext>
        friend hg_return_t
        hermes::detail::post_to_mercury(ExecutionContext*);

    public:
        output() : m_err() {}

        output(int32_t err) : m_err(err) {}

        output(output&& rhs) = default;

        output(const output& other) = default;

        output&
        operator=(output&& rhs) = default;

        output&
        operator=(const output& other) = default;

        explicit output(const rpc_err_out_t& out) {
            m_err = out.err;
        }

        int32_t
        err() const {
            return m_err;
        }

    private:
        int32_t m_err;
    };
};

#endif // HAS_RENAME

//==============================================================================
// definitions for remove data
struct remove_data {
+9 −0
Original line number Diff line number Diff line
@@ -118,6 +118,15 @@ gkfs_getdents64(unsigned int fd, struct linux_dirent64* dirp,
int
gkfs_truncate(const std::string& path, off_t offset);

#ifdef HAS_SYMLINKS
int
gkfs_mk_symlink(const std::string& path, const std::string& target);
int
gkfs_readlink(const std::string& path, char* buf, int bufsize);
#endif




} // namespace syscall
namespace malleable {
+4 −0
Original line number Diff line number Diff line
@@ -71,6 +71,10 @@ constexpr auto get_dirents_extended = "rpc_srv_get_dirents_extended";
#ifdef HAS_SYMLINKS
constexpr auto mk_symlink = "rpc_srv_mk_symlink";
#endif
#ifdef HAS_RENAME
constexpr auto rename = "rpc_srv_rename";
#endif

constexpr auto write = "rpc_srv_write_data";
constexpr auto read = "rpc_srv_read_data";
constexpr auto truncate = "rpc_srv_trunc_data";
+6 −0
Original line number Diff line number Diff line
@@ -94,6 +94,12 @@ MERCURY_GEN_PROC(rpc_mk_symlink_in_t, ((hg_const_string_t) (path))((
                                              hg_const_string_t) (target_path)))

#endif
#ifdef HAS_RENAME
MERCURY_GEN_PROC(rpc_rename_in_t, ((hg_const_string_t) (path))((
                                              hg_const_string_t) (target_path)))

#endif


// data
MERCURY_GEN_PROC(
+4 −0
Original line number Diff line number Diff line
@@ -72,6 +72,10 @@ DECLARE_MARGO_RPC_HANDLER(rpc_srv_get_dirents_extended)
DECLARE_MARGO_RPC_HANDLER(rpc_srv_mk_symlink)

#endif
#ifdef HAS_RENAME
DECLARE_MARGO_RPC_HANDLER(rpc_srv_rename)
#endif


// data
DECLARE_MARGO_RPC_HANDLER(rpc_srv_remove_data)
Loading