Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
fuse: fix reads from files created using O_CREAT|O_RDWR
Browse files Browse the repository at this point in the history
"create" hook doesn't have sys_creat semantics.
When user passed O_CREAT | O_RDWR as flags to open, we created write-only
file handle...
  • Loading branch information
mslusarz committed Nov 2, 2017
1 parent 37044bf commit fd1280b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/pmemfile-fuse/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ pmemfile_fuse_chown(const char *path, uid_t uid, gid_t gid)
return 0;
}

static PMEMfile *
pmemfile_open_wrapper(PMEMfilepool *pfp, const char *path, int flags,
pmemfile_mode_t mode)
{
/*
* &~0x8000, because fuse passes flag pmemfile doesn't understand
* (O_LARGEFILE, which userspace on x86_64 defines as 0)
*/
return pmemfile_open(pfp, path, flags & ~0x8000, mode);
}

static int
pmemfile_fuse_create(const char *path, mode_t mode, struct fuse_file_info *fi)
{
Expand All @@ -266,9 +277,9 @@ pmemfile_fuse_create(const char *path, mode_t mode, struct fuse_file_info *fi)
if ((ret = update_ctx(pfp)) < 0)
return ret;

PMEMfile *f = pmemfile_create(pfp, path, mode);
PMEMfile *f = pmemfile_open_wrapper(pfp, path, fi->flags, mode);
if (!f) {
log("pmemfile_create %s failed: %d\n", path, errno);
log("pmemfile_open %s failed: %d\n", path, errno);
return -errno;
}
fi->fh = (uintptr_t)f;
Expand Down Expand Up @@ -306,11 +317,7 @@ pmemfile_fuse_open(const char *path, struct fuse_file_info *fi)
if ((ret = update_ctx(pfp)) < 0)
return ret;

/*
* &~0x8000, because fuse passes flag pmemfile doesn't understand
* (O_LARGEFILE, which userspace on x86_64 defines as 0)
*/
PMEMfile *f = pmemfile_open(pfp, path, fi->flags & ~0x8000);
PMEMfile *f = pmemfile_open_wrapper(pfp, path, fi->flags, 0);
if (f == NULL) {
log("pmemfile_open %s failed: %d\n", path, errno);
return -errno;
Expand Down

0 comments on commit fd1280b

Please sign in to comment.