diff --git a/src/system/libroot/posix/fcntl.cpp b/src/system/libroot/posix/fcntl.cpp index ad9874a3f1..0bfa7f9977 100644 --- a/src/system/libroot/posix/fcntl.cpp +++ b/src/system/libroot/posix/fcntl.cpp @@ -102,5 +102,13 @@ posix_fallocate(int fd, off_t offset, off_t len) if (len == 0 || offset < 0) return EINVAL; - return _kern_preallocate(fd, offset, len); + int error = _kern_preallocate(fd, offset, len); + if (error == B_UNSUPPORTED) { + // While the official specification for this function does not + // prescribe which error code to use when the underlying file system + // does not support preallocation, we will convert B_UNSUPPORTED to + // EOPNOTSUPP for better compatibility with existing applications. + return EOPNOTSUPP; + } + return error; }