Debian Codegraph @

src/test/test-reread-partition-table-manual.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "fd-util.h"
4 #include "log.h"
5 #include "main-func.h"
6 #include "reread-partition-table.h"
7
8 static int run(int argc, char *argv[]) {
9 int r;
10
11 log_set_max_level(LOG_DEBUG);
12 log_setup();
13
14 if (argc != 2)
15 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Expected single parameter, the device node to open.");
16
17 _cleanup_close_ int fd = open(argv[1], O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
18 if (fd < 0)
19 return log_error_errno(errno, "Failed to open '%s': %m", argv[1]);
20
21 r = reread_partition_table_fd(fd, REREADPT_BSD_LOCK|REREADPT_FORCE_UEVENT);
22 if (r < 0)
23 return log_error_errno(r, "Failed to reread partition table: %m");
24
25 return 0;
26 }
27
28 DEFINE_MAIN_FUNCTION(run);