The fallback ftruncate() call was wrong, because posix_fallocate() will never shrink a file, but ftruncate() will. Also, if that failed, we didn't turn errno into a return code.
Also the fcntl() was wrong. In my defense, here's the documentation: The position modes (fst_posmode) for the F_PREALLOCATE command indicate how to use the offset field. The modes are as follows: F_PEOFPOSMODE Allocate from the physical end of file. In this case, fst_length indicates the number of newly allocated bytes desired. F_VOLPOSMODE Allocate from the volume offset. I think the new version is right, though it's obviously a lot more conservative than the real posix_fallocate(), but I don't think it's possible to do better? Also add tests for some of the prior failures. Fixes #472. --- lib/portability.c | 11 ++++++----- tests/fallocate.test | 8 ++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100755 tests/fallocate.test
0001-Fix-macOS-posix_fallocate.patch
Description: Binary data
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net