1 /* SPDX-License-Identifier: LGPL-2.1+ */
6 #include "dissect-image.h"
9 #include "string-util.h"
12 int main(int argc
, char *argv
[]) {
13 _cleanup_(loop_device_unrefp
) LoopDevice
*d
= NULL
;
14 _cleanup_(dissected_image_unrefp
) DissectedImage
*m
= NULL
;
17 test_setup_logging(LOG_DEBUG
);
20 log_error("Requires one command line argument.");
24 r
= loop_device_make_by_path(argv
[1], O_RDONLY
, &d
);
26 log_error_errno(r
, "Failed to set up loopback device: %m");
30 r
= dissect_image(d
->fd
, NULL
, 0, DISSECT_IMAGE_REQUIRE_ROOT
, &m
);
32 log_error_errno(r
, "Failed to dissect image: %m");
36 for (i
= 0; i
< _PARTITION_DESIGNATOR_MAX
; i
++) {
38 if (!m
->partitions
[i
].found
)
41 printf("Found %s partition, %s of type %s at #%i (%s)\n",
42 partition_designator_to_string(i
),
43 m
->partitions
[i
].rw
? "writable" : "read-only",
44 strna(m
->partitions
[i
].fstype
),
45 m
->partitions
[i
].partno
,
46 strna(m
->partitions
[i
].node
));