Currently hugeadm will happily remount hugetlbfs to the same directory if --create-*-mounts is specified more than once with the same arguments. This is a problem because the newest mount of a directory will mask the previous one(s) causing confusion when applications attempt tp share segements. This patch makes all the --create-*-mounts switches check to see if the requested directory is already mounted and if so skip the mount request.
Signed-off-by: Eric B Munson <ebmun...@us.ibm.com> --- Changes from V3: Separate the mount point collection logic and check into two patches Rename check_mount to check_if_already_mounted Changes from V2: Removed extra check of list pointer from mount_dir Changes from V1: Free list of mounts after mounted check fails hugeadm.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/hugeadm.c b/hugeadm.c index 24a2d2e..d450703 100644 --- a/hugeadm.c +++ b/hugeadm.c @@ -332,12 +332,42 @@ int ensure_dir(char *path, mode_t mode, uid_t uid, gid_t gid) return 0; } +int check_if_already_mounted(struct mount_list *list, char *path) +{ + while (list) { + if (!strcmp(list->entry.mnt_dir, path)) + return 1; + list = list->next; + } + return 0; +} + int mount_dir(char *path, char *options, mode_t mode, uid_t uid, gid_t gid) { struct passwd *pwd; struct group *grp; struct mntent entry; FILE *mounts; + struct mount_list *list, *previous; + + list = collect_active_mounts(NULL); + + if (list && check_if_already_mounted(list, path)) { + WARNING("Directory %s is already mounted.\n", path); + + while (list) { + previous = list; + list = list->next; + free(previous); + } + return 0; + } + + while (list) { + previous = list; + list = list->next; + free(previous); + } if (opt_dry_run) { pwd = getpwuid(uid); -- 1.6.1.2 ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel