Commit 15cee453 authored by Marc Vef's avatar Marc Vef
Browse files

Adding gkfs::hook and gkfs::preload namespaces, cleanup

parent dee19edc
Loading
Loading
Loading
Loading
Loading
+8 −25
Original line number Diff line number Diff line
@@ -17,23 +17,10 @@
#include <client/open_file_map.hpp>
#include <global/metadata.hpp>

struct linux_dirent {
    unsigned long d_ino;
    unsigned long d_off;
    unsigned short d_reclen;
    char d_name[1];
};

struct linux_dirent64 {
    unsigned long long d_ino;
    unsigned long long d_off;
    unsigned short d_reclen;
    unsigned char d_type;
    char d_name[1];
};

using sys_statfs = struct statfs;
using sys_statvfs = struct statvfs;
struct statfs;
struct statvfs;
struct dirent;
struct dirent64;

namespace gkfs {
namespace syscall {
@@ -48,9 +35,9 @@ int gkfs_access(const std::string& path, int mask, bool follow_links = true);

int gkfs_stat(const std::string& path, struct stat* buf, bool follow_links = true);

int gkfs_statfs(sys_statfs* buf);
int gkfs_statfs(struct statfs* buf);

int gkfs_statvfs(sys_statvfs* buf);
int gkfs_statvfs(struct statvfs* buf);

off64_t gkfs_lseek(unsigned int fd, off64_t offset, unsigned int whence);

@@ -92,13 +79,9 @@ ssize_t gkfs_read(int fd, void* buf, size_t count);

int gkfs_opendir(const std::string& path);

int gkfs_getdents(unsigned int fd,
             struct linux_dirent* dirp,
             unsigned int count);
int gkfs_getdents(unsigned int fd, struct dirent* dirp, unsigned int count);

int gkfs_getdents64(unsigned int fd,
                    struct linux_dirent64* dirp,
                    unsigned int count);
int gkfs_getdents64(unsigned int fd, struct dirent64* dirp, unsigned int count);

int gkfs_rmdir(const std::string& path);

+10 −2
Original line number Diff line number Diff line
@@ -17,6 +17,12 @@
#include <sys/types.h>
#include <fcntl.h>

struct statfs;
struct dirent;
struct dirent64;

namespace gkfs {
namespace hook {

int hook_openat(int dirfd, const char* cpath, int flags, mode_t mode);

@@ -63,9 +69,9 @@ int hook_dup2(unsigned int oldfd, unsigned int newfd);

int hook_dup3(unsigned int oldfd, unsigned int newfd, int flags);

int hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count);
int hook_getdents(unsigned int fd, struct dirent* dirp, unsigned int count);

int hook_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count);
int hook_getdents64(unsigned int fd, struct dirent64* dirp, unsigned int count);

int hook_mkdirat(int dirfd, const char* cpath, mode_t mode);

@@ -90,5 +96,7 @@ int hook_statfs(const char* path, struct statfs* buf);

int hook_fstatfs(unsigned int fd, struct statfs* buf);

} // namespace hook
} // namespace gkfs

#endif
+6 −0
Original line number Diff line number Diff line
@@ -14,6 +14,9 @@
#ifndef GEKKOFS_INTERCEPT_HPP
#define GEKKOFS_INTERCEPT_HPP

namespace gkfs {
namespace preload {

int
internal_hook_guard_wrapper(long syscall_number,
                            long arg0, long arg1, long arg2,
@@ -32,4 +35,7 @@ void start_interception();

void stop_interception();

} // namespace preload
} // namespace gkfs

#endif
+5 −2
Original line number Diff line number Diff line
@@ -18,9 +18,12 @@

#define EUNKNOWN (-1)

#define CTX PreloadContext::getInstance()

#define CTX gkfs::preload::PreloadContext::getInstance()
namespace gkfs {
namespace preload {
void init_ld_env_if_needed();
} // namespace preload
} // namespace gkfs

void init_preload() __attribute__((constructor));

+10 −3
Original line number Diff line number Diff line
@@ -25,19 +25,20 @@

/* Forward declarations */
namespace gkfs {

namespace filemap {
class OpenFileMap;
}

namespace rpc {
class Distributor;
}
namespace log {
struct logger;
}
}

namespace preload {
/*
 * Client file system config
 */
struct FsConfig {
    // configurable metadata
    bool atime_state;
@@ -60,6 +61,9 @@ enum class RelativizeStatus {
    fd_not_a_dir
};

/**
 * Singleton class of the client context with all relevant global data
 */
class PreloadContext {

    static auto constexpr MIN_INTERNAL_FD = MAX_OPEN_FDS - MAX_INTERNAL_FDS;
@@ -151,6 +155,9 @@ public:
    void unprotect_user_fds();
};

} // namespace preload
} // namespace gkfs


#endif //GEKKOFS_PRELOAD_CTX_HPP
Loading