mirror of
https://github.com/systemd/systemd
synced 2024-10-15 12:34:37 +00:00
dissect-image: add dissected_image_close() that closes all references to resources
This commit is contained in:
parent
f7178a04db
commit
9444e54e56
|
@ -1643,6 +1643,20 @@ int dissect_image_file_and_warn(
|
|||
verity);
|
||||
}
|
||||
|
||||
void dissected_image_close(DissectedImage *m) {
|
||||
if (!m)
|
||||
return;
|
||||
|
||||
/* Closes all fds we keep open assocated with this, but nothing else */
|
||||
|
||||
FOREACH_ARRAY(p, m->partitions, _PARTITION_DESIGNATOR_MAX) {
|
||||
p->mount_node_fd = safe_close(p->mount_node_fd);
|
||||
p->fsmount_fd = safe_close(p->fsmount_fd);
|
||||
}
|
||||
|
||||
m->loop = loop_device_unref(m->loop);
|
||||
}
|
||||
|
||||
DissectedImage* dissected_image_unref(DissectedImage *m) {
|
||||
if (!m)
|
||||
return NULL;
|
||||
|
|
|
@ -163,6 +163,7 @@ int dissect_image_file_and_warn(const char *path, const VeritySettings *verity,
|
|||
int dissect_loop_device(LoopDevice *loop, const VeritySettings *verity, const MountOptions *mount_options, const ImagePolicy *image_policy, DissectImageFlags flags, DissectedImage **ret);
|
||||
int dissect_loop_device_and_warn(LoopDevice *loop, const VeritySettings *verity, const MountOptions *mount_options, const ImagePolicy *image_policy, DissectImageFlags flags, DissectedImage **ret);
|
||||
|
||||
void dissected_image_close(DissectedImage *m);
|
||||
DissectedImage* dissected_image_unref(DissectedImage *m);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DissectedImage*, dissected_image_unref);
|
||||
|
||||
|
|
Loading…
Reference in a new issue