dissect-image: also store the image size in DissectedImage

That way we can easily access it the same way regardless if we operate
on a block device or on a regular file.
This commit is contained in:
Lennart Poettering
2023-12-13 17:35:22 +01:00
parent 6bc201343f
commit 51778dea0d
2 changed files with 9 additions and 1 deletions
+8 -1
View File
@@ -1547,6 +1547,7 @@ int dissect_image_file(
#if HAVE_BLKID
_cleanup_(dissected_image_unrefp) DissectedImage *m = NULL;
_cleanup_close_ int fd = -EBADF;
struct stat st;
int r;
assert(path);
@@ -1555,7 +1556,10 @@ int dissect_image_file(
if (fd < 0)
return -errno;
r = fd_verify_regular(fd);
if (fstat(fd, &st) < 0)
return -errno;
r = stat_verify_regular(&st);
if (r < 0)
return r;
@@ -1563,6 +1567,8 @@ int dissect_image_file(
if (r < 0)
return r;
m->image_size = st.st_size;
r = probe_sector_size(fd, &m->sector_size);
if (r < 0)
return r;
@@ -3699,6 +3705,7 @@ int dissect_loop_device(
return r;
m->loop = loop_device_ref(loop);
m->image_size = m->loop->device_size;
m->sector_size = m->loop->sector_size;
r = dissect_image(m, loop->fd, loop->node, verity, mount_options, image_policy, flags);
+1
View File
@@ -102,6 +102,7 @@ struct DissectedImage {
DecryptedImage *decrypted_image;
uint32_t sector_size;
uint64_t image_size;
char *image_name;
sd_id128_t image_uuid;