<br><br><div class="gmail_quote">On Mon, May 21, 2012 at 10:33 PM, Emmanuel Dreyfus <span dir="ltr">&lt;<a href="mailto:manu@netbsd.org" target="_blank">manu@netbsd.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Anand Avati &lt;<a href="mailto:anand.avati@gmail.com">anand.avati@gmail.com</a>&gt; wrote:<br>
<br>
&gt; Is the FUSE SETATTR implementation in NetBSD synchronous? i.e, does the<br>
&gt; chown() or chmod() syscall issued by the application strictly block till<br>
&gt; GlusterFS&#39;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 &lt;stdio.h&gt;<br>
#include &lt;stdlib.h&gt;<br>
#include &lt;unistd.h&gt;<br>
#include &lt;fcntl.h&gt;<br>
#include &lt;err.h&gt;<br>
#include &lt;sysexits.h&gt;<br>
<br>
int<br>
main(void)<br>
{<br>
        int fd;<br>
<br>
        (void)mkdir(&quot;subdir&quot;, 0755);<br>
<br>
        do {<br>
                if ((fd = open(&quot;subdir/bugc1.txt&quot;, O_CREAT|O_RDWR, 0644)) == -1)<br>
                        err(EX_OSERR, &quot;open failed&quot;);<br>
<br>
                if (close(fd) == -1)<br>
                        err(EX_OSERR, &quot;close failed&quot;);<br>
<br>
                if (unlink(&quot;subdir/bugc1.txt&quot;) == -1)<br>
                        err(EX_OSERR, &quot;unlink failed&quot;);<br>
        } while (1 /*CONSTCOND */);<br>
<br>
        /* NOTREACHED */<br>
        return EX_OK;<br>
}<br>
<br>
It produces a FUSE trace without SETATTR:<br>
<br>
&gt; unique = 393, nodeid = <a href="tel:3098542496" value="+13098542496">3098542496</a>, opcode = LOOKUP (1)<br>
&lt; unique = 393, nodeid = <a href="tel:3098542496" value="+13098542496">3098542496</a>, opcode = LOOKUP (1), error = -2<br>
&gt; unique = 394, nodeid = <a href="tel:3098542496" value="+13098542496">3098542496</a>, opcode = CREATE (35)<br>
&lt; unique = 394, nodeid = <a href="tel:3098542496" value="+13098542496">3098542496</a>, opcode = CREATE (35), error = 0<br>
<br>
 -&gt; 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>
&gt; unique = 395, nodeid = <a href="tel:3098542396" value="+13098542396">3098542396</a>, opcode = RELEASE (18)<br>
&lt; unique = 395, nodeid = <a href="tel:3098542396" value="+13098542396">3098542396</a>, opcode = RELEASE (18), error = 0<br>
&gt; unique = 396, nodeid = <a href="tel:3098542296" value="+13098542296">3098542296</a>, opcode = LOOKUP (1)<br>
&lt; 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>