aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/user/vfs.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-09 21:28:11 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-09 21:28:11 +0100
commit8bfbc4b05b219950e3eb8ac377b8cb3020ddb9ab (patch)
treed6dc0ff3158e2531820d323ceb925c79b5d99425 /src/kernel/user/vfs.c
parentf90436dd7415354105a27846e587adefaea7ef63 (diff)
downloadkogata-8bfbc4b05b219950e3eb8ac377b8cb3020ddb9ab.tar.gz
kogata-8bfbc4b05b219950e3eb8ac377b8cb3020ddb9ab.zip
Work on nullfs
Diffstat (limited to 'src/kernel/user/vfs.c')
-rw-r--r--src/kernel/user/vfs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/kernel/user/vfs.c b/src/kernel/user/vfs.c
index ebd5808..83f1377 100644
--- a/src/kernel/user/vfs.c
+++ b/src/kernel/user/vfs.c
@@ -42,6 +42,7 @@ fs_t *make_fs(const char* drv_name, fs_handle_t *source, char* opts) {
if (fs == 0) return 0;
if (d->ops->make(source, opts, fs)) {
+ fs->refs = 1;
return fs;
} else {
free(fs);
@@ -92,6 +93,7 @@ fs_handle_t* fs_open(fs_t *fs, const char* file, int mode) {
if (h == 0) return 0;
if (fs->ops->open(fs->data, file, mode, h)) {
+ h->refs = 1;
return h;
} else {
free(h);
@@ -112,10 +114,14 @@ void unrefe_file(fs_handle_t *file) {
}
size_t file_read(fs_handle_t *f, size_t offset, size_t len, char* buf) {
+ if (!(f->mode && FM_READ)) return 0;
+
return f->ops->read && f->ops->read(f->data, offset, len, buf);
}
size_t file_write(fs_handle_t *f, size_t offset, size_t len, const char* buf) {
+ if (!(f->mode && FM_WRITE)) return 0;
+
return f->ops->write && f->ops->write(f->data, offset, len, buf);
}