[PATCH] D39464: Define fs::allocate_file which preallocates disk blocks.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 01:55:38 PST 2017


ruiu added inline comments.


================
Comment at: llvm/lib/Support/Unix/Path.inc:436
       return std::error_code(Err, std::generic_category());
+    return make_error_code(errc::function_not_supported);
   }
----------------
krytarowski wrote:
> ruiu wrote:
> > krytarowski wrote:
> > > NetBSD needs `ftruncate`(2) as a fallback for `posix_fallocate`(2).
> > > 
> > > In the default setup `posix_fallocate`() returns EOPNOTSUPP.
> > The current code use ftruncate if the function is available. So it doesn't use it as a fallback, but it uses only fallocate. It seems like a OK behavior to me on NetBSD if posix_fallocate always returns EOPNOTSUPP, but can you confirm?
> By "the current code" I understand the pristine one. It calls posix_fallocate(2) and if it fails with EOPNOTSUPP, it moves on to the ftruncate(2) fallback.
> 
> As far as I can tell, this fallocate is a missing feature as of today in the FFSv2 file-system, the default one on NetBSD.
Ah, sorry, I misread ftruncate fallocate.

I intentionally do not fallback to ftruncate in this function. This function's contract is to allocate actual disk blocks to a given file or return with a failure code. On the caller side, if this function returns an error, we use an in-memory buffer instead of an on-disk temporary file.


https://reviews.llvm.org/D39464





More information about the llvm-commits mailing list