]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mount-setup: fix MNT_CHECK_WRITABLE error handling, and log about the issue
authorLennart Poettering <lennart@poettering.net>
Fri, 15 Dec 2017 16:37:16 +0000 (17:37 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 15 Dec 2017 19:52:28 +0000 (20:52 +0100)
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.

src/core/mount-setup.c

index 7171d8fda436c80442f28c2d41a60a3dc2c39239..a0c5f5aaae26ca37d8b7552c1b48e35fafa91ac6 100644 (file)
@@ -155,10 +155,12 @@ bool mount_point_ignore(const char *path) {
 }
 
 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;
 
@@ -168,7 +170,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)
@@ -196,7 +198,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;
         }
 
@@ -205,10 +207,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;
                 }
         }