replace getdir with readdir

This commit is contained in:
Valient Gough 2016-04-30 23:10:45 -07:00
parent ba9b25a1d2
commit 282fe77ec7
No known key found for this signature in database
GPG Key ID: B515DCEB95967051
3 changed files with 17 additions and 8 deletions

View File

@ -195,7 +195,8 @@ int encfs_fgetattr(const char *path, struct stat *stbuf,
return withFileNode("fgetattr", path, fi, bind(_do_getattr, _1, 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(); EncFS_Context *ctx = context();
int res = ESUCCESS; int res = ESUCCESS;
@ -206,7 +207,7 @@ int encfs_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler) {
DirTraverse dt = FSRoot->openDir(path); DirTraverse dt = FSRoot->openDir(path);
VLOG(1) << "getdir on " << FSRoot->cipherPath(path); VLOG(1) << "readdir on " << FSRoot->cipherPath(path);
if (dt.valid()) { if (dt.valid()) {
int fileType = 0; int fileType = 0;
@ -214,19 +215,26 @@ int encfs_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler) {
std::string name = dt.nextPlaintextName(&fileType, &inode); std::string name = dt.nextPlaintextName(&fileType, &inode);
while (!name.empty()) { 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); name = dt.nextPlaintextName(&fileType, &inode);
} }
} else { } else {
VLOG(1) << "getdir request invalid, path: '" << path << "'"; VLOG(1) << "readdir request invalid, path: '" << path << "'";
} }
return res; return res;
} catch (encfs::Error &err) { } catch (encfs::Error &err) {
RLOG(ERROR) << "Error caught in getdir"; RLOG(ERROR) << "Error caught in readdir";
return -EIO; 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, int encfs_fgetattr(const char *path, struct stat *stbuf,
struct fuse_file_info *fi); struct fuse_file_info *fi);
int encfs_readlink(const char *path, char *buf, size_t size); 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_mknod(const char *path, mode_t mode, dev_t rdev);
int encfs_mkdir(const char *path, mode_t mode); int encfs_mkdir(const char *path, mode_t mode);
int encfs_unlink(const char *path); int encfs_unlink(const char *path);

View File

@ -559,7 +559,7 @@ int main(int argc, char *argv[]) {
encfs_oper.getattr = encfs_getattr; encfs_oper.getattr = encfs_getattr;
encfs_oper.readlink = encfs_readlink; 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.mknod = encfs_mknod;
encfs_oper.mkdir = encfs_mkdir; encfs_oper.mkdir = encfs_mkdir;
encfs_oper.unlink = encfs_unlink; encfs_oper.unlink = encfs_unlink;