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)
This commit is contained in:
Levi Neely 2026-03-20 17:33:17 +01:00
parent 5848a455a7
commit 9fcfccd6db
1 changed files with 2 additions and 2 deletions

View File

@ -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);