mirror of
https://github.com/systemd/systemd.git
synced 2024-10-31 07:51:21 +03:00
homework: get rid of manual clean up path in home_setup_luks()
Now that we stored all our different objects inside the HomeSetup structure, we can get rid of our manual clean-up path, since home_setup_done() will clean up everything stored therein anyway, in the right order. This is the main reason we moved everything into HomeSetup in the previous commits: so that we can share clean-up paths for these objects with everything else.
This commit is contained in:
parent
80ffbbfbfb
commit
d33f024100
@ -1273,10 +1273,8 @@ int home_setup_luks(
|
||||
log_info("Discovered used loopback device %s.", setup->loop->node);
|
||||
|
||||
setup->root_fd = open(user_record_home_directory(h), O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOFOLLOW);
|
||||
if (setup->root_fd < 0) {
|
||||
r = log_error_errno(errno, "Failed to open home directory: %m");
|
||||
goto fail;
|
||||
}
|
||||
if (setup->root_fd < 0)
|
||||
return log_error_errno(errno, "Failed to open home directory: %m");
|
||||
} else {
|
||||
_cleanup_free_ char *fstype = NULL, *subdir = NULL;
|
||||
const char *ip;
|
||||
@ -1340,27 +1338,25 @@ int home_setup_luks(
|
||||
|
||||
r = luks_validate_home_record(setup->crypt_device, h, volume_key, cache, &luks_home);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
return r;
|
||||
|
||||
r = fs_validate(setup->dm_node, h->file_system_uuid, &fstype, &found_fs_uuid);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
return r;
|
||||
|
||||
r = run_fsck(setup->dm_node, fstype);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
return r;
|
||||
|
||||
r = home_unshare_and_mount(setup->dm_node, fstype, user_record_luks_discard(h), user_record_mount_flags(h));
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
return r;
|
||||
|
||||
setup->undo_mount = true;
|
||||
|
||||
setup->root_fd = open(subdir, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOFOLLOW);
|
||||
if (setup->root_fd < 0) {
|
||||
r = log_error_errno(errno, "Failed to open home directory: %m");
|
||||
goto fail;
|
||||
}
|
||||
if (setup->root_fd < 0)
|
||||
return log_error_errno(errno, "Failed to open home directory: %m");
|
||||
|
||||
if (user_record_luks_discard(h))
|
||||
(void) run_fitrim(setup->root_fd);
|
||||
@ -1380,16 +1376,6 @@ int home_setup_luks(
|
||||
*ret_luks_home = TAKE_PTR(luks_home);
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
setup->root_fd = safe_close(setup->root_fd);
|
||||
home_setup_undo_mount(setup, LOG_ERR);
|
||||
home_setup_undo_dm(setup, LOG_ERR);
|
||||
|
||||
if (setup->image_fd >= 0 && setup->do_mark_clean)
|
||||
(void) run_mark_dirty(setup->image_fd, false);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static void print_size_summary(uint64_t host_size, uint64_t encrypted_size, struct statfs *sfs) {
|
||||
|
Loading…
Reference in New Issue
Block a user