summaryrefslogtreecommitdiff
path: root/src/shared/copy.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-08 19:15:49 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-08 23:13:45 +0100
commitf2068bcce01db31cdc9422f44185f3b49c04d2ce (patch)
treefd5f6ddf9b0c36e9deb24252267d5ecce0cb2fe3 /src/shared/copy.c
parente45fc5e738b0b7700e8b4f3c4b25c58a49b44b27 (diff)
machined: when cloning a raw disk image, also set the NOCOW flag
Diffstat (limited to 'src/shared/copy.c')
-rw-r--r--src/shared/copy.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/shared/copy.c b/src/shared/copy.c
index 3df636704c..b681f6f109 100644
--- a/src/shared/copy.c
+++ b/src/shared/copy.c
@@ -359,7 +359,7 @@ int copy_file_fd(const char *from, int fdt, bool try_reflink) {
return r;
}
-int copy_file(const char *from, const char *to, int flags, mode_t mode) {
+int copy_file(const char *from, const char *to, int flags, mode_t mode, int chattr_flags) {
int fdt, r;
assert(from);
@@ -371,6 +371,9 @@ int copy_file(const char *from, const char *to, int flags, mode_t mode) {
return -errno;
}
+ if (chattr_flags != 0)
+ (void) chattr_fd(fdt, true, chattr_flags);
+
r = copy_file_fd(from, fdt, true);
if (r < 0) {
close(fdt);
@@ -386,7 +389,7 @@ int copy_file(const char *from, const char *to, int flags, mode_t mode) {
return 0;
}
-int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace) {
+int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace, int chattr_flags) {
_cleanup_free_ char *t;
int r;
@@ -397,7 +400,7 @@ int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace
if (r < 0)
return r;
- r = copy_file(from, t, O_NOFOLLOW|O_EXCL, mode);
+ r = copy_file(from, t, O_NOFOLLOW|O_EXCL, mode, chattr_flags);
if (r < 0)
return r;