mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-13 01:36:15 +02:00
Use posix_fallocate to create /nix/var/nix/db/reserved
This commit is contained in:
parent
ba63ec6f39
commit
2bc9c84327
1 changed files with 11 additions and 1 deletions
|
@ -289,7 +289,17 @@ LocalStore::LocalStore(bool reserveSpace)
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(reservedPath.c_str(), &st) == -1 ||
|
if (stat(reservedPath.c_str(), &st) == -1 ||
|
||||||
st.st_size != settings.reservedSize)
|
st.st_size != settings.reservedSize)
|
||||||
writeFile(reservedPath, string(settings.reservedSize, 'X'));
|
{
|
||||||
|
AutoCloseFD fd = open(reservedPath.c_str(), O_WRONLY | O_CREAT, 0600);
|
||||||
|
int res = -1;
|
||||||
|
#if HAVE_POSIX_FALLOCATE
|
||||||
|
res = posix_fallocate(fd, 0, settings.reservedSize);
|
||||||
|
#endif
|
||||||
|
if (res == -1) {
|
||||||
|
writeFull(fd, string(settings.reservedSize, 'X'));
|
||||||
|
ftruncate(fd, settings.reservedSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
deletePath(reservedPath);
|
deletePath(reservedPath);
|
||||||
|
|
Loading…
Reference in a new issue