From: Adrian Vovk Date: Thu, 11 Jul 2024 23:35:10 +0000 (-0400) Subject: table: Fix JSON name mangling breaking changes X-Git-Tag: v257-rc1~892^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c82dfaf7e2f6171fe599fdd325c7f7c57198f096;p=thirdparty%2Fsystemd.git table: Fix JSON name mangling breaking changes In previous commits, we've changed the JSON name mangling logic. This, of course, will cause breaking changes to occur on anything that relied on the JSON mangling logic. This commit fixes those breaking changes by manually forcing the JSON name back to what it was before. --- diff --git a/src/import/importctl.c b/src/import/importctl.c index 3334f37b946..30566a19170 100644 --- a/src/import/importctl.c +++ b/src/import/importctl.c @@ -912,6 +912,11 @@ static int list_images(int argc, char *argv[], void *userdata) { (void) table_hide_column_from_display(t, 8); (void) table_hide_column_from_display(t, 10); + /* Starting in v257, these fields would be automatically formatted with underscores. However, this + * command was introduced in v256, so changing the field name would be a breaking change. */ + (void) table_set_json_field_name(t, 8, "usage-exclusive"); + (void) table_set_json_field_name(t, 10, "limit-exclusive"); + for (;;) { uint64_t crtime, mtime, usage, usage_exclusive, limit, limit_exclusive; const char *class, *name, *type, *path; diff --git a/src/partition/repart.c b/src/partition/repart.c index 0509364063a..0ad8fad1509 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -3043,6 +3043,10 @@ static int context_dump_partitions(Context *context) { if (!t) return log_oom(); + /* Starting in v257, these fields would be automatically formatted with underscores. This would have + * been a breaking change, so to avoid that let's hard-code their original names. */ + table_set_json_field_name(t, 15, "drop-in_files"); + if (!DEBUG_LOGGING) { if (arg_json_format_flags & SD_JSON_FORMAT_OFF) (void) table_set_display(t, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4, diff --git a/src/sysupdate/sysupdate.c b/src/sysupdate/sysupdate.c index 3fcb2839d09..aded7dde0b4 100644 --- a/src/sysupdate/sysupdate.c +++ b/src/sysupdate/sysupdate.c @@ -470,6 +470,11 @@ static int context_show_version(Context *c, const char *version) { (void) table_set_align_percent(t, table_get_cell(t, 0, 8), 100); table_set_ersatz_string(t, TABLE_ERSATZ_DASH); + /* Starting in v257, these fields would be automatically formatted with underscores. This would have + * been a breaking change, so to avoid that let's hard-code their original names. */ + (void) table_set_json_field_name(t, 7, "tries-done"); + (void) table_set_json_field_name(t, 8, "tries-left"); + /* Determine if the target will make use of partition/fs attributes for any of the transfers */ FOREACH_ARRAY(transfer, c->transfers, c->n_transfers) { Transfer *tr = *transfer;