Loading src/client/gkfs_libc.cpp +60 −16 Original line number Diff line number Diff line Loading @@ -246,6 +246,10 @@ DLSYM_WRAPPER(ssize_t, pwritev2, DLSYM_WRAPPER(int, mkdir, (const char* path, mode_t mode), (path, mode), "mkdir") DLSYM_WRAPPER(int, mkdirat, (int dfd, const char* path, mode_t mode), (dfd, path, mode), "mkdirat") DLSYM_WRAPPER(int, rmdir, (const char* path), (path), "rmdir") DLSYM_WRAPPER(ssize_t, pread, (int fd, void* buf, size_t count, off_t offset), (fd, buf, count, offset), "pread") Loading Loading @@ -363,6 +367,7 @@ DLSYM_WRAPPER(int, dup2, (int fd, int fd2), (fd, fd2), "dup2") DLSYM_WRAPPER(int, dup3, (int fd, int fd2, int flags), (fd, fd2, flags), "dup3") DLSYM_WRAPPER(void, exit, (int status), (status), "exit") DLSYM_WRAPPER(int, chdir, (char* path), (path), "chdir") DLSYM_WRAPPER(int, fchdir, (int fd), (fd), "fchdir") DLSYM_WRAPPER(int, chmod, (char* path, mode_t mode), (path, mode), "chmod") DLSYM_WRAPPER(int, fchmod, (int fd, mode_t mode), (fd, mode), "fchmod") DLSYM_WRAPPER(int, chown, (char* path, uid_t owner, gid_t group), Loading Loading @@ -823,10 +828,30 @@ write(int fd, const void* buf, size_t nbyte) { int mkdir(const char* path, mode_t mode) { initializeGekko(); GKFS_PATH_OPERATION(create, AT_FDCWD, path, mode | S_IFDIR) DEBUG_INFO("[GKFS] at MKDIR path {} {}", path, CTX->interception_enabled()); if(CTX->interception_enabled()) { std::string resolved; DEBUG_INFO("[GKFS] mkdir path {}", path); switch(resolve_gkfs_path(AT_FDCWD, path, resolved)) { case PathStatus::Internal: DEBUG_INFO("[GKFS] mkdir res {}", resolved); return gkfs::syscall::gkfs_create(resolved, mode | S_IFDIR); case PathStatus::Error: return -1; default: break; } } GKFS_FALLBACK(mkdir, path, mode); } int mkdirat(int dirfd, const char* path, mode_t mode) { initializeGekko(); GKFS_PATH_OPERATION(create, dirfd, path, mode | S_IFDIR) GKFS_FALLBACK(mkdirat, dirfd, path, mode); } int rmdir(const char* path) { initializeGekko(); Loading Loading @@ -1284,9 +1309,14 @@ chdir(const char* path) { case gkfs::preload::RelativizeStatus::fd_not_a_dir: return -ENOTDIR; case gkfs::preload::RelativizeStatus::internal: return gkfs::hook::hook_chdir(path); break; case gkfs::preload::RelativizeStatus::internal: { auto res = gkfs::hook::hook_chdir(path); if(res < 0) { errno = -res; return -1; } return 0; } break; default: // Try normal open. Loading @@ -1297,6 +1327,19 @@ chdir(const char* path) { GKFS_FALLBACK(chdir, const_cast<char*>(path)); } int fchdir(int fd) { initializeGekko(); // is the path from gekkofs auto res = gkfs::hook::hook_fchdir(fd); if(res < 0) { errno = -res; return -1; } return 0; } int fcntl(int fd, int cmd, ...) // TODO Loading Loading @@ -2125,13 +2168,13 @@ scandir(const char* dirname, struct dirent*** namelist, if(resolve_gkfs_path(AT_FDCWD, dirname, resolved) == PathStatus::Internal) { DEBUG_INFO("[GKFS] {}", resolved); // implement scandir : The scandir() function scans the directory // dirp, calling filter() on each directory entry. Entries for // which filter() returns nonzero are stored in strings allocated // via malloc(3), sorted using qsort(3) with the comparison function // compar(), and collected in // array namelist which is allocated via malloc(3). If filter // is NULL, all entries are selected. // implement scandir : The scandir() function scans the // directory dirp, calling filter() on each directory entry. // Entries for which filter() returns nonzero are stored in // strings allocated via malloc(3), sorted using qsort(3) with // the comparison function compar(), and collected in // array namelist which is allocated via malloc(3). If // filter is NULL, all entries are selected. DIR* dirp = gekko_opendir(resolved); if(dirp == nullptr) { Loading Loading @@ -2273,7 +2316,8 @@ pwritev2(int fd, const struct iovec* iov, int iovcnt, off_t offset, int flags) { // size_t aio_nbytes; /* Length of transfer */ // int aio_reqprio; /* Request priority */ // struct sigevent aio_sigevent; /* Notification method */ // int aio_lio_opcode; /* Operation to be performed; // int aio_lio_opcode; /* Operation to be // performed; // lio_listio() only */ // /* Various implementation-internal fields not shown */ Loading @@ -2282,8 +2326,8 @@ pwritev2(int fd, const struct iovec* iov, int iovcnt, off_t offset, int flags) { // /* Operation codes for 'aio_lio_opcode': */ // enum { LIO_READ, LIO_WRITE, LIO_NOP }; // Possible values for aio_sigevent.sigev_notify are SIGEV_NONE, SIGEV_SIGNAL, // and SIGEV_THREAD. See sigevent(3type) for further de‐ // Possible values for aio_sigevent.sigev_notify are SIGEV_NONE, // SIGEV_SIGNAL, and SIGEV_THREAD. See sigevent(3type) for further de‐ // tails. // */ Loading src/client/hooks.cpp +1 −5 Original line number Diff line number Diff line Loading @@ -722,7 +722,7 @@ hook_chdir(const char* path) { // path falls in our namespace auto md = gkfs::utils::get_metadata(rel_path); if(!md) { LOG(ERROR, "{}() path {} errno {}", __func__, path, errno); LOG(ERROR, "{}() path {} / {} errno {}", __func__, path, rel_path, errno); return -errno; } Loading Loading @@ -789,10 +789,6 @@ hook_getcwd(char* buf, unsigned long size) { LOG(DEBUG, "{}() called with buf: {}, size: {}", __func__, fmt::ptr(buf), size); if(CTX->cwd().size() == 0) { CTX->cwd(gkfs::path::get_sys_cwd()); } if(CTX->cwd().size() + 1 > size) { LOG(ERROR, "{}() buffer too small to host current working dir", __func__); Loading src/client/preload_context.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,7 @@ PreloadContext::PreloadContext() char host[255]; gethostname(host, 255); hostname = host; cwd_ = gkfs::path::get_sys_cwd(); PreloadContext::set_replicas( std::stoi(gkfs::env::get_var(gkfs::env::NUM_REPL, "0"))); } Loading Loading
src/client/gkfs_libc.cpp +60 −16 Original line number Diff line number Diff line Loading @@ -246,6 +246,10 @@ DLSYM_WRAPPER(ssize_t, pwritev2, DLSYM_WRAPPER(int, mkdir, (const char* path, mode_t mode), (path, mode), "mkdir") DLSYM_WRAPPER(int, mkdirat, (int dfd, const char* path, mode_t mode), (dfd, path, mode), "mkdirat") DLSYM_WRAPPER(int, rmdir, (const char* path), (path), "rmdir") DLSYM_WRAPPER(ssize_t, pread, (int fd, void* buf, size_t count, off_t offset), (fd, buf, count, offset), "pread") Loading Loading @@ -363,6 +367,7 @@ DLSYM_WRAPPER(int, dup2, (int fd, int fd2), (fd, fd2), "dup2") DLSYM_WRAPPER(int, dup3, (int fd, int fd2, int flags), (fd, fd2, flags), "dup3") DLSYM_WRAPPER(void, exit, (int status), (status), "exit") DLSYM_WRAPPER(int, chdir, (char* path), (path), "chdir") DLSYM_WRAPPER(int, fchdir, (int fd), (fd), "fchdir") DLSYM_WRAPPER(int, chmod, (char* path, mode_t mode), (path, mode), "chmod") DLSYM_WRAPPER(int, fchmod, (int fd, mode_t mode), (fd, mode), "fchmod") DLSYM_WRAPPER(int, chown, (char* path, uid_t owner, gid_t group), Loading Loading @@ -823,10 +828,30 @@ write(int fd, const void* buf, size_t nbyte) { int mkdir(const char* path, mode_t mode) { initializeGekko(); GKFS_PATH_OPERATION(create, AT_FDCWD, path, mode | S_IFDIR) DEBUG_INFO("[GKFS] at MKDIR path {} {}", path, CTX->interception_enabled()); if(CTX->interception_enabled()) { std::string resolved; DEBUG_INFO("[GKFS] mkdir path {}", path); switch(resolve_gkfs_path(AT_FDCWD, path, resolved)) { case PathStatus::Internal: DEBUG_INFO("[GKFS] mkdir res {}", resolved); return gkfs::syscall::gkfs_create(resolved, mode | S_IFDIR); case PathStatus::Error: return -1; default: break; } } GKFS_FALLBACK(mkdir, path, mode); } int mkdirat(int dirfd, const char* path, mode_t mode) { initializeGekko(); GKFS_PATH_OPERATION(create, dirfd, path, mode | S_IFDIR) GKFS_FALLBACK(mkdirat, dirfd, path, mode); } int rmdir(const char* path) { initializeGekko(); Loading Loading @@ -1284,9 +1309,14 @@ chdir(const char* path) { case gkfs::preload::RelativizeStatus::fd_not_a_dir: return -ENOTDIR; case gkfs::preload::RelativizeStatus::internal: return gkfs::hook::hook_chdir(path); break; case gkfs::preload::RelativizeStatus::internal: { auto res = gkfs::hook::hook_chdir(path); if(res < 0) { errno = -res; return -1; } return 0; } break; default: // Try normal open. Loading @@ -1297,6 +1327,19 @@ chdir(const char* path) { GKFS_FALLBACK(chdir, const_cast<char*>(path)); } int fchdir(int fd) { initializeGekko(); // is the path from gekkofs auto res = gkfs::hook::hook_fchdir(fd); if(res < 0) { errno = -res; return -1; } return 0; } int fcntl(int fd, int cmd, ...) // TODO Loading Loading @@ -2125,13 +2168,13 @@ scandir(const char* dirname, struct dirent*** namelist, if(resolve_gkfs_path(AT_FDCWD, dirname, resolved) == PathStatus::Internal) { DEBUG_INFO("[GKFS] {}", resolved); // implement scandir : The scandir() function scans the directory // dirp, calling filter() on each directory entry. Entries for // which filter() returns nonzero are stored in strings allocated // via malloc(3), sorted using qsort(3) with the comparison function // compar(), and collected in // array namelist which is allocated via malloc(3). If filter // is NULL, all entries are selected. // implement scandir : The scandir() function scans the // directory dirp, calling filter() on each directory entry. // Entries for which filter() returns nonzero are stored in // strings allocated via malloc(3), sorted using qsort(3) with // the comparison function compar(), and collected in // array namelist which is allocated via malloc(3). If // filter is NULL, all entries are selected. DIR* dirp = gekko_opendir(resolved); if(dirp == nullptr) { Loading Loading @@ -2273,7 +2316,8 @@ pwritev2(int fd, const struct iovec* iov, int iovcnt, off_t offset, int flags) { // size_t aio_nbytes; /* Length of transfer */ // int aio_reqprio; /* Request priority */ // struct sigevent aio_sigevent; /* Notification method */ // int aio_lio_opcode; /* Operation to be performed; // int aio_lio_opcode; /* Operation to be // performed; // lio_listio() only */ // /* Various implementation-internal fields not shown */ Loading @@ -2282,8 +2326,8 @@ pwritev2(int fd, const struct iovec* iov, int iovcnt, off_t offset, int flags) { // /* Operation codes for 'aio_lio_opcode': */ // enum { LIO_READ, LIO_WRITE, LIO_NOP }; // Possible values for aio_sigevent.sigev_notify are SIGEV_NONE, SIGEV_SIGNAL, // and SIGEV_THREAD. See sigevent(3type) for further de‐ // Possible values for aio_sigevent.sigev_notify are SIGEV_NONE, // SIGEV_SIGNAL, and SIGEV_THREAD. See sigevent(3type) for further de‐ // tails. // */ Loading
src/client/hooks.cpp +1 −5 Original line number Diff line number Diff line Loading @@ -722,7 +722,7 @@ hook_chdir(const char* path) { // path falls in our namespace auto md = gkfs::utils::get_metadata(rel_path); if(!md) { LOG(ERROR, "{}() path {} errno {}", __func__, path, errno); LOG(ERROR, "{}() path {} / {} errno {}", __func__, path, rel_path, errno); return -errno; } Loading Loading @@ -789,10 +789,6 @@ hook_getcwd(char* buf, unsigned long size) { LOG(DEBUG, "{}() called with buf: {}, size: {}", __func__, fmt::ptr(buf), size); if(CTX->cwd().size() == 0) { CTX->cwd(gkfs::path::get_sys_cwd()); } if(CTX->cwd().size() + 1 > size) { LOG(ERROR, "{}() buffer too small to host current working dir", __func__); Loading
src/client/preload_context.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,7 @@ PreloadContext::PreloadContext() char host[255]; gethostname(host, 255); hostname = host; cwd_ = gkfs::path::get_sys_cwd(); PreloadContext::set_replicas( std::stoi(gkfs::env::get_var(gkfs::env::NUM_REPL, "0"))); } Loading