summaryrefslogtreecommitdiff
path: root/src/shared/switch-root.c
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-11-28 19:57:32 +0100
committerMichal Schmidt <mschmidt@redhat.com>2014-11-28 19:57:32 +0100
commit4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4f (patch)
treec7a6228e7151aa74bc8e331694a1e795226550cd /src/shared/switch-root.c
parent56f64d95763a799ba4475daf44d8e9f72a1bd474 (diff)
downloadsystemd-4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4f.tar.gz
treewide: another round of simplifications
Using the same scripts as in f647962d64e "treewide: yet more log_*_errno + return simplifications".
Diffstat (limited to 'src/shared/switch-root.c')
-rw-r--r--src/shared/switch-root.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c
index c5b635d17d..ca3875628a 100644
--- a/src/shared/switch-root.c
+++ b/src/shared/switch-root.c
@@ -56,10 +56,8 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
old_root_remove = in_initrd();
- if (stat(new_root, &new_root_stat) < 0) {
- log_error_errno(errno, "Failed to stat directory %s: %m", new_root);
- return -errno;
- }
+ if (stat(new_root, &new_root_stat) < 0)
+ return log_error_errno(errno, "Failed to stat directory %s: %m", new_root);
/* Work-around for kernel design: the kernel refuses switching
* root if any file systems are mounted MS_SHARED. Hence
@@ -109,10 +107,8 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
* switch_root() nevertheless. */
(void) base_filesystem_create(new_root);
- if (chdir(new_root) < 0) {
- log_error_errno(errno, "Failed to change directory to %s: %m", new_root);
- return -errno;
- }
+ if (chdir(new_root) < 0)
+ return log_error_errno(errno, "Failed to change directory to %s: %m", new_root);
if (old_root_remove) {
old_root_fd = open("/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY|O_DIRECTORY);
@@ -132,20 +128,14 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
oldroot,
errno == ENOENT ? "ignoring" : "leaving it around");
- } else if (mount(new_root, "/", NULL, MS_MOVE, NULL) < 0) {
- log_error_errno(errno, "Failed to mount moving %s to /: %m", new_root);
- return -errno;
- }
+ } else if (mount(new_root, "/", NULL, MS_MOVE, NULL) < 0)
+ return log_error_errno(errno, "Failed to mount moving %s to /: %m", new_root);
- if (chroot(".") < 0) {
- log_error_errno(errno, "Failed to change root: %m");
- return -errno;
- }
+ if (chroot(".") < 0)
+ return log_error_errno(errno, "Failed to change root: %m");
- if (chdir("/") < 0) {
- log_error_errno(errno, "Failed to change directory: %m");
- return -errno;
- }
+ if (chdir("/") < 0)
+ return log_error_errno(errno, "Failed to change directory: %m");
if (old_root_fd >= 0) {
struct stat rb;