***/
#include <sys/statfs.h>
+#include <linux/fs.h>
#include <fcntl.h>
#include "strv.h"
i->read_only = read_only;
i->crtime = crtime;
i->mtime = mtime;
+ i->size = i->size_exclusive = (uint64_t) -1;
+ i->limit = i->limit_exclusive = (uint64_t) -1;
i->name = strdup(pretty);
if (!i->name)
if (F_TYPE_EQUAL(sfs.f_type, BTRFS_SUPER_MAGIC)) {
BtrfsSubvolInfo info;
+ BtrfsQuotaInfo quota;
/* It's a btrfs subvolume */
if (r < 0)
return r;
+ r = btrfs_subvol_get_quota_fd(fd, "a);
+ if (r >= 0) {
+ (*ret)->size = quota.referred;
+ (*ret)->size_exclusive = quota.exclusive;
+
+ (*ret)->limit = quota.referred_max;
+ (*ret)->limit_exclusive = quota.exclusive_max;
+ }
+
return 1;
}
}
if (r < 0)
return r;
+ (*ret)->size = (*ret)->size_exclusive = st.st_blocks * 512;
+ (*ret)->limit = (*ret)->limit_exclusive = st.st_size;
+
return 1;
}
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:
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;
}