summaryrefslogtreecommitdiff
path: root/src/shared/machine-image.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-12-28 02:05:28 +0100
committerLennart Poettering <lennart@poettering.net>2014-12-28 02:08:40 +0100
commitb6b1849830f5e4a6065c3b0c993668e500c954d3 (patch)
tree6c7a086974d703a0e15535bf341ce66dac03b388 /src/shared/machine-image.c
parent814f000872fc2d254250831607bdca9b27e5705e (diff)
machined: add support for reporting image size via btrfs quota
Diffstat (limited to 'src/shared/machine-image.c')
-rw-r--r--src/shared/machine-image.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c
index 7c041fab76..36b64e1fab 100644
--- a/src/shared/machine-image.c
+++ b/src/shared/machine-image.c
@@ -71,6 +71,8 @@ static int image_new(
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)
@@ -138,6 +140,7 @@ static int image_make(
if (F_TYPE_EQUAL(sfs.f_type, BTRFS_SUPER_MAGIC)) {
BtrfsSubvolInfo info;
+ BtrfsQuotaInfo quota;
/* It's a btrfs subvolume */
@@ -156,6 +159,15 @@ static int image_make(
if (r < 0)
return r;
+ r = btrfs_subvol_get_quota_fd(fd, &quota);
+ 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;
}
}
@@ -199,6 +211,9 @@ static int image_make(
if (r < 0)
return r;
+ (*ret)->size = (*ret)->size_exclusive = st.st_blocks * 512;
+ (*ret)->limit = (*ret)->limit_exclusive = st.st_size;
+
return 1;
}