]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/import/test-qcow2.c
Merge pull request #11241 from bengal/lldp-802-3-subtypes
[thirdparty/systemd.git] / src / import / test-qcow2.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include "fd-util.h"
4 #include "log.h"
5 #include "qcow2-util.h"
6 #include "util.h"
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 }