Commit ea3997a8 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent fc4ab83b
...@@ -21,6 +21,13 @@ ...@@ -21,6 +21,13 @@
namespace os { namespace os {
tuple<File, error> open(const string &path) {
File f = {.fd = -1, path = path};
int err = std::open(path.c_str(), O_RDONLY); // XXX mode
if (err != 0)
return f, f._errno();
}
error File::close() { error File::close() {
File *f = this; File *f = this;
...@@ -44,4 +51,5 @@ error File::_err(const char *op) { ...@@ -44,4 +51,5 @@ error File::_err(const char *op) {
return errorf("%s %s: %s", op, f->path, strerror_r(errno)); return errorf("%s %s: %s", op, f->path, strerror_r(errno));
} }
} // os:: } // os::
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
#include <string> #include <string>
using std::string; using std::string;
#include <tuple>
using std::tuple;
// error mimics error from Go. // error mimics error from Go.
struct error { struct error {
string err; string err;
...@@ -51,7 +54,9 @@ struct File { ...@@ -51,7 +54,9 @@ struct File {
error stat(struct stat *st); error stat(struct stat *st);
}; };
// XXX tuple<File, error> open(const string &path) // open opens file @path.
// XXX mode
tuple<File, error> open(const string &path);
} // os:: } // os::
......
...@@ -73,6 +73,7 @@ struct SrvReq; ...@@ -73,6 +73,7 @@ struct SrvReq;
struct WCFS { struct WCFS {
Conn *connect(Tid at); Conn *connect(Tid at);
tuple<os::File, error> _open(const string &path /*, XXX mode*/);
}; };
// Conn represents logical connection that provides view of data on wcfs // Conn represents logical connection that provides view of data on wcfs
...@@ -264,3 +265,12 @@ void _Mapping::_remmapblk(int64_t blk, Tid at) { ...@@ -264,3 +265,12 @@ void _Mapping::_remmapblk(int64_t blk, Tid at) {
mm.map_into_ro(blkmem, fsfile.fd, blk*f->blksize); mm.map_into_ro(blkmem, fsfile.fd, blk*f->blksize);
} }
} }
// ---- WCFS raw file access ----
tuple<os::File, error> WCFS::_open(const string &path/*, XXX mode*/) {
WCFS *wc = this;
path_ = wc->_path(path);
return os::open(path_/*, XXX mode*/);
}
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