From 4bc654d80f36707d6a3a4a0ebb1300ba0948f80a Mon Sep 17 00:00:00 2001 From: Kirill Smelkov <kirr@nexedi.com> Date: Tue, 22 Oct 2019 15:41:32 +0300 Subject: [PATCH] . --- wcfs/internal/wcfs_misc.cpp | 6 +++--- wcfs/internal/wcfs_misc.h | 10 ++++++++-- wcfs/internal/wcfs_virtmem.cpp | 6 +++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/wcfs/internal/wcfs_misc.cpp b/wcfs/internal/wcfs_misc.cpp index b894119..a5ae1d5 100644 --- a/wcfs/internal/wcfs_misc.cpp +++ b/wcfs/internal/wcfs_misc.cpp @@ -22,11 +22,11 @@ // os:: namespace os { -tuple<File, error> open(const string &path) { +tuple<File, error> open(const string &path, int flags, mode_t mode) { File f = {.fd = -1, path = path}; - int err = std::open(path.c_str(), O_RDONLY); // XXX mode + int err = std::open(path.c_str(), flags, mode); if (err != 0) - return f, f._errno(); + return f, f._errno("open"); } error File::close() { diff --git a/wcfs/internal/wcfs_misc.h b/wcfs/internal/wcfs_misc.h index 943b179..5351f90 100644 --- a/wcfs/internal/wcfs_misc.h +++ b/wcfs/internal/wcfs_misc.h @@ -46,6 +46,10 @@ struct error { } }; +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + // os:: namespace os { @@ -60,8 +64,10 @@ struct File { }; // open opens file @path. -// XXX mode -tuple<File, error> open(const string &path); +tuple<File, error> open(const string &path, int flags = O_RDONLY, + mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR | + S_IRGRP | S_IWGRP | S_IXGRP | + S_IROTH | S_IWOTH | S_IXOTH); } // os:: diff --git a/wcfs/internal/wcfs_virtmem.cpp b/wcfs/internal/wcfs_virtmem.cpp index 68096d6..21e7a76 100644 --- a/wcfs/internal/wcfs_virtmem.cpp +++ b/wcfs/internal/wcfs_virtmem.cpp @@ -254,7 +254,7 @@ error _Mapping::_remmapblk(int64_t blk, Tid at) { else { // TODO share @rev fd until wconn is resynced? tie(fsfile, err) = f->wconn->_wc->_open( - fmt::sprintf("@%s/bigfile/%s", h_(at), h_(f->foid)), "rb"); + fmt::sprintf("@%s/bigfile/%s", h_(at), h_(f->foid))); if (err != nil) return err; defer(fsfile.close); @@ -289,10 +289,10 @@ string WCFS::_path(const string &obj) { return wc->mountpoint + "/" + obj; } -tuple<os::File, error> WCFS::_open(const string &path/*, XXX mode*/) { +tuple<os::File, error> WCFS::_open(const string &path, int flags=O_RDONLY) { WCFS *wc = this; string path_ = wc->_path(path); - return os::open(path_/*, XXX mode*/); + return os::open(path_, flags); } -- 2.30.9