Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Clone in Desktop Download ZIP

Loading…

don't try to update /etc/mtab unless it is a regular file. #16

Merged
merged 1 commit into from

2 participants

@pipcet

That's what the other mount helpers appear to be doing.

Debian switched to keeping a symlink to /proc/mounts in /etc/mtab, but didn't modify setmntent(3) to handle that case gracefully, so the only way to avoid error messages on Debian systems appears to be to lstat() /etc/mtab and check it's not a symbolic link.

libmount goes further and keeps some mount data in /run/mount/utab or $LIBMOUNT_UTAB, but I don't think we need to do that.

@pipcet pipcet don't try to update /etc/mtab unless it is a regular file.
That's what the other mount helpers appear to be doing.
a03d9ee
@garlick garlick merged commit 6d2ee8c into chaos:master
@pipcet pipcet deleted the pipcet:ignore-symlinked-mtab branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 18, 2015
  1. @pipcet

    don't try to update /etc/mtab unless it is a regular file.

    pipcet authored
    That's what the other mount helpers appear to be doing.
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 0 deletions.
  1. +13 −0 utils/diodmount.c
View
13 utils/diodmount.c
@@ -481,8 +481,21 @@ _update_mtab (char *options, char *spec, char *dir)
uid_t saved_euid = geteuid ();
FILE *f;
int ret = 0;
+ struct stat st;
struct mntent mnt;
+ ret = lstat(_PATH_MOUNTED, &st);
+
+ /* /etc/mtab can be a symlink to /proc/mounts or
+ * /proc/self/mounts, in which case we shouldn't write to it even
+ * if /proc isn't mounted. Return success in that case to avoid a
+ * spurious error message. */
+ if (ret != 0)
+ return 0;
+
+ if (!S_ISREG(st.st_mode))
+ return 1;
+
mnt.mnt_fsname = spec;
mnt.mnt_dir = dir;
mnt.mnt_type = "diod";
Something went wrong with that request. Please try again.