chiark / gitweb /
fs-util: add new unlinkat_deallocate() helper
authorLennart Poettering <lennart@poettering.net>
Fri, 9 Feb 2018 08:50:31 +0000 (09:50 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:54:01 +0000 (07:54 +0200)
commitaa3cde5d453e3dd0f259827f7f02874d7260047e
tree1d46ce4596613bcae2a3a7a0cf5a5484a8e7ade8
parent743ac495b83a83e7336f55321d38a4ebe7389e58
fs-util: add new unlinkat_deallocate() helper

This new helper not only removes a file from a directory but also
ensures its space on disk is deallocated, by either punching a hole over
the full file or truncating the file afterwards if the file's link
counter is 0. This is useful in "vacuuming" algorithms to ensure that
client's can't keep the disk space the vacuuming is supposed to recover
pinned simply by keeping an fd open to it.

(cherry picked from commit 43767d9d5e0ce8923828aebf9154da7af83916f7)
src/basic/fs-util.c
src/basic/fs-util.h
src/basic/missing.h
src/test/test-fs-util.c