Some distros may link /etc/mtab to /proc/mounts, or
/proc/self/mounts. In such case, we don't need to
update mtab. Otherwise we false alart user with
"
mount.lustre: addmntent: Invalid argument:
"
Signed-off-by: Peng Tao <tao.peng@emc.com>
Change-Id: I2e3e213e4ee3bc177865c4ca7435a7eecd274b46
Reviewed-on: http://review.whamcloud.com/3881
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
+#define PROC_DIR "/proc/"
+static int mtab_is_proc(const char *mtab)
+{
+ char path[16];
+
+ if (readlink(mtab, path, sizeof(path)) < 0)
+ return 0;
+
+ if (strncmp(path, PROC_DIR, strlen(PROC_DIR)))
+ return 0;
+
+ return 1;
+}
+
int update_mtab_entry(char *spec, char *mtpt, char *type, char *opts,
int flags, int freq, int pass)
{
int update_mtab_entry(char *spec, char *mtpt, char *type, char *opts,
int flags, int freq, int pass)
{
struct mntent mnt;
int rc = 0;
struct mntent mnt;
int rc = 0;
+ /* Don't update mtab if it is linked to any file in /proc direcotry.*/
+ if (mtab_is_proc(MOUNTED))
+ return 0;
+
mnt.mnt_fsname = spec;
mnt.mnt_dir = mtpt;
mnt.mnt_type = type;
mnt.mnt_fsname = spec;
mnt.mnt_dir = mtpt;
mnt.mnt_type = type;