chiark / gitweb /
machined: add support for reporting image size via btrfs quota
[elogind.git] / src / test / test-btrfs.c
index 43b445d8312a3e7249cffeae3b9af8c84535040a..150a32ad6fff076dae5b5b34055204d3495ff02d 100644 (file)
@@ -36,7 +36,8 @@ int main(int argc, char *argv[]) {
                 log_error_errno(errno, "Failed to open root directory: %m");
         else {
                 BtrfsSubvolInfo info;
-                char ts[FORMAT_TIMESTAMP_MAX];
+                BtrfsQuotaInfo quota;
+                char ts[FORMAT_TIMESTAMP_MAX], bs[FORMAT_BYTES_MAX];
 
                 r = btrfs_subvol_get_info_fd(fd, &info);
                 if (r < 0)
@@ -46,6 +47,16 @@ int main(int argc, char *argv[]) {
                         log_info("read-only (search): %s", yes_no(info.read_only));
                 }
 
+                r = btrfs_subvol_get_quota_fd(fd, &quota);
+                if (r < 0)
+                        log_error_errno(r, "Failed to get quota info: %m");
+                else {
+                        log_info("referred: %s", strna(format_bytes(bs, sizeof(bs), quota.referred)));
+                        log_info("exclusive: %s", strna(format_bytes(bs, sizeof(bs), quota.exclusive)));
+                        log_info("referred_max: %s", strna(format_bytes(bs, sizeof(bs), quota.referred_max)));
+                        log_info("exclusive_max: %s", strna(format_bytes(bs, sizeof(bs), quota.exclusive_max)));
+                }
+
                 r = btrfs_subvol_get_read_only_fd(fd);
                 if (r < 0)
                         log_error_errno(r, "Failed to get read only flag: %m");