| // SPDX-License-Identifier: LGPL-2.1-or-later |
| * libfdt - Flat Device Tree manipulation |
| * Testcase for node existence |
| * Copyright (C) 2016 Konsulko Inc. |
| FAIL(#code ": %s", fdt_strerror(err)); \ |
| /* 4k ought to be enough for anybody */ |
| #define FDT_COPY_SIZE (4 * 1024) |
| static void *open_dt(char *path) |
| copy = xmalloc(FDT_COPY_SIZE); |
| * Resize our DTs to 4k so that we have room to operate on |
| CHECK(fdt_open_into(dt, copy, FDT_COPY_SIZE)); |
| int main(int argc, char *argv[]) |
| int fail_config, exists, check_exists; |
| if (!strcmp(argv[2], "exists")) |
| else if (!strcmp(argv[2], "not-exists")) |
| CONFIG("Usage: %s <base dtb> <[exists|not-exists]> <node-path>", argv[0]); |
| fdt_base = open_dt(argv[1]); |
| exists = fdt_path_offset(fdt_base, argv[3]) >= 0; |
| if (exists == check_exists) |