<br><br><div class="gmail_quote">On Mon, May 21, 2012 at 10:33 PM, Emmanuel Dreyfus <span dir="ltr"><<a href="mailto:manu@netbsd.org" target="_blank">manu@netbsd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Anand Avati <<a href="mailto:anand.avati@gmail.com">anand.avati@gmail.com</a>> wrote:<br>
<br>
> Is the FUSE SETATTR implementation in NetBSD synchronous? i.e, does the<br>
> chown() or chmod() syscall issued by the application strictly block till<br>
> GlusterFS's fuse_setattr_cbk() is called?<br>
<br>
I have been able to narrow the test down to the code below, which does not even<br>
call chown().<br>
<br>
#include <stdio.h><br>
#include <stdlib.h><br>
#include <unistd.h><br>
#include <fcntl.h><br>
#include <err.h><br>
#include <sysexits.h><br>
<br>
int<br>
main(void)<br>
{<br>
int fd;<br>
<br>
(void)mkdir("subdir", 0755);<br>
<br>
do {<br>
if ((fd = open("subdir/bugc1.txt", O_CREAT|O_RDWR, 0644)) == -1)<br>
err(EX_OSERR, "open failed");<br>
<br>
if (close(fd) == -1)<br>
err(EX_OSERR, "close failed");<br>
<br>
if (unlink("subdir/bugc1.txt") == -1)<br>
err(EX_OSERR, "unlink failed");<br>
} while (1 /*CONSTCOND */);<br>
<br>
/* NOTREACHED */<br>
return EX_OK;<br>
}<br>
<br>
It produces a FUSE trace without SETATTR:<br>
<br>
> unique = 393, nodeid = <a href="tel:3098542496" value="+13098542496">3098542496</a>, opcode = LOOKUP (1)<br>
< unique = 393, nodeid = <a href="tel:3098542496" value="+13098542496">3098542496</a>, opcode = LOOKUP (1), error = -2<br>
> unique = 394, nodeid = <a href="tel:3098542496" value="+13098542496">3098542496</a>, opcode = CREATE (35)<br>
< unique = 394, nodeid = <a href="tel:3098542496" value="+13098542496">3098542496</a>, opcode = CREATE (35), error = 0<br>
<br>
-> I suspect (not yet checked) this is the place where I get fuse_entry_out<br>
with attr.uid = 0. This will be cached since attr_valid tells us to do so.<br>
<br>
> unique = 395, nodeid = <a href="tel:3098542396" value="+13098542396">3098542396</a>, opcode = RELEASE (18)<br>
< unique = 395, nodeid = <a href="tel:3098542396" value="+13098542396">3098542396</a>, opcode = RELEASE (18), error = 0<br>
> unique = 396, nodeid = <a href="tel:3098542296" value="+13098542296">3098542296</a>, opcode = LOOKUP (1)<br>
< unique = 396, nodeid = <a href="tel:3098542296" value="+13098542296">3098542296</a>, opcode = LOOKUP (1), error = 0<br>
<br>
>From other traces, I can tell that this last lookup is for the parent directory<br>
(subdir). The FUSE request for looking up bugc1.txt with the intent of deleting<br>
is not even sent: from cached uid we obtained from fuse_entry_out, we know that<br>
permissions shall be denied (I had a debug printf to check that). We do not even<br>
ask.<br>
<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>Even in the case where bugc1.txt got a wrong uid returned (assuming so), it should not influence the permissibility of it getting deleted. The deletability of a file is based on the permissions on the parent directory and not the ownership of the file (unless +t sticky bit was set on the directory).</div>
<div><br></div><div>Is there a way you can extend the trace code above to show the UIDs getting returned? Maybe it was the parent directory (subdir) that got a wrong UID returned?</div><div><br></div><div>Avati</div></div>