Skip to content

Commit 72d15ab

Browse files
committed
fs_open: return EROFS for non-RO opens
The use of EACCES leads to slightly confusing error messages in downstream consumers, so prefer EROFS to better articulate what's actually happening. While here, use O_RDWR to mask the open flags while testing for non-RO access. This is at least encouraged by POSIX with their suggestion that "O_RDONLY | O_WRONLY == O_RDWR".
1 parent ffb2658 commit 72d15ab

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/fuse_local.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ static int fs_open(const char *path, struct fuse_file_info *fi)
9595
if (!link) {
9696
return -ENOENT;
9797
}
98-
if ((fi->flags & 3) != O_RDONLY) {
99-
return -EACCES;
98+
if ((fi->flags & O_RDWR) != O_RDONLY) {
99+
return -EROFS;
100100
}
101101
if (CACHE_SYSTEM_INIT) {
102102
fi->fh = (uint64_t) Cache_open(path);

0 commit comments

Comments
 (0)