multipath-tools/multipathd main.c
CVSROOT: /cvs/dm
Module name: multipath-tools
Branch: RHEL5_FC6
Changes by: [email protected] 2008-09-12 23:49:57
Modified files:
multipathd : main.c
Log message:
Fix for bz 449097. When multipathd creates a new namespace for the callout functions, it now unmounts all of the unneeded mounts that it inherits the calling process.
multipathd/main.c +48 -1
@@ -15,6 +15,7 @@#include <errno.h> #include <sys/time.h> #include <sys/resource.h> +#include <sys/mount.h> /* * libsysfs
@@ -62,6 +63,10 @@#include "waiter.h" #include "copy.h" +#if !defined(MNT_DETACH ) +#define MNT_DETACH 2 +#endif +#define FILE_NAME_SIZE 256#define CMDSIZE 160
@@ -1231,6 +1236,47 @@return NULL ; } +static int +unmount_extra_devs (void ) +{ +int ret; +char buf[LINE_MAX ]; +FILE *file; + + file =fopen ("/proc/mounts" ,"r" ); +if (!file) { +condlog (0 ,"couldn't open /proc/mounts : %s" ,strerror (errno)); +return -1 ; + } + +while (fgets (buf,LINE_MAX , file)) { +char *end, *mnt =strchr (buf,' ' ); +if (!mnt) +continue ; + mnt++; + end =strchr (mnt,' ' ); +if (!end) { +condlog (2 ,"can't process /proc/mounts line (%s). skipping" , buf); +continue ; + } + *end ='\0' ; +if (strcmp (mnt,"/" ) ==0 ||strcmp (mnt,"/sbin" ) ==0 || +strcmp (mnt,"/bin" ) ==0 ||strcmp (mnt,"/tmp" ) ==0 || +strcmp (mnt,"/usr" ) ==0 ||strncmp (mnt,"/usr/lib" ,8 ) ==0 || +strncmp (mnt,"/etc" ,4 ) ==0 ||strncmp (mnt,"/proc" ,5 ) ==0 || +strncmp (mnt,"/dev" ,4 ) ==0 ||strncmp (mnt,"/sys" ,4 ) ==0 || +strncmp (mnt,"/var" ,4 ) ==0 ||strncmp (mnt,"/lib" ,4 ) ==0 ) +continue ; +if (umount2 (mnt,MNT_DETACH ) <0 && errno !=ENOENT ) { +condlog (0 ,"failed to umount '%s' (%s). skipping" , mnt,strerror (errno)); + } + } +fclose (file); +return ret; +} + + +#ifdef CLONE_NEWNS static int
@@ -1328,7 +1374,8 @@ return -1; }condlog (4 ,"bind ramfs on /tmp" ); - +if (unmount_extra_devs () <0 ) +return -1 ;return 0 ; }#endif