Skip to content

Commit

Permalink
fuse: fix truncate after open
Browse files Browse the repository at this point in the history
Commit e1181ee "vfs: pass struct file to do_truncate on O_TRUNC
opens" broke the behavior of open(O_TRUNC|O_RDONLY) in fuse.  Fuse
assumed that when called from open, a truncate() will be done, not an
ftruncate().

Fix by restoring the old behavior, based on the ATTR_OPEN flag.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
  • Loading branch information
Miklos Szeredi committed Feb 25, 2011
1 parent 5a18ec1 commit 8d56add
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1283,8 +1283,11 @@ static int fuse_do_setattr(struct dentry *entry, struct iattr *attr,
if (err)
return err;

if ((attr->ia_valid & ATTR_OPEN) && fc->atomic_o_trunc)
return 0;
if (attr->ia_valid & ATTR_OPEN) {
if (fc->atomic_o_trunc)
return 0;
file = NULL;
}

if (attr->ia_valid & ATTR_SIZE)
is_truncate = true;
Expand Down

0 comments on commit 8d56add

Please sign in to comment.