dissect-image: introduce dissect_loop_device() which takes LoopDevice object
This commit is contained in:
@@ -1196,12 +1196,9 @@ int image_read_metadata(Image *i) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = dissect_image(
|
||||
d->fd,
|
||||
r = dissect_loop_device(
|
||||
d,
|
||||
NULL, NULL,
|
||||
d->diskseq,
|
||||
d->uevent_seqnum_not_before,
|
||||
d->timestamp_not_before,
|
||||
DISSECT_IMAGE_GENERIC_ROOT |
|
||||
DISSECT_IMAGE_REQUIRE_ROOT |
|
||||
DISSECT_IMAGE_RELAX_VAR_CHECK |
|
||||
|
||||
+12
-24
@@ -2796,29 +2796,23 @@ finish:
|
||||
return r;
|
||||
}
|
||||
|
||||
int dissect_image_and_warn(
|
||||
int fd,
|
||||
int dissect_loop_device_and_warn(
|
||||
const char *name,
|
||||
const LoopDevice *loop,
|
||||
const VeritySettings *verity,
|
||||
const MountOptions *mount_options,
|
||||
uint64_t diskseq,
|
||||
uint64_t uevent_seqnum_not_before,
|
||||
usec_t timestamp_not_before,
|
||||
DissectImageFlags flags,
|
||||
DissectedImage **ret) {
|
||||
|
||||
_cleanup_free_ char *buffer = NULL;
|
||||
int r;
|
||||
|
||||
if (!name) {
|
||||
r = fd_get_path(fd, &buffer);
|
||||
if (r < 0)
|
||||
return r;
|
||||
assert(loop);
|
||||
assert(loop->fd >= 0);
|
||||
|
||||
name = buffer;
|
||||
}
|
||||
if (!name)
|
||||
name = ASSERT_PTR(loop->node);
|
||||
|
||||
r = dissect_image(fd, verity, mount_options, diskseq, uevent_seqnum_not_before, timestamp_not_before, flags, ret);
|
||||
r = dissect_loop_device(loop, verity, mount_options, flags, ret);
|
||||
switch (r) {
|
||||
|
||||
case -EOPNOTSUPP:
|
||||
@@ -2971,7 +2965,7 @@ int mount_image_privately_interactively(
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set up loopback device for %s: %m", image);
|
||||
|
||||
r = dissect_image_and_warn(d->fd, image, &verity, NULL, d->diskseq, d->uevent_seqnum_not_before, d->timestamp_not_before, flags, &dissected_image);
|
||||
r = dissect_loop_device_and_warn(image, d, &verity, NULL, flags, &dissected_image);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -3082,24 +3076,18 @@ int verity_dissect_and_mount(
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to create loop device for image: %m");
|
||||
|
||||
r = dissect_image(
|
||||
loop_device->fd,
|
||||
r = dissect_loop_device(
|
||||
loop_device,
|
||||
&verity,
|
||||
options,
|
||||
loop_device->diskseq,
|
||||
loop_device->uevent_seqnum_not_before,
|
||||
loop_device->timestamp_not_before,
|
||||
dissect_image_flags,
|
||||
&dissected_image);
|
||||
/* No partition table? Might be a single-filesystem image, try again */
|
||||
if (!verity.data_path && r == -ENOPKG)
|
||||
r = dissect_image(
|
||||
loop_device->fd,
|
||||
r = dissect_loop_device(
|
||||
loop_device,
|
||||
&verity,
|
||||
options,
|
||||
loop_device->diskseq,
|
||||
loop_device->uevent_seqnum_not_before,
|
||||
loop_device->timestamp_not_before,
|
||||
dissect_image_flags | DISSECT_IMAGE_NO_PARTITION_TABLE,
|
||||
&dissected_image);
|
||||
if (r < 0)
|
||||
|
||||
@@ -254,7 +254,11 @@ const char* mount_options_from_designator(const MountOptions *options, Partition
|
||||
|
||||
int probe_filesystem(const char *node, char **ret_fstype);
|
||||
int dissect_image(int fd, const VeritySettings *verity, const MountOptions *mount_options, uint64_t diskseq, uint64_t uevent_seqnum_not_before, usec_t timestamp_not_before, DissectImageFlags flags, DissectedImage **ret);
|
||||
int dissect_image_and_warn(int fd, const char *name, const VeritySettings *verity, const MountOptions *mount_options, uint64_t diskseq, uint64_t uevent_seqnum_not_before, usec_t timestamp_not_before, DissectImageFlags flags, DissectedImage **ret);
|
||||
static inline int dissect_loop_device(const LoopDevice *loop, const VeritySettings *verity, const MountOptions *mount_options, DissectImageFlags flags, DissectedImage **ret) {
|
||||
assert(loop);
|
||||
return dissect_image(loop->fd, verity, mount_options, loop->diskseq, loop->uevent_seqnum_not_before, loop->timestamp_not_before, flags, ret);
|
||||
}
|
||||
int dissect_loop_device_and_warn(const char *name, const LoopDevice *loop, const VeritySettings *verity, const MountOptions *mount_options, DissectImageFlags flags, DissectedImage **ret);
|
||||
|
||||
DissectedImage* dissected_image_unref(DissectedImage *m);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DissectedImage*, dissected_image_unref);
|
||||
|
||||
Reference in New Issue
Block a user