Commit 9d0c5efd authored by Ramon Nou's avatar Ramon Nou
Browse files

preadv et al, disable fcntl locking

parent 9b5dd4d6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -92,6 +92,11 @@ gkfs_readv(int fd, const struct iovec* iov, int iovcnt);
ssize_t
gkfs_writev(int fd, const struct iovec* iov, int iovcnt);

ssize_t
gkfs_preadv(int fd, const struct iovec* iov, int iovcnt, off_t offset);

ssize_t
gkfs_pwritev(int fd, const struct iovec* iov, int iovcnt, off_t offset);

int
gkfs_stat(const std::string& path, struct stat* buf, bool follow_links = true);
+40 −29
Original line number Diff line number Diff line
@@ -222,27 +222,24 @@ DLSYM_WRAPPER(ssize_t, read, (int fd, void* buf, size_t nbyte),
              (fd, buf, nbyte), "read")
DLSYM_WRAPPER(ssize_t, write, (int fd, const void* buf, size_t nbyte),
              (fd, buf, nbyte), "write")
/*
   ssize_t readv(int fd, const struct iovec *iov, int iovcnt);

       ssize_t writev(int fd, const struct iovec *iov, int iovcnt);

       ssize_t preadv(int fd, const struct iovec *iov, int iovcnt,
                      off_t offset);

       ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt,
                       off_t offset);

       ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt,
                       off_t offset, int flags);

       ssize_t pwritev2(int fd, const struct iovec *iov, int iovcnt,
                        off_t offset, int flags);
*/
DLSYM_WRAPPER(ssize_t, readv, (int fd, const struct iovec* iov, int iovcnt),
              (fd, iov, iovcnt), "readv")
DLSYM_WRAPPER(ssize_t, writev, (int fd, const struct iovec* iov, int iovcnt),
              (fd, iov, iovcnt), "writev")
DLSYM_WRAPPER(ssize_t, preadv,
              (int fd, const struct iovec* iov, int iovcnt, off_t offset),
              (fd, iov, iovcnt, offset), "preadv")
DLSYM_WRAPPER(ssize_t, pwritev,
              (int fd, const struct iovec* iov, int iovcnt, off_t offset),
              (fd, iov, iovcnt, offset), "pwritev")
DLSYM_WRAPPER(ssize_t, preadv2,
              (int fd, const struct iovec* iov, int iovcnt, off_t offset,
               int flags),
              (fd, iov, iovcnt, offset, flags), "preadv2")
DLSYM_WRAPPER(ssize_t, pwritev2,
              (int fd, const struct iovec* iov, int iovcnt, off_t offset,
               int flags),
              (fd, iov, iovcnt, offset, flags), "pwritev2")


DLSYM_WRAPPER(int, mkdir, (const char* path, mode_t mode), (path, mode),
@@ -1371,7 +1368,7 @@ fcntl(int fd, int cmd, ...) // TODO
                        gkfs::filemap::OpenFile_flags::cloexec,
                        (arg & FD_CLOEXEC));
                return 0;

#ifdef ENABLE_LOCKING
            case F_GETLK: {
                DEBUG_INFO("[GKFS] F_GETLK {}", fd);
                auto res = real_fcntl(fd, cmd, arg);
@@ -1399,7 +1396,7 @@ fcntl(int fd, int cmd, ...) // TODO
                auto res = real_fcntl(fd, cmd, arg);
                return res;
            }

#endif
            default:
                DEBUG_INFO("[GKFS] NOTSUPPORTED {}", fd);
                errno = ENOTSUP;
@@ -2197,16 +2194,30 @@ writev(int fd, const struct iovec* iov, int iovcnt) {
    GKFS_FALLBACK(writev, fd, iov, iovcnt)
}

/*
ssize_t preadv(int fd, const struct iovec *iov, int iovcnt,
               off_t offset);
ssize_t
preadv(int fd, const struct iovec* iov, int iovcnt, off_t offset) {
    initializeGekko();
    GKFS_OPERATION(preadv, fd, iov, iovcnt, offset)
    GKFS_FALLBACK(preadv, fd, iov, iovcnt, offset)
}

ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt,
                off_t offset);
ssize_t
pwritev(int fd, const struct iovec* iov, int iovcnt, off_t offset) {
    initializeGekko();
    GKFS_OPERATION(pwritev, fd, iov, iovcnt, offset)
    GKFS_FALLBACK(pwritev, fd, iov, iovcnt, offset)
}

ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt,
                off_t offset, int flags);
ssize_t
preadv2(int fd, const struct iovec* iov, int iovcnt, off_t offset, int flags) {
    initializeGekko();
    GKFS_OPERATION(preadv, fd, iov, iovcnt, offset)
    GKFS_FALLBACK(preadv2, fd, iov, iovcnt, offset, flags)
}

ssize_t pwritev2(int fd, const struct iovec *iov, int iovcnt,
                 off_t offset, int flags);
*/
ssize_t
pwritev2(int fd, const struct iovec* iov, int iovcnt, off_t offset, int flags) {
    initializeGekko();
    GKFS_OPERATION(pwritev, fd, iov, iovcnt, offset)
    GKFS_FALLBACK(pwritev2, fd, iov, iovcnt, offset, flags)
}
+2 −1
Original line number Diff line number Diff line
@@ -918,7 +918,7 @@ hook_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg) {
            CTX->file_map()->get(fd)->set_flag(
                    gkfs::filemap::OpenFile_flags::cloexec, (arg & FD_CLOEXEC));
            return 0;

#ifdef ENABLE_LOCKING
        case F_GETLK:
            LOG(ERROR, "{}() F_GETLK on fd (on underlying fd) {}", __func__,
                fd);
@@ -952,6 +952,7 @@ hook_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg) {
            return gsl::narrow_cast<int>(
                    syscall_no_intercept_wrapper(SYS_fcntl, fd, cmd, arg));

#endif
        default:
            LOG(ERROR, "{}() unrecognized command {} on fd {}", __func__, cmd,
                fd);
+0 −16
Original line number Diff line number Diff line
@@ -163,24 +163,8 @@ OpenFileMap::safe_generate_fd_idx_() {
        }
    } else {
        // Some architectures do not support SYS_open
        #define REALLOCK
        #ifndef REALLOCK
        fd = syscall_no_intercept(SYS_openat, AT_FDCWD, "/dev/null", O_RDWR,
                                  S_IRUSR | S_IWUSR);
        #else
        // create an empty temporal file in /tmp/gtmp/, and open it using syscall_no_intercept
        std::string tmp_file = "/tmp/gko/tmpfileXXXXXX";
        char* tmp_file_c = new char[tmp_file.length() + 1];
        strcpy(tmp_file_c, tmp_file.c_str());
        fd = mkstemp(tmp_file_c);
        // syscall_no_intercept(SYS_fchmod, fd, S_IRUSR | S_IWUSR);
        if (fd == -1) {
            LOG(ERROR, "Could not create temporary file");
            return -1;
        }

        #endif
        
    }
    return fd;
}