Whamcloud - gitweb
LU-1833 util: don't update mtab if linked to /proc
authorShuichi Ihara <sihara@ddn.com>
Mon, 10 Dec 2012 16:58:50 +0000 (01:58 +0900)
committerOleg Drokin <green@whamcloud.com>
Tue, 11 Dec 2012 23:33:10 +0000 (18:33 -0500)
Backport patch of LU-1833 for b2_1.
This is needed for the diskless environment since their
mtab is linking to /proc/mount.

Signed-off-by: Shuichi Ihara <sihara@ddn.com>
Signed-off-by: Peng Tao <tao.peng@emc.com>
Change-Id: Id18cd6a820dff905f0d61ecc1f71f4ce7b48cf77
Reviewed-on: http://review.whamcloud.com/4785
Tested-by: Hudson
Reviewed-by: Peng Tao <bergwolf@gmail.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/utils/mount_lustre.c

index 4f8f7c6..e00fe96 100644 (file)
@@ -129,6 +129,20 @@ static int check_mtab_entry(char *spec1, char *spec2, char *mtpt, char *type)
         return(0);
 }
 
+#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;
+}
+
 static int
 update_mtab_entry(char *spec, char *mtpt, char *type, char *opts,
                   int flags, int freq, int pass)
@@ -137,6 +151,10 @@ update_mtab_entry(char *spec, char *mtpt, char *type, char *opts,
         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;