summaryrefslogtreecommitdiffstats
path: root/src/mount
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2015-01-03 08:29:29 +0100
committerYan, Zheng <zyan@redhat.com>2015-01-03 08:35:00 +0100
commitbdd0e3c4bda97fe18487a58dd173a7dff752e1a2 (patch)
tree1e24aafc48f49d27567088628b05e1f0f417dd10 /src/mount
parentMerge pull request #3284 from ktdreyer/doc-rados-preflight-os (diff)
downloadceph-bdd0e3c4bda97fe18487a58dd173a7dff752e1a2.tar.xz
ceph-bdd0e3c4bda97fe18487a58dd173a7dff752e1a2.zip
mount.ceph: avoid spurious error message
/etc/mtab in most modern distributions is a symbol link to /proc/self/mounts. Fixes: #10351 Signed-off-by: Yan, Zheng <zyan@redhat.com>
Diffstat (limited to 'src/mount')
-rw-r--r--src/mount/mtab.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mount/mtab.c b/src/mount/mtab.c
index 9b2c9237e16..d17f7a55f6c 100644
--- a/src/mount/mtab.c
+++ b/src/mount/mtab.c
@@ -18,6 +18,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <sys/vfs.h>
#include <time.h>
#include <mntent.h>
#include <stdarg.h>
@@ -44,6 +45,7 @@ setlkw_timeout (int sig) {
#define _PATH_MOUNTED "/etc/mtab"
#define _PATH_MOUNTED_LOCK "/etc/mtab~"
+#define PROC_SUPER_MAGIC 0x9fa0
/* exit status - bits below are ORed */
#define EX_USAGE 1 /* incorrect invocation or permission */
@@ -245,11 +247,21 @@ lock_mtab (void) {
static void
update_mtab_entry(const char *spec, const char *node, const char *type,
const char *opts, int flags, int freq, int pass) {
- struct mntent mnt;
+ struct statfs buf;
+ int err = statfs(_PATH_MOUNTED, &buf);
+ if (err) {
+ printf("mount: can't statfs %s: %s", _PATH_MOUNTED,
+ strerror (err));
+ return;
+ }
+ /* /etc/mtab is symbol link to /proc/self/mounts? */
+ if (buf.f_type == PROC_SUPER_MAGIC)
+ return;
if (!opts)
opts = "rw";
+ struct mntent mnt;
mnt.mnt_fsname = strdup(spec);
mnt.mnt_dir = canonicalize_path(node);
mnt.mnt_type = strdup(type);