From 08d373881cb9ccb87464c58e3300160d899af0c1 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Wed, 24 Jul 2024 10:30:28 +0200 Subject: [PATCH] Fix JSON export of "otherfs" excluded type The exporter would write "othfs" while the import code was expecting "otherfs". This bug also exists in the 1.x branch and is probably as old as the JSON import/export feature. D'oh. Normalized the export to use "otherfs" now (which is what all versions can read correctly) and fixed the importer to also accept "othfs" (which is what all previous versions exported). --- src/json_import.zig | 2 +- src/sink.zig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json_import.zig b/src/json_import.zig index b7c3c43..177404f 100644 --- a/src/json_import.zig +++ b/src/json_import.zig @@ -337,7 +337,7 @@ fn itemkey(ctx: *Ctx, key: []const u8) void { var buf: [32]u8 = undefined; const typ = ctx.p.string(&buf); // "frmlnk" is also possible, but currently considered equivalent to "pattern". - if (eq(u8, typ, "otherfs")) ctx.special = .other_fs + if (eq(u8, typ, "otherfs") or eq(u8, typ, "othfs")) ctx.special = .other_fs else if (eq(u8, typ, "kernfs")) ctx.special = .kernfs else ctx.special = .excluded; return; diff --git a/src/sink.zig b/src/sink.zig index 1312166..b714d5e 100644 --- a/src/sink.zig +++ b/src/sink.zig @@ -170,7 +170,7 @@ const JsonWriter = struct { ctx.writeStr(name); ctx.write(switch (t) { .err => "\",\"read_error\":true}", - .other_fs => "\",\"excluded\":\"othfs\"}", + .other_fs => "\",\"excluded\":\"otherfs\"}", .kernfs => "\",\"excluded\":\"kernfs\"}", .excluded => "\",\"excluded\":\"pattern\"}", });