diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2021-02-08 09:41:51 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2021-02-08 22:38:25 +0100 |
commit | 6a7a846e6e075628a8b4afbe3cd0df8a570a0126 (patch) | |
tree | 35dad09a59ba533f67feb4d130e83ba1ed4d8d5b | |
parent | 0e4857a5389dfe919b18cb872f0b1d0948b4df52 (diff) |
#1019 Fix setup legacy string parser
UMA reports that the setup command (in queue mode) does not work.
WebConsole stores queued commands in the database using the deprecated
SocketHidra legacy string format and ogServer parses them with sscanf().
The setup command has a new field "ttp" since commit 0dd3edd, however,
the ogServer legacy parser was not updated to use this new field.
This patch adds legacy setup support to work with GPT tables. Add new field
table type to legacy setup that expects a string with "MSDOS" or "GPT".
-rw-r--r-- | src/rest.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -2374,19 +2374,22 @@ static int og_cmd_legacy_image_restore(const char *input, struct og_cmd *cmd) return 0; } +#define OG_PARTITION_TABLE_TYPE_MAXLEN 5 + static int og_cmd_legacy_setup(const char *input, struct og_cmd *cmd) { json_t *root, *disk, *cache, *cache_size, *partition_setup, *object; + char part_table_type_str[OG_PARTITION_TABLE_TYPE_MAXLEN + 1]; struct og_legacy_partition part_cfg[OG_PARTITION_MAX] = {}; + json_t *part_table_type, *part, *code, *fs, *size, *format; char cache_size_str [OG_DB_INT_MAXLEN + 1]; char disk_str [OG_DB_SMALLINT_MAXLEN + 1]; - json_t *part, *code, *fs, *size, *format; unsigned int partition_len = 0; const char *in_ptr; char cache_str[2]; - if (sscanf(input, "dsk=%s\rcfg=dis=%*[^*]*che=%[^*]*tch=%[^!]!", - disk_str, cache_str, cache_size_str) != 3) + if (sscanf(input, "ttp=%s\rdsk=%s\rcfg=dis=%*[^*]*che=%[^*]*tch=%[^!]!", + part_table_type_str, disk_str, cache_str, cache_size_str) != 4) return -1; in_ptr = strstr(input, "!") + 1; @@ -2407,6 +2410,7 @@ static int og_cmd_legacy_setup(const char *input, struct og_cmd *cmd) if (!root) return -1; + part_table_type = json_string(part_table_type_str); cache_size = json_string(cache_size_str); cache = json_string(cache_str); partition_setup = json_array(); @@ -2436,6 +2440,7 @@ static int og_cmd_legacy_setup(const char *input, struct og_cmd *cmd) json_object_set_new(root, "partition_setup", partition_setup); json_object_set_new(root, "cache_size", cache_size); + json_object_set_new(root, "type", part_table_type); json_object_set_new(root, "cache", cache); json_object_set_new(root, "disk", disk); |