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:
parent
5848a455a7
commit
9fcfccd6db
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue