]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
edce2aed | 2 | |
3ffd4af2 | 3 | #include "fd-util.h" |
edce2aed | 4 | #include "log.h" |
edce2aed | 5 | #include "qcow2-util.h" |
3ffd4af2 | 6 | #include "util.h" |
edce2aed LP |
7 | |
8 | int main(int argc, char *argv[]) { | |
9 | _cleanup_close_ int sfd = -1, dfd = -1; | |
10 | int r; | |
11 | ||
12 | if (argc != 3) { | |
13 | log_error("Needs two arguments."); | |
14 | return EXIT_FAILURE; | |
15 | } | |
16 | ||
17 | sfd = open(argv[1], O_RDONLY|O_CLOEXEC|O_NOCTTY); | |
18 | if (sfd < 0) { | |
19 | log_error_errno(errno, "Can't open source file: %m"); | |
20 | return EXIT_FAILURE; | |
21 | } | |
22 | ||
23 | dfd = open(argv[2], O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0666); | |
24 | if (dfd < 0) { | |
25 | log_error_errno(errno, "Can't open destination file: %m"); | |
26 | return EXIT_FAILURE; | |
27 | } | |
28 | ||
29 | r = qcow2_convert(sfd, dfd); | |
30 | if (r < 0) { | |
31 | log_error_errno(r, "Failed to unpack: %m"); | |
32 | return EXIT_FAILURE; | |
33 | } | |
34 | ||
35 | return EXIT_SUCCESS; | |
36 | } |