Move pattern matching to Rust

This commit is contained in:
topjohnwu
2023-06-21 16:47:20 -07:00
parent 399b9e5eba
commit 9c7cf340a1
7 changed files with 91 additions and 76 deletions

View File

@@ -8,6 +8,7 @@
#include "magiskboot.hpp"
#include "dtb.hpp"
#include "format.hpp"
#include "boot-rs.hpp"
using namespace std;
@@ -151,7 +152,7 @@ static bool dtb_patch(const char *file) {
int len;
char *value = (char *) fdt_getprop(fdt, node, "fsmgr_flags", &len);
byte_data data(value, len);
patched |= (patch_verity(data) != len);
patched |= (rust::patch_verity(data) != len);
}
}
}
@@ -224,7 +225,7 @@ static bool fdt_patch(void *fdt) {
int len;
const void *value = fdt_getprop(fdt, node, "fsmgr_flags", &len);
heap_data copy = byte_view(value, len).clone();
auto patched_sz = patch_verity(copy);
auto patched_sz = rust::patch_verity(copy);
if (patched_sz != len) {
modified = true;
fdt_setprop(fdt, node, "fsmgr_flags", copy.buf(), patched_sz);