Commit 4bc654d8 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent cdf82174
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
// os:: // os::
namespace 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}; 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) if (err != 0)
return f, f._errno(); return f, f._errno("open");
} }
error File::close() { error File::close() {
......
...@@ -46,6 +46,10 @@ struct error { ...@@ -46,6 +46,10 @@ struct error {
} }
}; };
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
// os:: // os::
namespace os { namespace os {
...@@ -60,8 +64,10 @@ struct File { ...@@ -60,8 +64,10 @@ struct File {
}; };
// open opens file @path. // open opens file @path.
// XXX mode tuple<File, error> open(const string &path, int flags = O_RDONLY,
tuple<File, error> open(const string &path); mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IWGRP | S_IXGRP |
S_IROTH | S_IWOTH | S_IXOTH);
} // os:: } // os::
......
...@@ -254,7 +254,7 @@ error _Mapping::_remmapblk(int64_t blk, Tid at) { ...@@ -254,7 +254,7 @@ error _Mapping::_remmapblk(int64_t blk, Tid at) {
else { else {
// TODO share @rev fd until wconn is resynced? // TODO share @rev fd until wconn is resynced?
tie(fsfile, err) = f->wconn->_wc->_open( 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) if (err != nil)
return err; return err;
defer(fsfile.close); defer(fsfile.close);
...@@ -289,10 +289,10 @@ string WCFS::_path(const string &obj) { ...@@ -289,10 +289,10 @@ string WCFS::_path(const string &obj) {
return wc->mountpoint + "/" + 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; WCFS *wc = this;
string path_ = wc->_path(path); string path_ = wc->_path(path);
return os::open(path_/*, XXX mode*/); return os::open(path_, flags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment