From 9fcfccd6db2278549cd09ec33226eb56712a6726 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Fri, 20 Mar 2026 17:33:17 +0100 Subject: [PATCH] 9pfuse: fix truncate for modern kernels Modern Linux kernels send additional flags (FATTR_CTIME, etc.) along with FATTR_SIZE when truncating files. The exact equality check (in->valid == FATTR_SIZE) failed, causing shell redirections like 'echo foo > file' to return ENOSYS on existing files. Change to a bitmask check: (in->valid & FATTR_SIZE) --- src/cmd/9pfuse/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c index ca9f3872..9dc950af 100644 --- a/src/cmd/9pfuse/main.c +++ b/src/cmd/9pfuse/main.c @@ -495,7 +495,7 @@ fusesetattr(FuseMsg *m) * Synthetic file servers (e.g., plumber) honor * open(OTRUNC) but not wstat. */ - if(in->valid == FATTR_SIZE && in->size == 0){ + if((in->valid & FATTR_SIZE) && in->size == 0){ if((nfid = fswalk(fid, nil)) == nil){ replyfuseerrstr(m); return; @@ -737,7 +737,7 @@ fusecreate(FuseMsg *m) flags &= ~3; flags &= ~(O_DIRECTORY|O_NONBLOCK|O_LARGEFILE|O_EXCL); flags &= ~O_APPEND; /* see comment in _fuseopen */ - flags &= ~(O_CREAT|O_TRUNC); /* huh? */ + flags &= ~(O_CREAT|O_TRUNC); if(flags){ fprint(2, "bad mode %#uo\n", in->flags); replyfuseerrno(m, EACCES);