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