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.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <linux/audit.h>
|
||||
#include <linux/capability.h>
|
||||
#include <linux/falloc.h>
|
||||
#include <linux/if_link.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/loop.h>
|
||||
@@ -1359,4 +1360,12 @@ struct fib_rule_uid_range {
|
||||
#define NS_GET_NSTYPE _IO(0xb7, 0x3)
|
||||
#endif
|
||||
|
||||
#ifndef FALLOC_FL_KEEP_SIZE
|
||||
#define FALLOC_FL_KEEP_SIZE 0x01
|
||||
#endif
|
||||
|
||||
#ifndef FALLOC_FL_PUNCH_HOLE
|
||||
#define FALLOC_FL_PUNCH_HOLE 0x02
|
||||
#endif
|
||||
|
||||
#include "missing_syscall.h"
|
||||
|
||||
Reference in New Issue
Block a user