diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-12-25 03:19:19 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-12-25 03:19:19 +0100 |
commit | 10f9c75519671e7c7ab8993b54fe22da7c2d0c38 (patch) | |
tree | 78777a123c0261f892af164581884f8a07756203 /src/machine/image-dbus.c | |
parent | 5fa89b2cb366d533e56a9b7a9ce548480776f973 (diff) |
machined: beef up machined image listing with creation/modification times of subvolumes
We make use of the btrfs subvol crtime for this, and for gpt images of a
manually managed xattr, if we can.
Diffstat (limited to 'src/machine/image-dbus.c')
-rw-r--r-- | src/machine/image-dbus.c | 64 |
1 files changed, 60 insertions, 4 deletions
diff --git a/src/machine/image-dbus.c b/src/machine/image-dbus.c index afb849b41a..8d9ad5589e 100644 --- a/src/machine/image-dbus.c +++ b/src/machine/image-dbus.c @@ -159,12 +159,68 @@ static int property_get_read_only( return 1; } +static int property_get_crtime( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + + _cleanup_(image_unrefp) Image *image = NULL; + int r; + + assert(bus); + assert(reply); + + r = image_find_by_bus_path_with_error(path, &image, error); + if (r < 0) + return r; + + r = sd_bus_message_append(reply, "t", image->crtime); + if (r < 0) + return r; + + return 1; +} + +static int property_get_mtime( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + + _cleanup_(image_unrefp) Image *image = NULL; + int r; + + assert(bus); + assert(reply); + + r = image_find_by_bus_path_with_error(path, &image, error); + if (r < 0) + return r; + + r = sd_bus_message_append(reply, "t", image->mtime); + if (r < 0) + return r; + + return 1; +} + const sd_bus_vtable image_vtable[] = { SD_BUS_VTABLE_START(0), - SD_BUS_PROPERTY("Name", "s", property_get_name, 0, 0), - SD_BUS_PROPERTY("Path", "s", property_get_path, 0, 0), - SD_BUS_PROPERTY("Type", "s", property_get_type, 0, 0), - SD_BUS_PROPERTY("ReadOnly", "b", property_get_read_only, 0, 0), + SD_BUS_PROPERTY("Name", "s", property_get_name, 0, 0), + SD_BUS_PROPERTY("Path", "s", property_get_path, 0, 0), + SD_BUS_PROPERTY("Type", "s", property_get_type, 0, 0), + SD_BUS_PROPERTY("ReadOnly", "b", property_get_read_only, 0, 0), + SD_BUS_PROPERTY("CreationTimestamp", "t", property_get_crtime, 0, 0), + SD_BUS_PROPERTY("ModificationTimestamp", "t", property_get_mtime, 0, 0), SD_BUS_VTABLE_END }; |