Subject: bin/444: mount will re-mount filesystems already mounted
To: None <gnats-admin>
From: Ken Hornstein <kenh@excalibur.entropic.com>
List: netbsd-bugs
Date: 08/29/1994 20:20:05
>Number:         444
>Category:       bin
>Synopsis:       mount will re-mount filesystems already mounted
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 29 20:20:03 1994
>Originator:     Ken Hornstein
>Organization:
"	"
>Release:        
>Environment:
	
System: NetBSD excalibur 1.0_BETA NetBSD 1.0_BETA (EXCALIBUR) #0: Mon Aug 22 02:11:47 EDT 1994 kenh@excalibur:/usr/src/sys/arch/i386/compile/EXCALIBUR i386


>Description:
Mount will re-mount filesystems when using the "-a" option that are already
mounted.  This is mildly annoying when trying to make a dataless configuration.
	
>How-To-Repeat:
Put a NFS filesystem in your fstab.  Run "mount -a" twice.
	
>Fix:
	
The following patch does an okay job of fixing this problem.

*** mount.c.old	Mon Aug 29 22:26:01 1994
--- mount.c	Mon Aug 29 23:05:45 1994
***************
*** 71,76 ****
--- 71,77 ----
  			int, const char *, const char *));
  void	prmount __P((struct statfs *));
  void	usage __P((void));
+ int	alreadymounted __P((const char *, const char *, const char *));
  
  /* From mount_ufs.c. */
  int	mount_ufs __P((int, char * const *));
***************
*** 167,172 ****
--- 168,176 ----
  					continue;
  				if (hasopt(fs->fs_mntops, "noauto"))
  					continue;
+ 				if (alreadymounted(fs->fs_spec, fs->fs_file,
+ 				    fs->fs_vfstype))
+ 					continue;
  				if (mountfs(fs->fs_vfstype, fs->fs_spec,
  				    fs->fs_file, init_flags, options,
  				    fs->fs_mntops))
***************
*** 527,530 ****
--- 531,555 ----
  		"[-adfruvw] [-t ufs | external_type]",
  		"[-dfruvw] special | node");
  	exit(1);
+ }
+ 
+ int alreadymounted(fs_spec, fs_file, fs_vfstype)
+ 	const char *fs_spec, *fs_file, *fs_vfstype;
+ {
+ 	struct statfs *mntbuf;
+ 	int i, mntsize;
+ 
+ 	mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
+ 
+ 	for(i = 0; i < mntsize; i++)
+ 		if (strcmp(mntbuf[i].f_mntfromname, fs_spec) == 0 &&
+ 		    strcmp(mntbuf[i].f_mntonname, fs_file) == 0 &&
+ 		    strcmp(mntbuf[i].f_fstypename, fs_vfstype) == 0)
+ 			return(1);
+ 		else if (strncmp(mntbuf[i].f_mntfromname, "mfs:", 4) == 0 &&
+ 			 strcmp(mntbuf[i].f_mntonname, fs_file) == 0 &&
+ 			 strcmp(mntbuf[i].f_fstypename, "mfs") == 0)
+ 			return(1);
+ 
+ 	return(0);
  }
>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------