Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

O_RDWR support

  • Loading branch information...
commit 418cc97ee5f27a2764fe175a544fa8221301a51b 1 parent 04c6b9d
@mikejs authored
Showing with 17 additions and 6 deletions.
  1. +17 −6 operations.cpp
View
23 operations.cpp
@@ -115,6 +115,10 @@ int gridfs_open(const char *path, struct fuse_file_info *fi)
path = fuse_to_mongo_path(path);
if((fi->flags & O_ACCMODE) == O_RDONLY) {
+ if(open_files.find(path) != open_files.end()) {
+ return 0;
+ }
+
ScopedDbConnection sdc(gridfs_options.host);
GridFS gf(sdc.conn(), gridfs_options.db);
GridFile file = gf.findFile(path);
@@ -126,11 +130,7 @@ int gridfs_open(const char *path, struct fuse_file_info *fi)
return -ENOENT;
} else {
- if(open_files.find(path) != open_files.end()) {
- return 0;
- }
-
- return -ENOENT;
+ return -EACCES;
}
}
@@ -147,7 +147,7 @@ int gridfs_release(const char* path, struct fuse_file_info* ffi)
{
path = fuse_to_mongo_path(path);
- if(open_files.find(path) == open_files.end()) {
+ if((ffi->flags & O_ACCMODE) == O_RDONLY) {
return 0;
}
@@ -174,6 +174,13 @@ int gridfs_read(const char *path, char *buf, size_t size, off_t offset,
path = fuse_to_mongo_path(path);
size_t len = 0;
+ map<string,LocalGridFile*>::const_iterator file_iter;
+ file_iter = open_files.find(path);
+ if(file_iter != open_files.end()) {
+ LocalGridFile *lgf = file_iter->second;
+ return lgf->read(buf, size, offset);
+ }
+
ScopedDbConnection sdc(gridfs_options.host);
GridFS gf(sdc.conn(), gridfs_options.db);
GridFile file = gf.findFile(path);
@@ -261,6 +268,10 @@ int gridfs_getxattr(const char* path, const char* name, char* value, size_t size
return -ENOATTR;
}
+ if(open_files.find(path) != open_files.end()) {
+ return -ENOATTR;
+ }
+
ScopedDbConnection sdc(gridfs_options.host);
GridFS gf(sdc.conn(), gridfs_options.db);
GridFile file = gf.findFile(path);
Please sign in to comment.
Something went wrong with that request. Please try again.