1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 16:59:03 +03:00

machined: refer to the disk space allocated for an image to "usage" rather than "size"

After all, it's closer to the "du"-reported value than to the file
sizes...
This commit is contained in:
Lennart Poettering 2015-01-19 17:01:15 +01:00
parent 1c7dd82563
commit c19de71113
5 changed files with 19 additions and 19 deletions

View File

@ -135,9 +135,9 @@ const sd_bus_vtable image_vtable[] = {
SD_BUS_PROPERTY("ReadOnly", "b", bus_property_get_bool, offsetof(Image, read_only), 0), SD_BUS_PROPERTY("ReadOnly", "b", bus_property_get_bool, offsetof(Image, read_only), 0),
SD_BUS_PROPERTY("CreationTimestamp", "t", NULL, offsetof(Image, crtime), 0), SD_BUS_PROPERTY("CreationTimestamp", "t", NULL, offsetof(Image, crtime), 0),
SD_BUS_PROPERTY("ModificationTimestamp", "t", NULL, offsetof(Image, mtime), 0), SD_BUS_PROPERTY("ModificationTimestamp", "t", NULL, offsetof(Image, mtime), 0),
SD_BUS_PROPERTY("Size", "t", NULL, offsetof(Image, size), 0), SD_BUS_PROPERTY("Usage", "t", NULL, offsetof(Image, usage), 0),
SD_BUS_PROPERTY("Limit", "t", NULL, offsetof(Image, limit), 0), SD_BUS_PROPERTY("Limit", "t", NULL, offsetof(Image, limit), 0),
SD_BUS_PROPERTY("SizeExclusive", "t", NULL, offsetof(Image, size_exclusive), 0), SD_BUS_PROPERTY("UsageExclusive", "t", NULL, offsetof(Image, usage_exclusive), 0),
SD_BUS_PROPERTY("LimitExclusive", "t", NULL, offsetof(Image, limit_exclusive), 0), SD_BUS_PROPERTY("LimitExclusive", "t", NULL, offsetof(Image, limit_exclusive), 0),
SD_BUS_METHOD("Remove", NULL, NULL, bus_image_method_remove, 0), SD_BUS_METHOD("Remove", NULL, NULL, bus_image_method_remove, 0),
SD_BUS_METHOD("Rename", "s", NULL, bus_image_method_rename, 0), SD_BUS_METHOD("Rename", "s", NULL, bus_image_method_rename, 0),

View File

@ -214,7 +214,7 @@ static int compare_image_info(const void *a, const void *b) {
static int list_images(int argc, char *argv[], void *userdata) { static int list_images(int argc, char *argv[], void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
size_t max_name = strlen("NAME"), max_type = strlen("TYPE"), max_size = strlen("SIZE"), max_crtime = strlen("CREATED"), max_mtime = strlen("MODIFIED"); size_t max_name = strlen("NAME"), max_type = strlen("TYPE"), max_size = strlen("USAGE"), max_crtime = strlen("CREATED"), max_mtime = strlen("MODIFIED");
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL; _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_free_ ImageInfo *images = NULL; _cleanup_free_ ImageInfo *images = NULL;
size_t n_images = 0, n_allocated = 0, j; size_t n_images = 0, n_allocated = 0, j;
@ -304,7 +304,7 @@ static int list_images(int argc, char *argv[], void *userdata) {
(int) max_name, "NAME", (int) max_name, "NAME",
(int) max_type, "TYPE", (int) max_type, "TYPE",
"RO", "RO",
(int) max_size, "SIZE", (int) max_size, "USAGE",
(int) max_crtime, "CREATED", (int) max_crtime, "CREATED",
(int) max_mtime, "MODIFIED"); (int) max_mtime, "MODIFIED");
@ -741,9 +741,9 @@ typedef struct ImageStatusInfo {
int read_only; int read_only;
usec_t crtime; usec_t crtime;
usec_t mtime; usec_t mtime;
uint64_t size; uint64_t usage;
uint64_t limit; uint64_t limit;
uint64_t size_exclusive; uint64_t usage_exclusive;
uint64_t limit_exclusive; uint64_t limit_exclusive;
} ImageStatusInfo; } ImageStatusInfo;
@ -786,12 +786,12 @@ static void print_image_status_info(sd_bus *bus, ImageStatusInfo *i) {
else if (s2) else if (s2)
printf("\tModified: %s\n", s2); printf("\tModified: %s\n", s2);
s3 = format_bytes(bs, sizeof(bs), i->size); s3 = format_bytes(bs, sizeof(bs), i->usage);
s4 = i->size_exclusive != i->size ? format_bytes(bs_exclusive, sizeof(bs_exclusive), i->size_exclusive) : NULL; s4 = i->usage_exclusive != i->usage ? format_bytes(bs_exclusive, sizeof(bs_exclusive), i->usage_exclusive) : NULL;
if (s3 && s4) if (s3 && s4)
printf("\t Size: %s (exclusive: %s)\n", s3, s4); printf("\t Usage: %s (exclusive: %s)\n", s3, s4);
else if (s3) else if (s3)
printf("\t Size: %s\n", s3); printf("\t Usage: %s\n", s3);
s3 = format_bytes(bs, sizeof(bs), i->limit); s3 = format_bytes(bs, sizeof(bs), i->limit);
s4 = i->limit_exclusive != i->limit ? format_bytes(bs_exclusive, sizeof(bs_exclusive), i->limit_exclusive) : NULL; s4 = i->limit_exclusive != i->limit ? format_bytes(bs_exclusive, sizeof(bs_exclusive), i->limit_exclusive) : NULL;
@ -810,9 +810,9 @@ static int show_image_info(const char *verb, sd_bus *bus, const char *path, bool
{ "ReadOnly", "b", NULL, offsetof(ImageStatusInfo, read_only) }, { "ReadOnly", "b", NULL, offsetof(ImageStatusInfo, read_only) },
{ "CreationTimestamp", "t", NULL, offsetof(ImageStatusInfo, crtime) }, { "CreationTimestamp", "t", NULL, offsetof(ImageStatusInfo, crtime) },
{ "ModificationTimestamp", "t", NULL, offsetof(ImageStatusInfo, mtime) }, { "ModificationTimestamp", "t", NULL, offsetof(ImageStatusInfo, mtime) },
{ "Size", "t", NULL, offsetof(ImageStatusInfo, size) }, { "Usage", "t", NULL, offsetof(ImageStatusInfo, usage) },
{ "Limit", "t", NULL, offsetof(ImageStatusInfo, limit) }, { "Limit", "t", NULL, offsetof(ImageStatusInfo, limit) },
{ "SizeExclusive", "t", NULL, offsetof(ImageStatusInfo, size_exclusive) }, { "UsageExclusive", "t", NULL, offsetof(ImageStatusInfo, usage_exclusive) },
{ "LimitExclusive", "t", NULL, offsetof(ImageStatusInfo, limit_exclusive) }, { "LimitExclusive", "t", NULL, offsetof(ImageStatusInfo, limit_exclusive) },
{} {}
}; };

View File

@ -504,7 +504,7 @@ static int method_list_images(sd_bus *bus, sd_bus_message *message, void *userda
image->read_only, image->read_only,
image->crtime, image->crtime,
image->mtime, image->mtime,
image->size, image->usage,
p); p);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -73,7 +73,7 @@ static int image_new(
i->read_only = read_only; i->read_only = read_only;
i->crtime = crtime; i->crtime = crtime;
i->mtime = mtime; i->mtime = mtime;
i->size = i->size_exclusive = (uint64_t) -1; i->usage = i->usage_exclusive = (uint64_t) -1;
i->limit = i->limit_exclusive = (uint64_t) -1; i->limit = i->limit_exclusive = (uint64_t) -1;
i->name = strdup(pretty); i->name = strdup(pretty);
@ -164,8 +164,8 @@ static int image_make(
r = btrfs_subvol_get_quota_fd(fd, &quota); r = btrfs_subvol_get_quota_fd(fd, &quota);
if (r >= 0) { if (r >= 0) {
(*ret)->size = quota.referred; (*ret)->usage = quota.referred;
(*ret)->size_exclusive = quota.exclusive; (*ret)->usage_exclusive = quota.exclusive;
(*ret)->limit = quota.referred_max; (*ret)->limit = quota.referred_max;
(*ret)->limit_exclusive = quota.exclusive_max; (*ret)->limit_exclusive = quota.exclusive_max;
@ -218,7 +218,7 @@ static int image_make(
if (r < 0) if (r < 0)
return r; return r;
(*ret)->size = (*ret)->size_exclusive = st.st_blocks * 512; (*ret)->usage = (*ret)->usage_exclusive = st.st_blocks * 512;
(*ret)->limit = (*ret)->limit_exclusive = st.st_size; (*ret)->limit = (*ret)->limit_exclusive = st.st_size;
return 1; return 1;

View File

@ -41,8 +41,8 @@ typedef struct Image {
usec_t crtime; usec_t crtime;
usec_t mtime; usec_t mtime;
uint64_t size; uint64_t usage;
uint64_t size_exclusive; uint64_t usage_exclusive;
uint64_t limit; uint64_t limit;
uint64_t limit_exclusive; uint64_t limit_exclusive;
} Image; } Image;