<div dir="ltr">IIUC, ftruncate will fail with `EISDIR` if its input is a directory. And I don't know of any use-cases where we'd want or should be able to `dd` a directory. Unless I'm missing something, the S_ISDIR could be removed, since ftruncate ought to fail if a directory is given.<div><br></div><div>Thanks!<br><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>+Chris<br></div></div></div></div></div></div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 23, 2020 at 4:38 AM Rob Landley <<a href="mailto:rob@landley.net">rob@landley.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 9/15/20 12:10 PM, Chris Sarra via Toybox wrote:<br>
> - if (trunc && ftruncate(TT.out.fd, bs)) perror_exit("ftruncate");<br>
> + if (trunc && ftruncate(TT.out.fd, bs)) {<br>
> + struct stat st;<br>
> + if (fstat(TT.out.fd, &st) < 0 || S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)) {<br>
> + perror_exit("unexpected ftruncate failure");<br>
> + }<br>
> + }<br>
<br>
What does truncating a directory do? Is there a valid use case where dd's target<br>
can be a directory? (How would that work?)<br>
<br>
Rob<br>
</blockquote></div>