dissect: introduce new helper dissected_image_mount_and_warn() and use it everywhere
This commit is contained in:
parent
fa45d12c1c
commit
af187ab237
|
@ -450,11 +450,9 @@ static int action_mount(DissectedImage *m, LoopDevice *d) {
|
|||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = dissected_image_mount(m, arg_path, UID_INVALID, arg_flags);
|
||||
if (r == -EUCLEAN)
|
||||
return log_error_errno(r, "File system check on image failed: %m");
|
||||
r = dissected_image_mount_and_warn(m, arg_path, UID_INVALID, arg_flags);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to mount image: %m");
|
||||
return r;
|
||||
|
||||
if (di) {
|
||||
r = decrypted_image_relinquish(di);
|
||||
|
@ -500,11 +498,9 @@ static int action_copy(DissectedImage *m, LoopDevice *d) {
|
|||
|
||||
created_dir = TAKE_PTR(temp);
|
||||
|
||||
r = dissected_image_mount(m, created_dir, UID_INVALID, arg_flags);
|
||||
if (r == -EUCLEAN)
|
||||
return log_error_errno(r, "File system check on image failed: %m");
|
||||
r = dissected_image_mount_and_warn(m, created_dir, UID_INVALID, arg_flags);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to mount image: %m");
|
||||
return r;
|
||||
|
||||
mounted_dir = TAKE_PTR(created_dir);
|
||||
|
||||
|
|
|
@ -3369,14 +3369,13 @@ static int outer_child(
|
|||
* uid shift known. That way we can mount VFAT file systems shifted to the right place right away. This
|
||||
* makes sure ESP partitions and userns are compatible. */
|
||||
|
||||
r = dissected_image_mount(dissected_image, directory, arg_uid_shift,
|
||||
DISSECT_IMAGE_MOUNT_ROOT_ONLY|DISSECT_IMAGE_DISCARD_ON_LOOP|
|
||||
(arg_read_only ? DISSECT_IMAGE_READ_ONLY : DISSECT_IMAGE_FSCK)|
|
||||
(arg_start_mode == START_BOOT ? DISSECT_IMAGE_VALIDATE_OS : 0));
|
||||
if (r == -EUCLEAN)
|
||||
return log_error_errno(r, "File system check for image failed: %m");
|
||||
r = dissected_image_mount_and_warn(
|
||||
dissected_image, directory, arg_uid_shift,
|
||||
DISSECT_IMAGE_MOUNT_ROOT_ONLY|DISSECT_IMAGE_DISCARD_ON_LOOP|
|
||||
(arg_read_only ? DISSECT_IMAGE_READ_ONLY : DISSECT_IMAGE_FSCK)|
|
||||
(arg_start_mode == START_BOOT ? DISSECT_IMAGE_VALIDATE_OS : 0));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to mount image root file system: %m");
|
||||
return r;
|
||||
}
|
||||
|
||||
r = determine_uid_shift(directory);
|
||||
|
|
|
@ -1145,6 +1145,29 @@ int dissected_image_mount(DissectedImage *m, const char *where, uid_t uid_shift,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int dissected_image_mount_and_warn(DissectedImage *m, const char *where, uid_t uid_shift, DissectImageFlags flags) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
assert(where);
|
||||
|
||||
r = dissected_image_mount(m, where, uid_shift, flags);
|
||||
if (r == -ENXIO)
|
||||
return log_error_errno(r, "Not root file system found in image.");
|
||||
if (r == -EMEDIUMTYPE)
|
||||
return log_error_errno(r, "No suitable os-release file in image found.");
|
||||
if (r == -EUNATCH)
|
||||
return log_error_errno(r, "Encrypted file system discovered, but decryption not requested.");
|
||||
if (r == -EUCLEAN)
|
||||
return log_error_errno(r, "File system check on image failed.");
|
||||
if (r == -EBUSY)
|
||||
return log_error_errno(r, "File system already mounted elsewhere.");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to mount image: %m");
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#if HAVE_LIBCRYPTSETUP
|
||||
typedef struct DecryptedPartition {
|
||||
struct crypt_device *device;
|
||||
|
@ -2031,11 +2054,9 @@ int mount_image_privately_interactively(
|
|||
|
||||
created_dir = TAKE_PTR(temp);
|
||||
|
||||
r = dissected_image_mount(dissected_image, created_dir, UID_INVALID, flags);
|
||||
if (r == -EUCLEAN)
|
||||
return log_error_errno(r, "File system check on image failed: %m");
|
||||
r = dissected_image_mount_and_warn(dissected_image, created_dir, UID_INVALID, flags);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to mount image: %m");
|
||||
return r;
|
||||
|
||||
if (decrypted_image) {
|
||||
r = decrypted_image_relinquish(decrypted_image);
|
||||
|
|
|
@ -106,6 +106,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(DissectedImage*, dissected_image_unref);
|
|||
int dissected_image_decrypt(DissectedImage *m, const char *passphrase, const void *root_hash, size_t root_hash_size, const char *verity_data, const char *root_hash_sig_path, const void *root_hash_sig, size_t root_hash_sig_size, DissectImageFlags flags, DecryptedImage **ret);
|
||||
int dissected_image_decrypt_interactively(DissectedImage *m, const char *passphrase, const void *root_hash, size_t root_hash_size, const char *verity_data, const char *root_hash_sig_path, const void *root_hash_sig, size_t root_hash_sig_size, DissectImageFlags flags, DecryptedImage **ret);
|
||||
int dissected_image_mount(DissectedImage *m, const char *dest, uid_t uid_shift, DissectImageFlags flags);
|
||||
int dissected_image_mount_and_warn(DissectedImage *m, const char *where, uid_t uid_shift, DissectImageFlags flags);
|
||||
|
||||
int dissected_image_acquire_metadata(DissectedImage *m);
|
||||
|
||||
|
|
Loading…
Reference in New Issue