Debian Codegraph @

test/sysfs/tree-dump.c

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /**
3 * This file is part of libnvme.
4 * Copyright (c) 2024 Daniel Wagner, SUSE LLC
5 */
6
7 #include <string.h>
8 #include <stdbool.h>
9 #include <stdlib.h>
10 #include <errno.h>
11
12 #include <libnvme.h>
13
14 static bool tree_dump(void)
15 {
16 bool pass = false;
17 nvme_root_t r;
18 int err;
19
20 r = nvme_create_root(stdout, LOG_ERR);
21 if (!r)
22 return false;
23
24 err = nvme_scan_topology(r, NULL, NULL);
25 if (err) {
26 if (errno != ENOENT)
27 goto out;
28 }
29
30 if (nvme_dump_tree(r))
31 goto out;
32 printf("\n");
33
34 pass = true;
35
36 out:
37 nvme_free_tree(r);
38 return pass;
39 }
40
41 int main(int argc, char *argv[])
42 {
43 bool pass = true;
44
45 pass = tree_dump();
46 fflush(stdout);
47
48 exit(pass ? EXIT_SUCCESS : EXIT_FAILURE);
49 }