summaryrefslogtreecommitdiff
path: root/lib/mount_util.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2008-07-10 19:35:21 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2008-07-10 19:35:21 +0000
commit5f28cd15ab43c741f6d116be4d3a9aa5d82ab385 (patch)
tree16ad52166ef11aaf6325696f048ad27c579dae80 /lib/mount_util.c
parentcb71b4372c963da8c9fef37eac3ddb60de02b2a3 (diff)
downloadfuse-5f28cd15ab43c741f6d116be4d3a9aa5d82ab385.tar.gz
Skip calling mount(8) if /etc/mtab doesn't exist...
Diffstat (limited to 'lib/mount_util.c')
-rw-r--r--lib/mount_util.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/mount_util.c b/lib/mount_util.c
index 7db8060..e78b482 100644
--- a/lib/mount_util.c
+++ b/lib/mount_util.c
@@ -22,6 +22,7 @@
static int mtab_needs_update(const char *mnt)
{
+ int res;
struct stat stbuf;
/* If mtab is within new mount, don't touch it */
@@ -29,8 +30,25 @@ static int mtab_needs_update(const char *mnt)
_PATH_MOUNTED[strlen(mnt)] == '/')
return 0;
- if (lstat(_PATH_MOUNTED, &stbuf) != -1 && S_ISLNK(stbuf.st_mode))
- return 0;
+ /*
+ * Skip mtab update if /etc/mtab:
+ *
+ * - doesn't exist,
+ * - is a symlink,
+ * - is on a read-only filesystem.
+ */
+ res = lstat(_PATH_MOUNTED, &stbuf);
+ if (res == -1) {
+ if (errno == ENOENT)
+ return 0;
+ } else {
+ if (S_ISLNK(stbuf.st_mode))
+ return 0;
+
+ res = access(_PATH_MOUNTED, W_OK);
+ if (res == -1 && errno == EROFS)
+ return 0;
+ }
return 1;
}