]>
Commit | Line | Data |
---|---|---|
edce2aed LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2015 Lennart Poettering | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License | |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
20 | ***/ | |
21 | ||
22 | #include "log.h" | |
23 | #include "util.h" | |
24 | ||
25 | #include "qcow2-util.h" | |
26 | ||
27 | int main(int argc, char *argv[]) { | |
28 | _cleanup_close_ int sfd = -1, dfd = -1; | |
29 | int r; | |
30 | ||
31 | if (argc != 3) { | |
32 | log_error("Needs two arguments."); | |
33 | return EXIT_FAILURE; | |
34 | } | |
35 | ||
36 | sfd = open(argv[1], O_RDONLY|O_CLOEXEC|O_NOCTTY); | |
37 | if (sfd < 0) { | |
38 | log_error_errno(errno, "Can't open source file: %m"); | |
39 | return EXIT_FAILURE; | |
40 | } | |
41 | ||
42 | dfd = open(argv[2], O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0666); | |
43 | if (dfd < 0) { | |
44 | log_error_errno(errno, "Can't open destination file: %m"); | |
45 | return EXIT_FAILURE; | |
46 | } | |
47 | ||
48 | r = qcow2_convert(sfd, dfd); | |
49 | if (r < 0) { | |
50 | log_error_errno(r, "Failed to unpack: %m"); | |
51 | return EXIT_FAILURE; | |
52 | } | |
53 | ||
54 | return EXIT_SUCCESS; | |
55 | } |