Commit 4127b332 authored by Ramon Nou's avatar Ramon Nou
Browse files

Solved fd flags bug on write

parent 532bf230
Loading
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -283,8 +283,8 @@ DLSYM_WRAPPER(int, fxstat64, (int ver, int fd, struct stat64* buf),
DLSYM_WRAPPER(int, __lxstat, (int ver, const char* path, struct stat* buf),
              (ver, path, buf), "__lxstat")

DLSYM_WRAPPER(int, lstat, (const char* path, struct stat* buf),
              (path, buf), "lstat")
DLSYM_WRAPPER(int, lstat, (const char* path, struct stat* buf), (path, buf),
              "lstat")

DLSYM_WRAPPER(int, lstat64, (const char* path, struct stat64* buf), (path, buf),
              "lstat64")
@@ -1799,11 +1799,11 @@ fdopen(int fd, const char* mode) {
            if(strchr(mode, 'r') != NULL)
                ret->_flags |= O_RDONLY;
            if(strchr(mode, 'w'))
                ret->_flags = O_WRONLY | O_CREAT | O_TRUNC;
                ret->_flags = O_WRONLY | O_CREAT | O_TRUNC | 0x2000;
            if(strchr(mode, 'a'))
                ret->_flags = O_WRONLY | O_CREAT | O_APPEND;
                ret->_flags = O_WRONLY | O_CREAT | O_APPEND | 0x2000;
            if(strchr(mode, '+'))
                ret->_flags = O_RDWR | O_CREAT;
                ret->_flags = O_RDWR | O_CREAT | 0x2000;
            ret->_fileno = fd;
            return ret;
        }
@@ -1861,7 +1861,8 @@ freopen64(const char* path, const char* mode, FILE* stream) {
            const int fd = gkfs::syscall::gkfs_open(resolved, 0666, flags);
            if(fd < 0)
                return nullptr;

            stream->_mode = 0666;
            stream->_flags = flags | 0x2000;
            stream->_fileno = fd;
            return stream;
        }
@@ -2573,6 +2574,3 @@ renameat2(int olddirfd, const char* oldpath, int newdirfd, const char* newpath,
    }
    GKFS_FALLBACK(renameat2, olddirfd, oldpath, newdirfd, newpath, flags);
}