mirror of
https://github.com/vgough/encfs.git
synced 2025-02-16 09:49:46 +01:00
Merge pull request #164 from vgough/readdir
replace getdir with readdir
This commit is contained in:
commit
3076450d34
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user