summaryrefslogtreecommitdiffstats
path: root/src/json.h
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-09-24 13:38:34 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-09-25 12:09:32 +0200
commitc7bfc370ae8974302cf1e316b3e03d0e6e960e0c (patch)
treeba6c9570f07cf6b76048405c8b6bb8ea3eb90e6a /src/json.h
parentb74a05cf38c2677029d14d6cc47be20689a09012 (diff)
src: add used_size and free_size to partition data
Extend database table ordenadores_particiones to add new "used_size" and "free_size" fields. FIELD TYPE | tamano | bigint | | uso | tinyint | | used_size | bigint | | free_size | bigint | "tamano" is the field storing the total size of the partition. "uso" is a field storing the integer percentage of use, it is preserved for backwards compatibility with scritps that access the database. "used_size" and "free_size" contain the used and free partition size in bytes. Old response from ogClient for /cache/delete, /cache/fetch and /image/restore: { 'cache': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'} ] } New response: { 'cache': { 'used_size': 4520232322423, 'free_size': 48273465287452945, 'images': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'} ] } } Parse the new "free_size" and "used_size" fields of each partition data in the response payload of /refresh Parse "free_size" and "used_size" fields of the cache data in the reponse payload of /image/restore, /cache/delete and /cache/fetch Replace "used_size" field of GET /client/setup with the value of the new database field "used_size"
Diffstat (limited to 'src/json.h')
-rw-r--r--src/json.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/json.h b/src/json.h
index e43531e..ff5c8ad 100644
--- a/src/json.h
+++ b/src/json.h
@@ -22,6 +22,7 @@ int og_json_parse_bool(const json_t *element, bool *value);
#define OG_PARAM_PART_OS (1UL << 6)
#define OG_PARAM_PART_USED_SIZE (1UL << 7)
#define OG_PARAM_PART_DISK_TYPE (1UL << 8)
+#define OG_PARAM_PART_FREE_SIZE (1UL << 9)
struct og_partition {
const char *disk;
@@ -32,7 +33,9 @@ struct og_partition {
const char *filesystem;
const char *format;
const char *os;
- const char *used_size;
+ uint64_t used_size;
+ uint64_t free_size;
+
};
#define OG_DISK_MAX 4
@@ -128,8 +131,17 @@ struct og_cache_image {
struct list_head list;
};
+#define OG_PARAM_CACHE_USED_SIZE (1UL << 0)
+#define OG_PARAM_CACHE_FREE_SIZE (1UL << 1)
+#define OG_PARAM_CACHE_IMAGES (1UL << 2)
+
+struct og_cache_data {
+ uint64_t used_size;
+ uint64_t free_size;
+};
+
void og_cache_image_free(struct list_head *cache_list);
-int og_json_parse_cache(json_t *element, struct list_head *cache_list);
+int og_json_parse_cache(json_t *element, struct og_cache_data *cache_data, struct list_head *cache_list);
#define OG_PARAM_EFI_ENTRIES (1UL << 0)