chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
shared: add minimal firewall manipulation helpers for establishing NAT rules, using...
[elogind.git]
/
src
/
shared
/
machine-image.c
diff --git
a/src/shared/machine-image.c
b/src/shared/machine-image.c
index 36b64e1fab8fec9cf0f6db88157f78c1509cd52a..25689ca93cba91042ab0f9eec37520d7b7b54912 100644
(file)
--- a/
src/shared/machine-image.c
+++ b/
src/shared/machine-image.c
@@
-20,6
+20,7
@@
***/
#include <sys/statfs.h>
***/
#include <sys/statfs.h>
+#include <linux/fs.h>
#include <fcntl.h>
#include "strv.h"
#include <fcntl.h>
#include "strv.h"
@@
-440,7
+441,7
@@
int image_clone(Image *i, const char *new_name, bool read_only) {
case IMAGE_GPT:
new_path = strappenda("/var/lib/container/", new_name, ".gpt");
case IMAGE_GPT:
new_path = strappenda("/var/lib/container/", new_name, ".gpt");
- r = copy_file_atomic(i->path, new_path, read_only ? 0444 : 0644, false);
+ r = copy_file_atomic(i->path, new_path, read_only ? 0444 : 0644, false
, FS_NOCOW_FL
);
break;
default:
break;
default:
@@
-477,6
+478,12
@@
int image_read_only(Image *i, bool b) {
if (chmod(i->path, (st.st_mode & 0444) | (b ? 0000 : 0200)) < 0)
return -errno;
if (chmod(i->path, (st.st_mode & 0444) | (b ? 0000 : 0200)) < 0)
return -errno;
+
+ /* If the images is now read-only, it's a good time to
+ * defrag it, given that no write patterns will
+ * fragment it again. */
+ if (b)
+ (void) btrfs_defrag(i->path);
break;
}
break;
}