forked from linux-nvme/nvme-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig-dump.c
More file actions
52 lines (40 loc) · 860 Bytes
/
config-dump.c
File metadata and controls
52 lines (40 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: LGPL-2.1-or-later
/**
* This file is part of libnvme.
* Copyright (c) 2024 Daniel Wagner, SUSE LLC
*/
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <libnvme.h>
static bool config_dump(const char *file)
{
struct nvme_global_ctx *ctx;
bool pass = false;
int err;
ctx = nvme_create_global_ctx(stderr, LOG_ERR);
if (!ctx)
return false;
err = nvme_scan_topology(ctx, NULL, NULL);
if (err < 0 && err != -ENOENT)
goto out;
err = nvme_read_config(ctx, file);
if (err)
goto out;
err = nvme_dump_config(ctx, STDOUT_FILENO);
if (err)
goto out;
pass = true;
out:
nvme_free_global_ctx(ctx);
return pass;
}
int main(int argc, char *argv[])
{
bool pass;
pass = config_dump(argv[1]);
fflush(stdout);
exit(pass ? EXIT_SUCCESS : EXIT_FAILURE);
}