dissect-image: reuse LoopDevice.node in dissect_image()
Currently, dissect_image() is only called through dissect_loop_device(), and the LoopDevice object has device name. Hence, it is not necessary to get device name in dissect_image().
This commit is contained in:
@@ -193,6 +193,7 @@ static int make_partition_devname(
|
||||
|
||||
int dissect_image(
|
||||
int fd,
|
||||
const char *devname,
|
||||
const char *image_path,
|
||||
const VeritySettings *verity,
|
||||
const MountOptions *mount_options,
|
||||
@@ -205,17 +206,16 @@ int dissect_image(
|
||||
bool is_gpt, is_mbr, multiple_generic = false,
|
||||
generic_rw = false, /* initialize to appease gcc */
|
||||
generic_growfs = false;
|
||||
_cleanup_(sd_device_unrefp) sd_device *d = NULL;
|
||||
_cleanup_(dissected_image_unrefp) DissectedImage *m = NULL;
|
||||
_cleanup_(blkid_free_probep) blkid_probe b = NULL;
|
||||
_cleanup_free_ char *generic_node = NULL;
|
||||
sd_id128_t generic_uuid = SD_ID128_NULL;
|
||||
const char *pttype = NULL, *devname = NULL;
|
||||
const char *pttype = NULL;
|
||||
blkid_partlist pl;
|
||||
int r, generic_nr = -1, n_partitions;
|
||||
struct stat st;
|
||||
|
||||
assert(fd >= 0);
|
||||
assert(devname);
|
||||
assert(ret);
|
||||
assert(!verity || verity->designator < 0 || IN_SET(verity->designator, PARTITION_ROOT, PARTITION_USR));
|
||||
assert(!verity || verity->root_hash || verity->root_hash_size == 0);
|
||||
@@ -259,16 +259,6 @@ int dissect_image(
|
||||
}
|
||||
}
|
||||
|
||||
if (fstat(fd, &st) < 0)
|
||||
return -errno;
|
||||
|
||||
if (!S_ISBLK(st.st_mode))
|
||||
return -ENOTBLK;
|
||||
|
||||
r = sd_device_new_from_stat_rdev(&d, &st);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
b = blkid_new_probe();
|
||||
if (!b)
|
||||
return -ENOMEM;
|
||||
@@ -319,10 +309,6 @@ int dissect_image(
|
||||
m->image_name = TAKE_PTR(name_stripped);
|
||||
}
|
||||
|
||||
r = sd_device_get_devname(d, &devname);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to get device devname: %m");
|
||||
|
||||
if ((!(flags & DISSECT_IMAGE_GPT_ONLY) &&
|
||||
(flags & DISSECT_IMAGE_GENERIC_ROOT)) ||
|
||||
(flags & DISSECT_IMAGE_NO_PARTITION_TABLE)) {
|
||||
|
||||
@@ -255,6 +255,7 @@ 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 char *devname,
|
||||
const char *image_path,
|
||||
const VeritySettings *verity,
|
||||
const MountOptions *mount_options,
|
||||
@@ -262,7 +263,7 @@ int dissect_image(
|
||||
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, loop->backing_file ?: loop->node, verity, mount_options, flags, ret);
|
||||
return dissect_image(loop->fd, loop->node, loop->backing_file ?: loop->node, verity, mount_options, flags, ret);
|
||||
}
|
||||
int dissect_loop_device_and_warn(const LoopDevice *loop, const VeritySettings *verity, const MountOptions *mount_options, DissectImageFlags flags, DissectedImage **ret);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user