Verified Commit ffc27e88 authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

faccessat support AT_FDCWD flag

parent 83fbdf9a
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -570,7 +570,13 @@ int faccessat(int dirfd, const char* cpath, int mode, int flags) __THROW {

    std::string resolved;

    if(cpath[0] != PSP) {
    if((cpath[0] == PSP) || (dirfd == AT_FDCWD)) {
        // cpath is absolute or relative to CWD
        if (CTX->relativize_path(cpath, resolved)) {
            return adafs_access(resolved, mode);
        }
    } else {
        // cpath is relative
        if(!(CTX->file_map()->exist(dirfd))) {
            //TODO relative cpath could still lead to our FS
            return LIBC_FUNC(faccessat, dirfd, cpath, mode, flags);
@@ -590,10 +596,6 @@ int faccessat(int dirfd, const char* cpath, int mode, int flags) __THROW {
        if(resolve_path(path, resolved)) {
            return adafs_access(resolved, mode);
        }
    } else {
        if (CTX->relativize_path(cpath, resolved)) {
            return adafs_access(resolved, mode);
        }
    }
    return LIBC_FUNC(faccessat, dirfd, resolved.c_str(), mode, flags);
}