mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
dissect-image: Return mount point fd if requested
This commit is contained in:
@@ -625,6 +625,7 @@ static int run(int argc, char *argv[]) {
|
||||
DISSECT_IMAGE_RELAX_VAR_CHECK |
|
||||
DISSECT_IMAGE_READ_ONLY,
|
||||
&unlink_dir,
|
||||
/* ret_dir_fd= */ NULL,
|
||||
&loop_device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -467,6 +467,7 @@ static int run(int argc, char *argv[]) {
|
||||
DISSECT_IMAGE_GENERIC_ROOT |
|
||||
DISSECT_IMAGE_RELAX_VAR_CHECK,
|
||||
&unlink_dir,
|
||||
/* ret_dir_fd= */ NULL,
|
||||
&loop_device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -1366,6 +1366,7 @@ static int run(int argc, char *argv[]) {
|
||||
DISSECT_IMAGE_RELAX_VAR_CHECK |
|
||||
DISSECT_IMAGE_VALIDATE_OS,
|
||||
&mounted_dir,
|
||||
/* ret_dir_fd= */ NULL,
|
||||
&loop_device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -1389,6 +1389,7 @@ static int run(int argc, char *argv[]) {
|
||||
DISSECT_IMAGE_FSCK |
|
||||
DISSECT_IMAGE_GROWFS,
|
||||
&unlink_dir,
|
||||
/* ret_dir_fd= */ NULL,
|
||||
&loop_device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -2125,6 +2125,7 @@ static int run(int argc, char *argv[]) {
|
||||
DISSECT_IMAGE_RELAX_VAR_CHECK |
|
||||
(arg_action == ACTION_UPDATE_CATALOG ? DISSECT_IMAGE_FSCK|DISSECT_IMAGE_GROWFS : DISSECT_IMAGE_READ_ONLY),
|
||||
&unlink_dir,
|
||||
/* ret_dir_fd= */ NULL,
|
||||
&loop_device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -147,6 +147,7 @@ static int run(int argc, char *argv[]) {
|
||||
DISSECT_IMAGE_FSCK |
|
||||
DISSECT_IMAGE_GROWFS,
|
||||
&unlink_dir,
|
||||
/* ret_dir_fd= */ NULL,
|
||||
&loop_device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -6429,6 +6429,7 @@ static int run(int argc, char *argv[]) {
|
||||
DISSECT_IMAGE_USR_NO_ROOT |
|
||||
DISSECT_IMAGE_REQUIRE_ROOT,
|
||||
&mounted_dir,
|
||||
/* ret_dir_fd= */ NULL,
|
||||
&loop_device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -3315,6 +3315,7 @@ int mount_image_privately_interactively(
|
||||
const char *image,
|
||||
DissectImageFlags flags,
|
||||
char **ret_directory,
|
||||
int *ret_dir_fd,
|
||||
LoopDevice **ret_loop_device) {
|
||||
|
||||
_cleanup_(verity_settings_done) VeritySettings verity = VERITY_SETTINGS_DEFAULT;
|
||||
@@ -3388,6 +3389,16 @@ int mount_image_privately_interactively(
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to relinquish DM and loopback block devices: %m");
|
||||
|
||||
if (ret_dir_fd) {
|
||||
_cleanup_close_ int dir_fd = -EBADF;
|
||||
|
||||
dir_fd = open(created_dir, O_CLOEXEC|O_DIRECTORY);
|
||||
if (dir_fd < 0)
|
||||
return log_error_errno(errno, "Failed to open mount point directory: %m");
|
||||
|
||||
*ret_dir_fd = TAKE_FD(dir_fd);
|
||||
}
|
||||
|
||||
*ret_directory = TAKE_PTR(created_dir);
|
||||
*ret_loop_device = TAKE_PTR(d);
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ bool dissected_image_verity_candidate(const DissectedImage *image, PartitionDesi
|
||||
bool dissected_image_verity_ready(const DissectedImage *image, PartitionDesignator d);
|
||||
bool dissected_image_verity_sig_ready(const DissectedImage *image, PartitionDesignator d);
|
||||
|
||||
int mount_image_privately_interactively(const char *path, DissectImageFlags flags, char **ret_directory, LoopDevice **ret_loop_device);
|
||||
int mount_image_privately_interactively(const char *path, DissectImageFlags flags, char **ret_directory, int *ret_dir_fd, LoopDevice **ret_loop_device);
|
||||
|
||||
int verity_dissect_and_mount(int src_fd, const char *src, const char *dest, const MountOptions *options, const char *required_host_os_release_id, const char *required_host_os_release_version_id, const char *required_host_os_release_sysext_level, const char *required_sysext_scope);
|
||||
|
||||
|
||||
@@ -1222,6 +1222,7 @@ static int run(int argc, char *argv[]) {
|
||||
DISSECT_IMAGE_RELAX_VAR_CHECK |
|
||||
DISSECT_IMAGE_VALIDATE_OS,
|
||||
&mounted_dir,
|
||||
/* ret_dir_fd= */ NULL,
|
||||
&loop_device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -881,6 +881,7 @@ static int process_image(
|
||||
DISSECT_IMAGE_GENERIC_ROOT |
|
||||
DISSECT_IMAGE_REQUIRE_ROOT,
|
||||
&mounted_dir,
|
||||
/* ret_dir_fd= */ NULL,
|
||||
&loop_device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -2180,6 +2180,7 @@ static int run(int argc, char *argv[]) {
|
||||
DISSECT_IMAGE_FSCK |
|
||||
DISSECT_IMAGE_GROWFS,
|
||||
&unlink_dir,
|
||||
/* ret_dir_fd= */ NULL,
|
||||
&loop_device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -4142,6 +4142,7 @@ static int run(int argc, char *argv[]) {
|
||||
DISSECT_IMAGE_FSCK |
|
||||
DISSECT_IMAGE_GROWFS,
|
||||
&unlink_dir,
|
||||
/* ret_dir_fd= */ NULL,
|
||||
&loop_device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
Reference in New Issue
Block a user