Did you actually see a need for this fix? Even though the semantics of fuse_setattr allow for multiple attributes coming in the same call, it never happens practically. This is because the POSIX system calls which exist, change only one attribute at a time (chmod, chown, utimes) and fuse performs these calls synchronously. Maybe in the future if fuse (kernel module) does some kind of aggregation of these calls (quite tricky actually) into a single setattr call, moving in this direction might make sense.
Avati
On Jan 23, 2009 7:48 AM, "Filipe Maia" <filipe@xxxxxxxxxxxxxx> wrote:
Hi,
There is a problem with fuse_setattr() when the valid flag matches
more than one condition.
Imagine the following situation:
A file is created by the root and it's mode changed to 6555. Then the
owner is change to someone else.
When this happens the setuid and setgid bits are removed at the same
as the owner is changed.
In this case valid == FUSE_SET_ATTR_MODE|FUSE_SET_ATTR_UID | FUSE_SET_ATTR_GID.
Due to the if else structure of the code the chown call will only
change the permissions it will not actually change the owner. Only the
second chown call will change the owner.
Changing the if else to a bunch of ifs causes problem which I think
are related to double freeing of some variables. It seems to me that
with the current code it's difficult to do
two fops from the same setattr.
The best solution I found for now was to use the following patch:
--- fuse-bridge.c.old 2009-01-23 16:39:32.000000000 +0100
+++ fuse-bridge.c 2009-01-23 16:38:43.000000000 +0100
@@ -858,11 +858,10 @@
int valid,
struct fuse_file_info *fi)
{
-
- if (valid & FUSE_SET_ATTR_MODE)
- do_chmod (req, ino, attr, fi);
- else if (valid & (FUSE_SET_ATTR_UID | FUSE_SET_ATTR_GID))
+ if (valid & (FUSE_SET_ATTR_UID | FUSE_SET_ATTR_GID))
do_chown (req, ino, attr, valid, fi);
+ else if (valid & FUSE_SET_ATTR_MODE)
+ do_chmod (req, ino, attr, fi);
else if (valid & FUSE_SET_ATTR_SIZE)
do_truncate (req, ino, attr, fi);
else if (valid & (FUSE_SET_ATTR_ATIME | FUSE_SET_ATTR_MTIME))
Having the USE_SET_ATTR_UID | FUSE_SET_ATTR_GID tested before
FUSE_SET_ATTR_MOD will cause the correct behaviour with the chown on
my machine.
But hardly seems like a proper solution. The best way I think would be
to test all possible flags one at a time, but I didn't manage to get
that working.
Filipe
_______________________________________________
Gluster-devel mailing list
Gluster-devel@xxxxxxxxxx
http://lists.nongnu.org/mailman/listinfo/gluster-devel