mirror of
https://github.com/systemd/systemd.git
synced 2024-11-06 08:26:52 +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:
parent
1c7dd82563
commit
c19de71113
@ -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("CreationTimestamp", "t", NULL, offsetof(Image, crtime), 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("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_METHOD("Remove", NULL, NULL, bus_image_method_remove, 0),
|
||||
SD_BUS_METHOD("Rename", "s", NULL, bus_image_method_rename, 0),
|
||||
|
@ -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) {
|
||||
|
||||
_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_free_ ImageInfo *images = NULL;
|
||||
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_type, "TYPE",
|
||||
"RO",
|
||||
(int) max_size, "SIZE",
|
||||
(int) max_size, "USAGE",
|
||||
(int) max_crtime, "CREATED",
|
||||
(int) max_mtime, "MODIFIED");
|
||||
|
||||
@ -741,9 +741,9 @@ typedef struct ImageStatusInfo {
|
||||
int read_only;
|
||||
usec_t crtime;
|
||||
usec_t mtime;
|
||||
uint64_t size;
|
||||
uint64_t usage;
|
||||
uint64_t limit;
|
||||
uint64_t size_exclusive;
|
||||
uint64_t usage_exclusive;
|
||||
uint64_t limit_exclusive;
|
||||
} ImageStatusInfo;
|
||||
|
||||
@ -786,12 +786,12 @@ static void print_image_status_info(sd_bus *bus, ImageStatusInfo *i) {
|
||||
else if (s2)
|
||||
printf("\tModified: %s\n", s2);
|
||||
|
||||
s3 = format_bytes(bs, sizeof(bs), i->size);
|
||||
s4 = i->size_exclusive != i->size ? format_bytes(bs_exclusive, sizeof(bs_exclusive), i->size_exclusive) : NULL;
|
||||
s3 = format_bytes(bs, sizeof(bs), i->usage);
|
||||
s4 = i->usage_exclusive != i->usage ? format_bytes(bs_exclusive, sizeof(bs_exclusive), i->usage_exclusive) : NULL;
|
||||
if (s3 && s4)
|
||||
printf("\t Size: %s (exclusive: %s)\n", s3, s4);
|
||||
printf("\t Usage: %s (exclusive: %s)\n", s3, s4);
|
||||
else if (s3)
|
||||
printf("\t Size: %s\n", s3);
|
||||
printf("\t Usage: %s\n", s3);
|
||||
|
||||
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;
|
||||
@ -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) },
|
||||
{ "CreationTimestamp", "t", NULL, offsetof(ImageStatusInfo, crtime) },
|
||||
{ "ModificationTimestamp", "t", NULL, offsetof(ImageStatusInfo, mtime) },
|
||||
{ "Size", "t", NULL, offsetof(ImageStatusInfo, size) },
|
||||
{ "Usage", "t", NULL, offsetof(ImageStatusInfo, usage) },
|
||||
{ "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) },
|
||||
{}
|
||||
};
|
||||
|
@ -504,7 +504,7 @@ static int method_list_images(sd_bus *bus, sd_bus_message *message, void *userda
|
||||
image->read_only,
|
||||
image->crtime,
|
||||
image->mtime,
|
||||
image->size,
|
||||
image->usage,
|
||||
p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -73,7 +73,7 @@ static int image_new(
|
||||
i->read_only = read_only;
|
||||
i->crtime = crtime;
|
||||
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->name = strdup(pretty);
|
||||
@ -164,8 +164,8 @@ static int image_make(
|
||||
|
||||
r = btrfs_subvol_get_quota_fd(fd, "a);
|
||||
if (r >= 0) {
|
||||
(*ret)->size = quota.referred;
|
||||
(*ret)->size_exclusive = quota.exclusive;
|
||||
(*ret)->usage = quota.referred;
|
||||
(*ret)->usage_exclusive = quota.exclusive;
|
||||
|
||||
(*ret)->limit = quota.referred_max;
|
||||
(*ret)->limit_exclusive = quota.exclusive_max;
|
||||
@ -218,7 +218,7 @@ static int image_make(
|
||||
if (r < 0)
|
||||
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;
|
||||
|
||||
return 1;
|
||||
|
@ -41,8 +41,8 @@ typedef struct Image {
|
||||
usec_t crtime;
|
||||
usec_t mtime;
|
||||
|
||||
uint64_t size;
|
||||
uint64_t size_exclusive;
|
||||
uint64_t usage;
|
||||
uint64_t usage_exclusive;
|
||||
uint64_t limit;
|
||||
uint64_t limit_exclusive;
|
||||
} Image;
|
||||
|
Loading…
Reference in New Issue
Block a user