<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 14, 2017 at 4:42 AM, Mark Kettenis <span dir="ltr"><<a href="mailto:mark.kettenis@xs4all.nl" target="_blank">mark.kettenis@xs4all.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> From: Rafael Avila de Espindola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>><br>
> Date: Mon, 13 Nov 2017 10:21:13 -0800<br>
<span class="">><br>
> Kamil Rytarowski <<a href="mailto:n54@gmx.com">n54@gmx.com</a>> writes:<br>
><br>
> > On 13.11.2017 18:19, Rafael Avila de Espindola wrote:<br>
> >> Kamil Rytarowski via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> writes:<br>
> >><br>
> >>> krytarowski added inline comments.<br>
> >>><br>
> >>><br>
> >>> ================<br>
> >>> Comment at: llvm/lib/Support/Unix/Path.<wbr>inc:436<br>
> >>>        return std::error_code(Err, std::generic_category());<br>
> >>> +    return make_error_code(errc::<wbr>function_not_supported);<br>
> >>>    }<br>
> >>> ----------------<br>
> >>> NetBSD needs `ftruncate`(2) as a fallback for `posix_fallocate`(2).<br>
> >>><br>
> >>> In the default setup `posix_fallocate`() returns EOPNOTSUPP.<br>
> >><br>
> >> Will ftruncate allocate space on netbsd? Note that it is OK for<br>
> >> allocate_file to fail. The user then has to use a buffer and write(2)<br>
> >> instead of mmap for output.<br>
> >><br>
> >> Cheers,<br>
> >> Rafael<br>
> >><br>
> ><br>
> > ftruncate(2)/NetBSD as an extension extends area and makes it<br>
> > zero-filled. It's equivalent to lseek(2) + write(2).<br>
><br>
> Cool, so an mmap of the file after a ftruncate will never crash because<br>
> of disk full, correct?<br>
<br>
</span>I seriously doubt ftruncate(2) behaves differently on NetBSD.  There<br>
is nothing in the man page that suggests this, and users would<br>
probably scream if creating sparse files was broken.<br>
<span class=""><br>
> If so we could use use ftruncate on netbsd as a special case, similar to<br>
> the special case we have for OS X.<br>
<br>
</span>I still think OS-specific code should be avoided when a reasonable<br>
portable alternative exists.  Maybe OS X is important enough that a<br>
performance regressions in unacceptable.  But the Linux-specific code<br>
provides no benefit over the posix_fallocate(2) code for the vast<br>
majority of use cases where output files will be created on<br>
filesystems that support fallocate(2).<br>
</blockquote></div><br></div><div class="gmail_extra">Essentially I'd agree with you, but I believe this small Linux specific code is still worth adding. I once accidentally created a ext2 filesystem (instead of ext4), and even though it could be mounted as ext4, the filesystem didn't support fallocate(2). I could also imagine that an output directory is on fuse.</div></div>