Verified Commit 7cb374b1 authored by Marc Vef's avatar Marc Vef
Browse files

TMP bandaid fixes to avoid nullptr in gkfsfunctions

parent e2a1e2e5
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1072,6 +1072,8 @@ gkfs_write_ws(gkfs::filemap::OpenFile& file, const char* buf, size_t count,
ssize_t
gkfs_pwrite(int fd, const void* buf, size_t count, off64_t offset) {
    auto file = CTX->file_map()->get(fd);
    if(!file)
        return 0;
    return gkfs_write_ws(*file, reinterpret_cast<const char*>(buf), count,
                         offset);
}
@@ -1108,6 +1110,8 @@ ssize_t
gkfs_pwritev(int fd, const struct iovec* iov, int iovcnt, off_t offset) {

    auto file = CTX->file_map()->get(fd);
    if(!file)
        return 0;
    auto pos = offset; // keep track of current position
    ssize_t written = 0;
    ssize_t ret;
@@ -1147,6 +1151,8 @@ ssize_t
gkfs_writev(int fd, const struct iovec* iov, int iovcnt) {

    auto gkfs_fd = CTX->file_map()->get(fd);
    if(!gkfs_fd)
        return 0;
    auto pos = gkfs_fd->pos(); // retrieve the current offset
    auto ret = gkfs_pwritev(fd, iov, iovcnt, pos);
    assert(ret != 0);
@@ -1246,6 +1252,8 @@ gkfs_read_ws(const gkfs::filemap::OpenFile& file, char* buf, size_t count,
ssize_t
gkfs_pread(int fd, void* buf, size_t count, off64_t offset) {
    auto gkfs_fd = CTX->file_map()->get(fd);
    if(!gkfs_fd)
        return 0;
    return gkfs_read_ws(*gkfs_fd, reinterpret_cast<char*>(buf), count, offset);
}

@@ -1284,6 +1292,8 @@ ssize_t
gkfs_preadv(int fd, const struct iovec* iov, int iovcnt, off_t offset) {

    auto file = CTX->file_map()->get(fd);
    if(!file)
        return 0;
    auto pos = offset; // keep track of current position
    ssize_t read = 0;
    ssize_t ret;
@@ -1323,6 +1333,8 @@ ssize_t
gkfs_readv(int fd, const struct iovec* iov, int iovcnt) {

    auto gkfs_fd = CTX->file_map()->get(fd);
    if(!gkfs_fd)
        return 0;
    auto pos = gkfs_fd->pos(); // retrieve the current offset
    auto ret = gkfs_preadv(fd, iov, iovcnt, pos);
    assert(ret != 0);