<br><br><div class="gmail_quote">On Feb 5, 2008 11:49 PM, Rob Landley &lt;<a href="mailto:rob@landley.net">rob@landley.net</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Tuesday 05 February 2008 10:13:13 Jacques Verryn wrote:<br>&gt; The crux of the problem is if I scp a file from my desktop linux pc to the<br>&gt; gumstix, the resulting file on the gumstix has zero file length.<br>
&gt; The common denominator in the above posts and in my case, is uclibc.<br>&gt; I upgraded from dropbear 0.48.1 to 0.50 due the the scp hang error that was<br>&gt; fixed be extensive reworking of the common-channel.c code.<br>
&gt; I&#39;m working on a production level project and can unfortunately not trade<br>&gt; scp functionality versus the occasional session hang.<br>&gt;<br>&gt; Any ideas???<br><br></div>Run &quot;./dropbear -F -E&quot; under strace, and then do your scp to it with stderr<br>
captured to a log file. &nbsp;(Via serial console if necessary.)<br><br>At a guess, some call to libc is returning an error that aborts the write.<br>Figure out _where_ the write stops, and you&#39;re halfway to figuring out why.<br>
<br>Rob<br><font color="#888888">--<br>&quot;One of my most productive days was throwing away 1000 lines of code.&quot;<br> &nbsp;- Ken Thompson.<br><br><br></font></blockquote></div><br>I ran strace -fF dropbear -F. I then scp&#39;d a file(small.txt) containing &#39;hello world\n&#39; and saw the following<br>
<br>&lt;--- trace snip -----&gt;<br>[pid&nbsp; 6696] stat64(&quot;./small.txt&quot;, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0<br>[pid&nbsp; 6696] open(&quot;./small.txt&quot;, O_WRONLY|O_CREAT|O_LARGEFILE, 0644) = 3<br>[pid&nbsp; 6696] write(1, &quot;\0&quot;, 1 &lt;unfinished ...&gt;<br>
[pid&nbsp; 6694] &lt;... select resumed&gt; )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 1 (in [10], left {299, 640000})<br>[pid&nbsp; 6696] &lt;... write resumed&gt; )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 1<br>[pid&nbsp; 6694] gettimeofday( &lt;unfinished ...&gt;<br>[pid&nbsp; 6696] read(0,&nbsp; &lt;unfinished ...&gt;<br>
[pid&nbsp; 6694] &lt;... gettimeofday resumed&gt; {4920, 971917}, NULL) = 0<br>[pid&nbsp; 6694] read(10, &quot;\0&quot;, 16375)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 1<br>[pid&nbsp; 6694] select(13, [4 6 10 12], [6], NULL, {300, 0}) = 1 (out [6], left {300, 0})<br>[pid&nbsp; 6694] gettimeofday({4920, 978769}, NULL) = 0<br>
[pid&nbsp; 6694] write(6, &quot;s\266?\251(\210b\337\376\247\207D\203p\354\37\201\315i&quot;..., 48) = 48<br>[pid&nbsp; 6694] gettimeofday({4920, 983486}, NULL) = 0<br>[pid&nbsp; 6694] select(13, [4 6 10 12], [], NULL, {300, 0}) = 1 (in [6], left {300, 0})<br>
[pid&nbsp; 6694] gettimeofday({4920, 988049}, NULL) = 0<br>[pid&nbsp; 6694] read(6, &quot;s\273\227(D\r(\243\251\276\215\32~\233\226\306&quot;, 16) = 16<br>[pid&nbsp; 6694] read(6, &quot;\312\333!d\3324\32\324\356\347\262\365A/k\301\32\205\371&quot;..., 32) = 32<br>
[pid&nbsp; 6694] select(13, [4 6 10 12], [9], NULL, {300, 0}) = 2 (in [6], out [9], left {300, 0})<br>[pid&nbsp; 6694] gettimeofday({4920, 996866}, NULL) = 0<br>[pid&nbsp; 6694] read(6, &quot;\373r\306\275\16\272\360d\16$j\336|\34V\266&quot;, 16) = 16<br>
[pid&nbsp; 6694] read(6, &quot;\241y\256\0252N\226\365\&#39;z79\270=\30E\253h\260.\267\2\261&quot;..., 32) = 32<br>[pid&nbsp; 6694] write(9, &quot;hello world\n\0&quot;, 13) = 13<br>[pid&nbsp; 6694] select(13, [4 6 10 12], [], NULL, {300, 0} &lt;unfinished ...&gt;<br>
[pid&nbsp; 6696] &lt;... read resumed&gt; &quot;hello world\n&quot;, 12) = 12<br>[pid&nbsp; 6696] write(3, &quot;hello world\n&quot;, 12) = 12<br>[pid&nbsp; 6696] ftruncate64(3, 51539607552) = 0<br>[pid&nbsp; 6696] close(3)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0<br>
[pid&nbsp; 6696] read(0, &quot;\0&quot;, 1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 1<br>[pid&nbsp; 6696] write(1, &quot;\0&quot;, 1 &lt;unfinished ...&gt;<br>&lt;/---trace snip ----&gt;<br><br>The size parameter of the ftruncate64 call is WAY wrong!<br>Doing the same with dropbear 0.48.1 yields the following trace<br>
<br>&lt;--- trace snip -----&gt;<br>[pid&nbsp; 6710] write(7, &quot;hello world\n\0&quot;, 13) = 13<br>[pid&nbsp; 6710] select(11, [6 8 10], [], NULL, {20, 0} &lt;unfinished ...&gt;<br>[pid&nbsp; 6712] &lt;... read resumed&gt; &quot;hello world\n&quot;, 12) = 12<br>
[pid&nbsp; 6712] write(3, &quot;hello world\n&quot;, 12) = 12<br>[pid&nbsp; 6712] ftruncate(3, 12)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0<br>[pid&nbsp; 6712] close(3)<br>&lt;/--- trace snip -----&gt;<br><br>My first observation is that 0.48 use ftruncate instead ftruncate64 and secondly the size parameter is correct.<br>
The code in scp.c line(1032-1041) that is involved with the write and then ftruncate is:<br>&lt;code&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (count != 0 &amp;&amp; wrerr == NO &amp;&amp;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; atomicio(vwrite, ofd, bp-&gt;buf, count) != count) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wrerr = YES;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wrerrno = errno;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (wrerr == NO &amp;&amp; ftruncate(ofd, size) != 0) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; run_err(&quot;%s: truncate: %s&quot;, np, strerror(errno));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; wrerr = DISPLAYED;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&lt;/code&gt;<br>This code has not change in a while. I also verified the &#39;size&#39; has the correct value just before the ftruncate.<br><br>I&#39;m starting to suspect a compiler flag / package config issue.<br>
<br>I&#39;m going to fiddle a bit more, but this is what I have at the moment.<br><br><br><br>