aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorhuman <human@neet.fi>2021-01-07 16:31:52 +0200
committerhuman <human@neet.fi>2021-01-11 10:25:57 +0200
commita7ab34ebbce60f2af159f9010a2e3629756af3d1 (patch)
tree265c2026e52d8faee189b9a96c18b77557d427cb /fs
parent6d65a48d4e5fbd467c68f6e98301cf136115c570 (diff)
fix truncating in defineFile()
- in the C part: enable FUSE_CAP_ATOMIC_O_TRUNC so that open() will get called with O_TRUNC in flags instead of truncate() being called separately - this also prevents truncate() from calling setData() with an empty string when a file is opened with O_TRUNC - in defineFile()->open(): if O_TRUNC is used, don't call getData() but start with an empty file as if it had just been truncated - in defineFile()->write()/truncate(): correct buffer resizing/copying
Diffstat (limited to 'fs')
-rw-r--r--fs/tabfs.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/tabfs.c b/fs/tabfs.c
index 8c28dab..0eab91c 100644
--- a/fs/tabfs.c
+++ b/fs/tabfs.c
@@ -423,6 +423,20 @@ static int tabfs_create(const char *path, mode_t mode, struct fuse_file_info *fi
return 0;
}
+#define want_capability(conn, flag) \
+ do { \
+ if (conn->capable & flag) { \
+ conn->want |= flag; \
+ } else { \
+ eprintln("warning: " #flag " not supported"); \
+ } \
+ } while (0)
+
+static void *tabfs_init(struct fuse_conn_info *conn) {
+ want_capability(conn, FUSE_CAP_ATOMIC_O_TRUNC);
+ return NULL;
+}
+
static const struct fuse_operations tabfs_oper = {
.getattr = tabfs_getattr,
.readlink = tabfs_readlink,
@@ -441,6 +455,8 @@ static const struct fuse_operations tabfs_oper = {
.mkdir = tabfs_mkdir,
.create = tabfs_create,
+
+ .init = tabfs_init,
};
int main(int argc, char **argv) {