2 This file is part of systemd.
4 Copyright 2016 Lennart Poettering
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 #include "dissect-image.h"
25 #include "loop-util.h"
26 #include "string-util.h"
28 int main(int argc
, char *argv
[]) {
29 _cleanup_(loop_device_unrefp
) LoopDevice
*d
= NULL
;
30 _cleanup_(dissected_image_unrefp
) DissectedImage
*m
= NULL
;
33 log_set_max_level(LOG_DEBUG
);
36 log_error("Requires one command line argument.");
40 r
= loop_device_make_by_path(argv
[1], O_RDONLY
, &d
);
42 log_error_errno(r
, "Failed to set up loopback device: %m");
46 r
= dissect_image(d
->fd
, NULL
, 0, &m
);
48 log_error_errno(r
, "Failed to dissect image: %m");
52 for (i
= 0; i
< _PARTITION_DESIGNATOR_MAX
; i
++) {
54 if (!m
->partitions
[i
].found
)
57 printf("Found %s partition, %s of type %s at #%i (%s)\n",
58 partition_designator_to_string(i
),
59 m
->partitions
[i
].rw
? "writable" : "read-only",
60 strna(m
->partitions
[i
].fstype
),
61 m
->partitions
[i
].partno
,
62 strna(m
->partitions
[i
].node
));