mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 14:36:16 +02:00
libutil/archive: add preallocate-contents option
Make archive preallocation (fallocate) optional because some filesystems like btrfs do not behave as expected with fallocate. See #3550.
This commit is contained in:
parent
9c95a8bebf
commit
2548347bba
1 changed files with 5 additions and 0 deletions
|
@ -27,6 +27,8 @@ struct ArchiveSettings : Config
|
||||||
#endif
|
#endif
|
||||||
"use-case-hack",
|
"use-case-hack",
|
||||||
"Whether to enable a Darwin-specific hack for dealing with file name collisions."};
|
"Whether to enable a Darwin-specific hack for dealing with file name collisions."};
|
||||||
|
Setting<bool> preallocateContents{this, true, "preallocate-contents",
|
||||||
|
"Whether to preallocate files when writing objects with known size."};
|
||||||
};
|
};
|
||||||
|
|
||||||
static ArchiveSettings archiveSettings;
|
static ArchiveSettings archiveSettings;
|
||||||
|
@ -325,6 +327,9 @@ struct RestoreSink : ParseSink
|
||||||
|
|
||||||
void preallocateContents(uint64_t len)
|
void preallocateContents(uint64_t len)
|
||||||
{
|
{
|
||||||
|
if (!archiveSettings.preallocateContents)
|
||||||
|
return;
|
||||||
|
|
||||||
#if HAVE_POSIX_FALLOCATE
|
#if HAVE_POSIX_FALLOCATE
|
||||||
if (len) {
|
if (len) {
|
||||||
errno = posix_fallocate(fd.get(), 0, len);
|
errno = posix_fallocate(fd.get(), 0, len);
|
||||||
|
|
Loading…
Reference in a new issue