From ffb2658abbdf6ae65b31c2931b6a489747ba5a43 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Tue, 28 Jun 2022 14:45:31 +0100 Subject: [PATCH 1/2] getopt_long returns an int, not a char On platforms with an unsigned char, such as Arm, this results in always taking error paths around initialization. Fixes https://github.com/fangfufu/httpdirfs/issues/103 --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index f59a56d..8ceacda 100644 --- a/src/main.c +++ b/src/main.c @@ -169,7 +169,7 @@ void parse_config_file(char ***argv, int *argc) static int parse_arg_list(int argc, char **argv, char ***fuse_argv, int *fuse_argc) { - char c; + int c; int long_index = 0; const char *short_opts = "o:hVdfsp:u:P:"; const struct option long_opts[] = { From 72d15ab6c7ee25dfe61b50b33e88b555e3cfb038 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Tue, 28 Jun 2022 14:54:51 +0100 Subject: [PATCH 2/2] 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". --- src/fuse_local.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fuse_local.c b/src/fuse_local.c index aa71162..9873513 100644 --- a/src/fuse_local.c +++ b/src/fuse_local.c @@ -95,8 +95,8 @@ static int fs_open(const char *path, struct fuse_file_info *fi) if (!link) { return -ENOENT; } - if ((fi->flags & 3) != O_RDONLY) { - return -EACCES; + if ((fi->flags & O_RDWR) != O_RDONLY) { + return -EROFS; } if (CACHE_SYSTEM_INIT) { fi->fh = (uint64_t) Cache_open(path);