summaryrefslogtreecommitdiff
path: root/netfs/fuse/fuseFiles.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'netfs/fuse/fuseFiles.cpp')
-rw-r--r--netfs/fuse/fuseFiles.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp
index 4ea7f47..c166e46 100644
--- a/netfs/fuse/fuseFiles.cpp
+++ b/netfs/fuse/fuseFiles.cpp
@@ -205,10 +205,18 @@ FuseApp::write(const char *, const char * buf, size_t s, off_t o, struct fuse_fi
}
int
-FuseApp::truncate(const char * p, off_t o)
+FuseApp::truncate(const char * p, off_t o, fuse_file_info * fi)
{
try {
- volume->truncate(reqEnv(), p, o);
+ if (fi) {
+ auto of = getProxy<OpenFilePtr>(fi->fh);
+ of->wait();
+ auto remote = of->remote;
+ remote->ftruncate(reqEnv(), o);
+ }
+ else {
+ volume->truncate(reqEnv(), p, o);
+ }
return 0;
}
catch (SystemError & e) {
@@ -217,28 +225,24 @@ FuseApp::truncate(const char * p, off_t o)
}
int
-FuseApp::ftruncate(const char *, off_t o, fuse_file_info * fi)
+FuseApp::getattr(const char * p, struct stat * s, fuse_file_info * fi)
{
try {
- auto of = getProxy<OpenFilePtr>(fi->fh);
- of->wait();
- auto remote = of->remote;
- remote->ftruncate(reqEnv(), o);
- return 0;
- }
- catch (SystemError & e) {
- return -e.syserrno;
- }
-}
+ if (fi) {
+ auto of = getProxy<OpenFilePtr>(fi->fh);
+ of->wait();
+ auto remote = of->remote;
+ *s = converter.convert(remote->fgetattr(reqEnv()));
+ }
+ else {
+ if (auto cacehedStat = statCache.get(p)) {
+ *s = *cacehedStat;
+ }
+ else {
+ *s = converter.convert(volume->getattr(reqEnv(), p));
+ }
-int
-FuseApp::fgetattr(const char *, struct stat * s, fuse_file_info * fi)
-{
- try {
- auto of = getProxy<OpenFilePtr>(fi->fh);
- of->wait();
- auto remote = of->remote;
- *s = converter.convert(remote->fgetattr(reqEnv()));
+ }
return 0;
}
catch (SystemError & e) {