diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2020-11-17 16:44:34 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2020-11-18 13:10:34 +0100 |
commit | 24e6fbf1dee7ff21913a4bef8ae0ae4ed2245fc8 (patch) | |
tree | 0be596f15b5aa130ce89236d7b684dac72954238 /src/client.c | |
parent | 727f31a88b9b4daf50a28997b51f9097605e92c9 (diff) |
#1008 Restore support for 4 disks and 16 partitions
ogServer expects to receive information of 1 disk and 4 partitions
from ogClient. Previous ogServer versions support several disks and
partitions.
Add ogServer support for 4 disks and 16 partitions.
Diffstat (limited to 'src/client.c')
-rw-r--r-- | src/client.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/client.c b/src/client.c index ebac662..9b2120f 100644 --- a/src/client.c +++ b/src/client.c @@ -284,10 +284,10 @@ static int og_dbi_queue_autorun(uint32_t computer_id, uint32_t proc_id) static int og_resp_refresh(json_t *data, struct og_client *cli) { struct og_partition partitions[OG_PARTITION_MAX] = {}; + struct og_partition disks[OG_DISK_MAX] = {}; const char *serial_number = NULL; struct og_computer computer = {}; - struct og_partition disk_setup; - char cfg[1024] = {}; + char cfg[4096] = {}; struct og_dbi *dbi; const char *key; unsigned int i; @@ -300,9 +300,7 @@ static int og_resp_refresh(json_t *data, struct og_client *cli) json_object_foreach(data, key, value) { if (!strcmp(key, "disk_setup")) { - err = og_json_parse_partition(value, - &disk_setup, - OG_PARAMS_RESP_REFRESH); + err = og_json_parse_partition_array(value, disks); } else if (!strcmp(key, "partition_setup")) { err = og_json_parse_partition_array(value, partitions); } else if (!strcmp(key, "serial_number")) { @@ -318,16 +316,20 @@ static int og_resp_refresh(json_t *data, struct og_client *cli) if (strlen(serial_number) > 0) snprintf(cfg, sizeof(cfg), "ser=%s\n", serial_number); - if (!disk_setup.disk || !disk_setup.number || !disk_setup.code || - !disk_setup.filesystem || !disk_setup.os || !disk_setup.size || - !disk_setup.used_size) - return -1; + for (i = 0; i < OG_DISK_MAX; i++) { + if (!disks[i].disk || !disks[i].number || + !disks[i].code || !disks[i].filesystem || + !disks[i].os || !disks[i].size || + !disks[i].used_size) + continue; - snprintf(cfg + strlen(cfg), sizeof(cfg) - strlen(cfg), - "disk=%s\tpar=%s\tcpt=%s\tfsi=%s\tsoi=%s\ttam=%s\tuso=%s\n", - disk_setup.disk, disk_setup.number, disk_setup.code, - disk_setup.filesystem, disk_setup.os, disk_setup.size, - disk_setup.used_size); + snprintf(cfg + strlen(cfg), sizeof(cfg) - strlen(cfg), + "disk=%s\tpar=%s\tcpt=%s\tfsi=%s\tsoi=%s\ttam=%s\tuso=%s\n", + disks[i].disk, disks[i].number, + disks[i].code, disks[i].filesystem, + disks[i].os, disks[i].size, + disks[i].used_size); + } for (i = 0; i < OG_PARTITION_MAX; i++) { if (!partitions[i].disk || !partitions[i].number || |