util-lib: when copying files make sure to apply some chattrs early, some late
Some chattrs only work sensible if you set them right after opening a file for create (think: FS_NOCOW_FL). Others only work when they are applied when the file is fully written (think: FS_IMMUTABLE_FL). Let's take that into account when copying files and applying a chattr to them.
This commit is contained in:
@@ -1,6 +1,20 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include "missing_fs.h"
|
||||
|
||||
/* The chattr() flags to apply when creating a new file *before* writing to it. In particular, flags such as
|
||||
* FS_NOCOW_FL don't work if applied a-posteriori. All other flags are fine (or even necessary, think
|
||||
* FS_IMMUTABLE_FL!) to apply after writing to the files. */
|
||||
#define CHATTR_EARLY_FL \
|
||||
(FS_NOATIME_FL | \
|
||||
FS_COMPR_FL | \
|
||||
FS_NOCOW_FL | \
|
||||
FS_NOCOMP_FL | \
|
||||
FS_PROJINHERIT_FL)
|
||||
|
||||
int chattr_fd(int fd, unsigned value, unsigned mask, unsigned *previous);
|
||||
int chattr_path(const char *p, unsigned value, unsigned mask, unsigned *previous);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user