Merge pull request #164 from vgough/readdir

replace getdir with readdir
This commit is contained in:
Valient Gough 2016-05-10 22:53:47 -07:00
commit 3076450d34
3 changed files with 17 additions and 8 deletions

View File

@ -196,7 +196,8 @@ int encfs_fgetattr(const char *path, struct stat *stbuf,
return withFileNode("fgetattr", path, fi, bind(_do_getattr, _1, stbuf));
}
int encfs_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler) {
int encfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *finfo) {
EncFS_Context *ctx = context();
int res = ESUCCESS;
@ -207,7 +208,7 @@ int encfs_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler) {
DirTraverse dt = FSRoot->openDir(path);
VLOG(1) << "getdir on " << FSRoot->cipherPath(path);
VLOG(1) << "readdir on " << FSRoot->cipherPath(path);
if (dt.valid()) {
int fileType = 0;
@ -215,19 +216,26 @@ int encfs_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler) {
std::string name = dt.nextPlaintextName(&fileType, &inode);
while (!name.empty()) {
res = filler(h, name.c_str(), fileType, inode);
struct stat st;
st.st_ino = inode;
st.st_mode = fileType << 12;
if (res != ESUCCESS) break;
// TODO: add offset support.
#if defined(fuse_fill_dir_flags)
if (filler(buf, name.c_str(), &st, 0, 0)) break;
#else
if (filler(buf, name.c_str(), &st, 0)) break;
#endif
name = dt.nextPlaintextName(&fileType, &inode);
}
} else {
VLOG(1) << "getdir request invalid, path: '" << path << "'";
VLOG(1) << "readdir request invalid, path: '" << path << "'";
}
return res;
} catch (encfs::Error &err) {
RLOG(ERROR) << "Error caught in getdir";
RLOG(ERROR) << "Error caught in readdir";
return -EIO;
}
}

View File

@ -62,7 +62,8 @@ int encfs_getattr(const char *path, struct stat *stbuf);
int encfs_fgetattr(const char *path, struct stat *stbuf,
struct fuse_file_info *fi);
int encfs_readlink(const char *path, char *buf, size_t size);
int encfs_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler);
int encfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *finfo);
int encfs_mknod(const char *path, mode_t mode, dev_t rdev);
int encfs_mkdir(const char *path, mode_t mode);
int encfs_unlink(const char *path);

View File

@ -558,7 +558,7 @@ int main(int argc, char *argv[]) {
encfs_oper.getattr = encfs_getattr;
encfs_oper.readlink = encfs_readlink;
encfs_oper.getdir = encfs_getdir; // deprecated for readdir
encfs_oper.readdir = encfs_readdir;
encfs_oper.mknod = encfs_mknod;
encfs_oper.mkdir = encfs_mkdir;
encfs_oper.unlink = encfs_unlink;