<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 20, 2014 at 3:39 AM, Pavel Emelyanov <span dir="ltr">&lt;<a href="mailto:xemul@parallels.com" target="_blank">xemul@parallels.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">On 08/20/2014 10:21 AM, Saied Kazemi wrote:<br>

<br>
&gt;     &gt; Thanks again for your feedback.  I hope the answers are clear.  If it&#39;s easier or more productive,<br>
&gt;     &gt; I am available on video chat to discuss in greater detail.  My schedule is flexible, so time<br>
&gt;     &gt; difference shouldn&#39;t be a problem.<br>
&gt;<br>
&gt;     OK, I&#39;ll keep that in mind :) Your timezone is US Pacific one, right?<br>
&gt;<br>
&gt;<br>
&gt; Yes, I am in Mountain View.<br>
&gt;<br>
&gt; Looking forward to your comments on this patch which I think has addressed everything above.<br>
<br>
</div>Yup, I think this patch is perfect. Only one question left:<br></blockquote><div><br></div><div>Great!</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<br>
&gt; @@ -240,6 +244,31 @@ static int vma_get_mapfile(struct vma_area *vma, DIR *mfd,<br>
&gt;                       vma-&gt;vm_socket_id = buf.st_ino;<br>
&gt;               } else if (errno != ENOENT)<br>
&gt;                       return -1;<br>
&gt; +     } else if (opts.aufs) {<br>
&gt; +             /*<br>
&gt; +              * AUFS support to compensate for the kernel bug<br>
&gt; +              * exposing branch pathnames in map_files.<br>
&gt; +              *<br>
&gt; +              * If the link points inside a branch, replace it<br>
&gt; +              * with a pathname from the root for later use in<br>
&gt; +              * dump_filemap().<br>
&gt; +              */<br>
&gt; +             char p[PATH_MAX];<br>
&gt; +             int n;<br>
&gt; +<br>
&gt; +             p[0] = &#39;.&#39;;<br>
&gt; +             n = read_fd_link(vma-&gt;vm_file_fd, &amp;p[1], sizeof p - 1);<br>
<div class="">&gt; +             if (n &lt; 0)<br>
&gt; +                     return -1;<br>
</div>&gt; +             n = fixup_aufs_path(&amp;p[1], sizeof p - 1, true);<br>
<div class="">&gt; +             if (n &lt; 0)<br>
&gt; +                     return -1;<br>
&gt; +             if (n &gt; 0) {<br>
</div>&gt; +                     vma-&gt;aufs_rpath = xmalloc(n + 2);<br>
&gt; +                     if (!vma-&gt;aufs_rpath)<br>
&gt; +                             return -1;<br>
&gt; +                     strcpy(vma-&gt;aufs_rpath, p);<br>
&gt; +             }<br>
&gt;       }<br>
&gt;<br>
&gt;       return 0;<br>
&gt; @@ -450,12 +479,24 @@ int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list, bool use_map_file<br>
<div class="">&gt;                       vma_area-&gt;st = prev-&gt;st;<br>
&gt;               } else if (vma_area-&gt;vm_file_fd &gt;= 0) {<br>
&gt;                       struct stat *st_buf;<br>
&gt; +                     char *f;<br>
&gt;<br>
&gt;                       st_buf = vma_area-&gt;st = xmalloc(sizeof(*st_buf));<br>
&gt;                       if (!st_buf)<br>
&gt;                               goto err;<br>
&gt;<br>
&gt; -                     if (fstat(vma_area-&gt;vm_file_fd, st_buf) &lt; 0) {<br>
&gt; +                     /*<br>
</div>&gt; +                      * For AUFS support, we cannot fstat() a file descriptor that<br>
<div class="">&gt; +                      * is a symbolic link to a branch.  Instead, we obtain the<br>
&gt; +                      * pathname of the file from the root and use stat().<br>
&gt; +                      */<br>
&gt; +                     if (opts.aufs &amp;&amp; (f = fixup_aufs_fd_path(vma_area-&gt;vm_file_fd))) {<br>
</div><div class="">&gt; +                             if (stat(f, st_buf) &lt; 0) {<br>
</div>&gt; +                                     pr_perror(&quot;Failed stat on %d&#39;s map %lu (%s)&quot;,<br>
<div class="">&gt; +                                             pid, start, f);<br>
&gt; +                                     goto err;<br>
&gt; +                             }<br>
&gt; +                     } else if (fstat(vma_area-&gt;vm_file_fd, st_buf) &lt; 0) {<br>
&gt;                               pr_perror(&quot;Failed fstat on %d&#39;s map %lu&quot;, pid, start);<br>
&gt;                               goto err;<br>
&gt;                       }<br>
<br>
</div>Why do we need the 2nd call to fixup branch name? Can&#39;t we just stat<br>
the vma-&gt;aufs_rpath here?<br></blockquote><div><br></div><div>That&#39;s because vma-&gt;aufs_rpath is relative from the root of the mount namespace (e.g., ./bin/busybox) but we are not in that directory (we&#39;re in /).  To avoid calling fixup we can construct the full path by prepending aufs_root as follows:</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>-                       if (opts.aufs &amp;&amp; (f = fixup_aufs_fd_path(vma_area-&gt;vm_file_fd))) {</div>
<div>-                               if (stat(f, st_buf) &lt; 0) {</div><div>+                       if (opts.aufs &amp;&amp; vma_area-&gt;aufs_rpath &amp;&amp; opts.aufs_root) {</div><div>+                               char path[PATH_MAX];</div>
<div>+                               int n;</div><div>+</div><div>+                               n = snprintf(path, PATH_MAX, &quot;%s/%s&quot;, opts.aufs_root, vma_area-&gt;aufs_rpath);</div><div>+                               if (n &gt;= PATH_MAX) {</div>
<div>+                                       pr_err(&quot;Path %s/%s too long\n&quot;, opts.aufs_root, vma_area-&gt;aufs_rpath);</div><div>+                                       goto err;</div><div>+                               }</div>
<div>+                               if (stat(path, st_buf) &lt; 0) {</div></blockquote><div><br></div><div>If you prefer this approach, I will send you a new patch with this change and removal of fixup_aufs_fd_path().</div>
<div><br></div>







<div>Cheers!</div><div><br></div><div>--Saied</div><div><br></div></div></div></div>