From: Shuichi Ihara Date: Mon, 10 Dec 2012 16:58:50 +0000 (+0900) Subject: LU-1833 util: don't update mtab if linked to /proc X-Git-Tag: 2.1.4-RC1~9 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=bf0ffcea349000d99b006ca8b0aef98cc2a9a010;p=fs%2Flustre-release.git LU-1833 util: don't update mtab if linked to /proc 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 Signed-off-by: Peng Tao Change-Id: Id18cd6a820dff905f0d61ecc1f71f4ce7b48cf77 Reviewed-on: http://review.whamcloud.com/4785 Tested-by: Hudson Reviewed-by: Peng Tao Tested-by: Maloo Reviewed-by: Andreas Dilger --- diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index 4f8f7c6..e00fe96 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -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;