encfs.cpp (encfs-1.9.4) | : | encfs.cpp (encfs-1.9.5) | ||
---|---|---|---|---|
skipping to change at line 142 | skipping to change at line 142 | |||
throw Error("dead canary"); | throw Error("dead canary"); | |||
} | } | |||
// helper function -- apply a functor to a node | // helper function -- apply a functor to a node | |||
static int withFileNode(const char *opName, const char *path, | static int withFileNode(const char *opName, const char *path, | |||
struct fuse_file_info *fi, | struct fuse_file_info *fi, | |||
const function<int(FileNode *)> &op) { | const function<int(FileNode *)> &op) { | |||
EncFS_Context *ctx = context(); | EncFS_Context *ctx = context(); | |||
int res = -EIO; | int res = -EIO; | |||
std::shared_ptr<DirNode> FSRoot = ctx->getRoot(&res); | bool skipUsageCount = false; | |||
if (strlen(path) == 1) { | ||||
skipUsageCount = true; | ||||
} | ||||
std::shared_ptr<DirNode> FSRoot = ctx->getRoot(&res, skipUsageCount); | ||||
if (!FSRoot) { | if (!FSRoot) { | |||
return res; | return res; | |||
} | } | |||
try { | try { | |||
auto do_op = [&FSRoot, opName, &op](std::shared_ptr<FileNode> fnode) { | auto do_op = [&FSRoot, opName, &op](std::shared_ptr<FileNode> fnode) { | |||
rAssert(fnode != nullptr); | rAssert(fnode != nullptr); | |||
checkCanary(fnode); | checkCanary(fnode); | |||
VLOG(1) << "op: " << opName << " : " << fnode->cipherName(); | VLOG(1) << "op: " << opName << " : " << fnode->cipherName(); | |||
skipping to change at line 166 | skipping to change at line 170 | |||
VLOG(1) << "op: " << opName << " error: Tried to touch mountpoint: '" | VLOG(1) << "op: " << opName << " error: Tried to touch mountpoint: '" | |||
<< fnode->cipherName() << "'"; | << fnode->cipherName() << "'"; | |||
return -EIO; | return -EIO; | |||
} | } | |||
return op(fnode.get()); | return op(fnode.get()); | |||
}; | }; | |||
if (fi != nullptr && fi->fh != 0) { | if (fi != nullptr && fi->fh != 0) { | |||
auto node = ctx->lookupFuseFh(fi->fh); | auto node = ctx->lookupFuseFh(fi->fh); | |||
if (node == nullptr) { | if (node == nullptr) { | |||
#ifdef __CYGWIN__ | ||||
if (strcmp(opName, "flush") == 0) { | ||||
RLOG(WARNING) << "Filenode to flush not found, file has certainly be r | ||||
enamed: " | ||||
<< path; | ||||
return 0; | ||||
} | ||||
#endif | ||||
auto msg = "fh=" + std::to_string(fi->fh) + " not found in fuseFhMap"; | auto msg = "fh=" + std::to_string(fi->fh) + " not found in fuseFhMap"; | |||
throw Error(msg.c_str()); | throw Error(msg.c_str()); | |||
} | } | |||
res = do_op(node); | res = do_op(node); | |||
} else { | } else { | |||
res = do_op(FSRoot->lookupNode(path, opName)); | res = do_op(FSRoot->lookupNode(path, opName)); | |||
} | } | |||
if (res < 0) { | if (res < 0) { | |||
RLOG(DEBUG) << "op: " << opName << " error: " << strerror(-res); | RLOG(DEBUG) << "op: " << opName << " error: " << strerror(-res); | |||
skipping to change at line 503 | skipping to change at line 514 | |||
res = -errno; | res = -errno; | |||
} else { | } else { | |||
res = ESUCCESS; | res = ESUCCESS; | |||
} | } | |||
} catch (encfs::Error &err) { | } catch (encfs::Error &err) { | |||
RLOG(ERROR) << "error caught in symlink: " << err.what(); | RLOG(ERROR) << "error caught in symlink: " << err.what(); | |||
} | } | |||
return res; | return res; | |||
} | } | |||
int encfs_link(const char *from, const char *to) { | int encfs_link(const char *to, const char *from) { | |||
EncFS_Context *ctx = context(); | EncFS_Context *ctx = context(); | |||
if (isReadOnly(ctx)) { | if (isReadOnly(ctx)) { | |||
return -EROFS; | return -EROFS; | |||
} | } | |||
int res = -EIO; | int res = -EIO; | |||
std::shared_ptr<DirNode> FSRoot = ctx->getRoot(&res); | std::shared_ptr<DirNode> FSRoot = ctx->getRoot(&res); | |||
if (!FSRoot) { | if (!FSRoot) { | |||
return res; | return res; | |||
} | } | |||
try { | try { | |||
res = FSRoot->link(from, to); | res = FSRoot->link(to, from); | |||
} catch (encfs::Error &err) { | } catch (encfs::Error &err) { | |||
RLOG(ERROR) << "error caught in link: " << err.what(); | RLOG(ERROR) << "error caught in link: " << err.what(); | |||
} | } | |||
return res; | return res; | |||
} | } | |||
int encfs_rename(const char *from, const char *to) { | int encfs_rename(const char *from, const char *to) { | |||
EncFS_Context *ctx = context(); | EncFS_Context *ctx = context(); | |||
if (isReadOnly(ctx)) { | if (isReadOnly(ctx)) { | |||
End of changes. 4 change blocks. | ||||
3 lines changed or deleted | 15 lines changed or added |