[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-frameworks-devel
Subject:    D17816: Support for xattrs on kio copy/move
From:       Gleb Popov <noreply () phabricator ! kde ! org>
Date:       2021-03-02 11:58:59
Message-ID: 184531e27611f93c29540cfdf5abe913 () localhost ! localdomain
[Download RAW message or body]

[Attachment #2 (text/plain)]

arrowd added a comment.


  In D17816#677446 <https://phabricator.kde.org/D17816#677446>, @kdudka \
wrote:  
  > I was wondering why copying files in Krusader or Dolphin from a \
vfat-formatted memory card stopped working for me after update.  After \
copying the first file, the transfer stopped progressing and the process \
ended up consuming 100% CPU forever.  Later I discovered that the cause of \
the breakage was this patch: If fgetxattr() fails with ENOTSUP, the code \
loops indefinitely calling fgetxattr().  >
  > The following hotfix made copying of files in Krusader work again for \
me:  >  ...
  >
  > However, the code might need bigger changes to cover all the cases.  I \
do not fully understand the (IMO over-complicated) loops around \
flistxattr() and fgetxattr().  Note that the fact that one of them uses \
`while (true) { ... }` whereas the other one uses `do { ... } while (true)` \
does not improve code readability either.  
  
  I think, the correct fix is something like
  
    diff --git a/src/ioslaves/file/file_unix.cpp \
b/src/ioslaves/file/file_unix.cpp  index 74767123..4bc87c57 100644
    --- a/src/ioslaves/file/file_unix.cpp
    +++ b/src/ioslaves/file/file_unix.cpp
    @@ -614,8 +614,8 @@ bool FileProtocol::copyXattrs(const int src_fd, \
const int dest_fd)  valuelen = 0;
                     continue;
                 }
    -            // happens when attr value is an empty string
    -            if (valuelen == 0) {
    +            // valuelen=0 happens when attr value is an empty string
    +            if (valuelen == 0 || valuelen == -1) {
                     break;
                 }
             } while (true);
  
  Can you check if this works for you too?

REVISION DETAIL
  https://phabricator.kde.org/D17816

To: arrowd, dfaure, chinmoyr, bruns, #frameworks, tmarshall, usta, cochise
Cc: kdudka, usta, scheirle, tmarshall, arrowd, cfeck, bruns, phidrho, \
dhaumann, funkybomber, abika, pino, davidedmundson, ngraham, atha.kane, \
spoorun, nicolasfella, kde-frameworks-devel, LeGast00n, cblack, michaelh


[Attachment #3 (text/html)]

<table><tr><td style="">arrowd added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; \
float: right; color: #464C5C; font-weight: bold; border-radius: 3px; \
background-color: #F7F7F9; background-image: linear-gradient(to \
bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid \
rgba(71,87,120,.2);" href="https://phabricator.kde.org/D17816">View \
Revision</a></tr></table><br /><div><div><blockquote style="border-left: \
3px solid #8C98B8;  color: #6B748C;
          font-style: italic;
          margin: 4px 0 12px 0;
          padding: 8px 12px;
          background-color: #F8F9FC;">
<div style="font-style: normal;
          padding-bottom: 4px;">In <a \
href="https://phabricator.kde.org/D17816#677446" style="background-color: \
#e7e7e7;  border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">D17816#677446</a>, <a \
href="https://phabricator.kde.org/p/kdudka/" style="  border-color: \
#f1f7ff;  color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;">@kdudka</a> wrote:</div>
<div style="margin: 0;
          padding: 0;
          border: 0;
          color: rgb(107, 116, 140);"><p>I was wondering why copying files \
in Krusader or Dolphin from a vfat-formatted memory card stopped working \
for me after update.  After copying the first file, the transfer stopped \
progressing and the process ended up consuming 100% CPU forever.  Later I \
discovered that the cause of the breakage was this patch: If fgetxattr() \
fails with ENOTSUP, the code loops indefinitely calling fgetxattr().</p>

<p>The following hotfix made copying of files in Krusader work again for \
                me:<br />
 ...</p>

<p>However, the code might need bigger changes to cover all the cases.  I \
do not fully understand the (IMO over-complicated) loops around \
flistxattr() and fgetxattr().  Note that the fact that one of them uses <tt \
style="background: #ebebeb; font-size: 13px;">while (true) { ... }</tt> \
whereas the other one uses <tt style="background: #ebebeb; font-size: \
13px;">do { ... } while (true)</tt> does not improve code readability \
either.</p></div> </blockquote>

<p>I think, the correct fix is something like</p>

<div class="remarkup-code-block" style="margin: 12px 0;" \
data-code-lang="diff" data-sigil="remarkup-code-block"><pre \
class="remarkup-code" style="font: 11px/15px &quot;Menlo&quot;, \
&quot;Consolas&quot;, &quot;Monaco&quot;, monospace; padding: 12px; margin: \
0; background: rgba(71, 87, 120, 0.08);"><span style="color: #000080">diff \
--git a/src/ioslaves/file/file_unix.cpp \
b/src/ioslaves/file/file_unix.cpp</span> <span style="color: #000080">index \
74767123..4bc87c57 100644</span> <span style="color: #a00000">--- \
a/src/ioslaves/file/file_unix.cpp</span> <span style="color: #00a000">+++ \
b/src/ioslaves/file/file_unix.cpp</span> <span style="color: #800080">@@ \
-614,8 +614,8 @@ bool FileProtocol::copyXattrs(const int src_fd, const int \
dest_fd)</span>  valuelen = 0;
                 continue;
             }
<span style="color: #a00000">-            // happens when attr value is an \
empty string</span> <span style="color: #a00000">-            if (valuelen \
== 0) {</span> <span style="color: #00a000">+            // valuelen=0 \
happens when attr value is an empty string</span> <span style="color: \
#00a000">+            if (valuelen == 0 || valuelen == -1) {</span>  break;
             }
         } while (true);</pre></div>

<p>Can you check if this works for you too?</p></div></div><br \
/><div><strong>REVISION DETAIL</strong><div><a \
href="https://phabricator.kde.org/D17816">https://phabricator.kde.org/D17816</a></div></div><br \
/><div><strong>To: </strong>arrowd, dfaure, chinmoyr, bruns, Frameworks, \
tmarshall, usta, cochise<br /><strong>Cc: </strong>kdudka, usta, scheirle, \
tmarshall, arrowd, cfeck, bruns, phidrho, dhaumann, funkybomber, abika, \
pino, davidedmundson, ngraham, atha.kane, spoorun, nicolasfella, \
kde-frameworks-devel, LeGast00n, cblack, michaelh<br /></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic