diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-12-15 17:37:16 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-05-30 07:49:38 +0200 |
commit | 52b92b14f861c1cb57380c8b4586136ad9ddacaf (patch) | |
tree | 32c157fef586e87657bff9245b6094991955e413 /src/core/mount-setup.c | |
parent | d069de81ca1056ebe59650554ee5abc700a39b3f (diff) |
mount-setup: fix MNT_CHECK_WRITABLE error handling, and log about the issue
Let's correct the error handling (the error is in errno, not r), and
let's add logging like the rest of the function has it.
Diffstat (limited to 'src/core/mount-setup.c')
-rw-r--r-- | src/core/mount-setup.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c index 1e2849801..b35b90c36 100644 --- a/src/core/mount-setup.c +++ b/src/core/mount-setup.c @@ -169,10 +169,12 @@ bool mount_point_ignore(const char *path) { #endif // 0 static int mount_one(const MountPoint *p, bool relabel) { - int r; + int r, priority; assert(p); + priority = (p->mode & MNT_FATAL) ? LOG_ERR : LOG_DEBUG; + if (p->condition_fn && !p->condition_fn()) return 0; @@ -182,7 +184,7 @@ static int mount_one(const MountPoint *p, bool relabel) { r = path_is_mount_point(p->where, NULL, AT_SYMLINK_FOLLOW); if (r < 0 && r != -ENOENT) { - log_full_errno((p->mode & MNT_FATAL) ? LOG_ERR : LOG_DEBUG, r, "Failed to determine whether %s is a mount point: %m", p->where); + log_full_errno(priority, r, "Failed to determine whether %s is a mount point: %m", p->where); return (p->mode & MNT_FATAL) ? r : 0; } if (r > 0) @@ -210,7 +212,7 @@ static int mount_one(const MountPoint *p, bool relabel) { p->type, p->flags, p->options) < 0) { - log_full_errno((p->mode & MNT_FATAL) ? LOG_ERR : LOG_DEBUG, errno, "Failed to mount %s at %s: %m", p->type, p->where); + log_full_errno(priority, errno, "Failed to mount %s at %s: %m", p->type, p->where); return (p->mode & MNT_FATAL) ? -errno : 0; } @@ -219,10 +221,13 @@ static int mount_one(const MountPoint *p, bool relabel) { (void) label_fix(p->where, false, false); if (p->mode & MNT_CHECK_WRITABLE) { - r = access(p->where, W_OK); - if (r < 0) { + if (access(p->where, W_OK) < 0) { + r = -errno; + (void) umount(p->where); (void) rmdir(p->where); + + log_full_errno(priority, r, "Mount point %s not writable after mounting: %m", p->where); return (p->mode & MNT_FATAL) ? r : 0; } } |