Subject: bin/2363: umount -a uses fstab instead of mounted filesystem list
To: None <gnats-bugs@NetBSD.ORG>
From: None <greywolf@starwolf.com>
List: netbsd-bugs
Date: 04/29/1996 12:27:58
>Number:         2363
>Category:       bin
>Synopsis:       umount -a uses fstab instead of mounted filesystem list
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May  1 13:35:04 1996
>Last-Modified:
>Originator:     Greywolf
>Organization:
	Star Wolf Innovations: Food*Beer*Software*Gaming
>Release:        NetBSD-current: kernel:960430; userbin:960411; src:to-date
>Environment:
	
	SPARCstation 1+
	NetBSD-current (1.1B)
	sun4c/umount

System: NetBSD strikeforce 1.1B NetBSD 1.1B (STRIKEFORCE) #1: Tue Apr 30 17:25:04 PDT 1996 root@strikeforce:/usr/src/sys/arch/sparc/compile/STRIKEFORCE sparc


>Description:
	umount -a uses fstab instead of the list of mounted filesystems.
>How-To-Repeat:
	# umount -a
	umount: /cdrom: not currently mounted
	/dev/sd1h: unmount from /usr/X11
	umount: /usr/X11: Device busy
	umount: /altroot: not currently mounted
	/dev/sd0h: unmount from /usr/src
	umount: /usr/src: Device busy
	/dev/sd0g: unmount from /usr
	umount: /usr: Device busy
	/dev/sd0d: unmount from /var
	umount: /var: Device busy
	#

>Fix:
	Apply the following diff in /usr/src/sbin/umount
*** umount.c	Mon Apr 29 12:16:51 1996
--- umount.c.orig	Mon Apr 29 11:50:07 1996
***************
*** 144,162 ****
  int
  umountall()
  {
! 	struct statfs *mtab;
! 	int rval = 0;
! 	int nfsys;	/* number of mounted filesystems */
! 	int i;
  
! 	if (nfsys = getmntinfo(&mtab, MNT_NOWAIT)) {
! 	    for (i=nfsys - 1; i; i--) {
! 		if (strcmp(mtab[i].f_mntonname, "/")) {
! 		    if (umountfs(mtab[i].f_mntonname)) rval = 1;
!     	    	}
! 	    }
  	}
! 	return(rval);
  }
  
  int
--- 144,181 ----
  int
  umountall()
  {
! 	struct fstab *fs;
! 	int rval;
! 	char *cp;
  
! 	while ((fs = getfsent()) != NULL) {
! 		/* Ignore the root. */
! 		if (strcmp(fs->fs_file, "/") == 0)
! 			continue;
! 		/*
! 		 * !!!
! 		 * Historic practice: ignore unknown FSTAB_* fields.
! 		 */
! 		if (strcmp(fs->fs_type, FSTAB_RW) &&
! 		    strcmp(fs->fs_type, FSTAB_RO) &&
! 		    strcmp(fs->fs_type, FSTAB_RQ))
! 			continue;
! 
! 		if (!selected(fs->fs_vfstype))
! 			continue;
! 
! 		/* 
! 		 * We want to unmount the file systems in the reverse order
! 		 * that they were mounted.  So, we save off the file name
! 		 * in some allocated memory, and then call recursively.
! 		 */
! 		if ((cp = malloc((size_t)strlen(fs->fs_file) + 1)) == NULL)
! 			err(1, NULL);
! 		(void)strcpy(cp, fs->fs_file);
! 		rval = umountall();
! 		return (umountfs(cp) || rval);
  	}
! 	return (0);
  }
  
  int
>Audit-Trail:
>Unformatted: