From: Peng Tao Date: Wed, 5 Sep 2012 10:36:05 +0000 (+0800) Subject: LU-1833 util: don't update mtab if linked to /proc X-Git-Tag: 2.3.53~10 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=f1b513eba1f67e16a0d15da3ad83e07b4572f8de LU-1833 util: don't update mtab if linked to /proc 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 Change-Id: I2e3e213e4ee3bc177865c4ca7435a7eecd274b46 Reviewed-on: http://review.whamcloud.com/3881 Reviewed-by: Bob Glossman Reviewed-by: Andreas Dilger Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/mount_utils.c b/lustre/utils/mount_utils.c index effa6c7..db3a0aa 100644 --- a/lustre/utils/mount_utils.c +++ b/lustre/utils/mount_utils.c @@ -180,6 +180,20 @@ 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; +} + int update_mtab_entry(char *spec, char *mtpt, char *type, char *opts, int flags, int freq, int pass) { @@ -187,6 +201,10 @@ int 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;