From yugawa@orleans.rim.or.jp  Tue May 13 08:02:59 1997
Received: from rayearth.rim.or.jp (uucp@rayearth.rim.or.jp [202.247.130.242])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id IAA23727
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 13 May 1997 08:00:41 -0700 (PDT)
Received: (from uucp@localhost) by rayearth.rim.or.jp (8.8.5/3.5Wpl2-uucp1/RIMNET) with UUCP
	id AAA03280 for FreeBSD-gnats-submit@freebsd.org; Wed, 14 May 1997 00:00:15 +0900 (JST)
Received: (from uucp@localhost) by orleans.rim.or.jp (8.8.5/3.5W-darwin.1) with UUCP id XAA29843 for FreeBSD-gnats-submit@freebsd.org; Tue, 13 May 1997 23:41:29 +0900 (JST)
Received: (from yugawa@localhost) by oleo.orleans.rim.or.jp (8.8.5/3.5W-oleo.1) id XAA04885; Tue, 13 May 1997 23:39:05 +0900 (JST)
Message-Id: <199705131439.XAA04885@oleo.orleans.rim.or.jp>
Date: Tue, 13 May 1997 23:39:05 +0900 (JST)
From: Takahiro Yugawa <yugawa@orleans.rim.or.jp>
Reply-To: yugawa@orleans.rim.or.jp
To: FreeBSD-gnats-submit@freebsd.org
Cc: yugawa@oleo.orleans.rim.or.jp
Subject: Memory Filesystem unmounting problem
X-Send-Pr-Version: 3.2

>Number:         3588
>Category:       bin
>Synopsis:       Memory Filesystem unmounting problem
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 13 08:10:01 PDT 1997
>Closed-Date:    Fri May 16 03:27:14 PDT 1997
>Last-Modified:  Fri May 16 03:28:56 PDT 1997
>Originator:     Takahiro Yugawa
>Release:        FreeBSD 2.2.1-RELEASE i386
>Organization:
personal FreeBSD user in Japan
>Environment:
	General FreeBSD environment with 'options MFS' enabled kernel.

>Description:
	When unmounting mfs like '# umount /tmp', 
	umount process searches for host 'mfs'.
	And if there is a host named 'mfs', an error will occur with
	umount command.
	If there isn't a host named 'mfs' but the host is configured to
	use name server, umount produces unnecessary network packet.

	In /usr/src/sbin/umount/umount.c, there is a function named 
	umountfs(). The argument to the function umountfs(), named 'name',
	is a file system name (which can see at the left most column 
	at the output of df command).
	Umountfs() searches '@' or ':' character in variable 'name' to see
	if it is a NFS or not. Since file system name for mfs is
	'mfs:[pid of mfs]', umountfs() thinks it is a NFS (because there is
	':' in it) and then searches for host named 'mfs' with
	gethostbyname() function.

>How-To-Repeat:
	First, prepare a kernel with 'options MFS' enabled.
	Then prepare a host named 'mfs'. The easiest way is to add 
	an alias 'mfs' to localhost(127.0.0.1) in /etc/hosts like, 

	127.0.0.1	localhost mfs

	Then mount mfs with mount_mfs command like,

	# mount_mfs -s 2048 /dev/wd0s2b /tmp

	And, then umount mfs with umount command like,

	# umount /tmp

	This umount process produces message like
        "Cannot MNT PRC: RPC: Program not registered."
	
	Or, give an IP address for host 'mfs'(actually it isn't exist),
	and do mounting & umounting as above produces message like
	"Cannot MNT PRC: RPC: Port mapper failure - RPC: Unable to send."

	In any cases, mfs will actually umounted, though.
>Fix:
	I think there are several ways to fix the problem.
	One of them is to change file system name for mfs to something
	like 'mfs![pid of mfs]', and not include a character '@' or ':'
	in it.
	I didn't do this because I wonder there may be some side effects.
	Another way and my solution is to change
	/usr/src/sbin/umount/umount.c like this.

*** umount.c.orig	Tue May 13 23:31:17 1997
--- umount.c	Tue May 13 23:31:40 1997
***************
*** 219,225 ****
  	if (!selected(type))
  		return (0);
  
! 	if ((delimp = strchr(name, '@')) != NULL) {
  		hostp = delimp + 1;
  		*delimp = '\0';
  		hp = gethostbyname(hostp);
--- 219,227 ----
  	if (!selected(type))
  		return (0);
  
! 	if (strstr( name, "mfs:" ) == name && isdigit(*(name+4))) {
! 		hp = NULL;
! 	} else if ((delimp = strchr(name, '@')) != NULL) {
  		hostp = delimp + 1;
  		*delimp = '\0';
  		hp = gethostbyname(hostp);

>Release-Note:
>Audit-Trail:

From: j@uriah.heep.sax.de (J Wunsch)
To: yugawa@orleans.rim.or.jp
Cc: FreeBSD-gnats-submit@freebsd.org, dfr@freebsd.org
Subject: Re: bin/3588: Memory Filesystem unmounting problem
Date: Fri, 16 May 1997 08:30:30 +0200

 As Takahiro Yugawa wrote:
 
 > *** umount.c.orig	Tue May 13 23:31:17 1997
 > --- umount.c	Tue May 13 23:31:40 1997
 > ***************
 > *** 219,225 ****
 >   	if (!selected(type))
 >   		return (0);
 >   
 > ! 	if ((delimp = strchr(name, '@')) != NULL) {
 >   		hostp = delimp + 1;
 >   		*delimp = '\0';
 >   		hp = gethostbyname(hostp);
 > --- 219,227 ----
 >   	if (!selected(type))
 >   		return (0);
 >   
 > ! 	if (strstr( name, "mfs:" ) == name && isdigit(*(name+4))) {
 > ! 		hp = NULL;
 > ! 	} else if ((delimp = strchr(name, '@')) != NULL) {
 >   		hostp = delimp + 1;
 >   		*delimp = '\0';
 >   		hp = gethostbyname(hostp);
 
 That's the wrong fix, IMHO.  Umounting other mount points that use the
 same syntax will still yield the same problem (e.g., amd writes a
 similar entry to mfs).
 
 Doug recently fixed some problem like:
 
 Index: /usr/src/sbin/umount/umount.c
 ===================================================================
 RCS file: /home/cvs/src/sbin/umount/umount.c,v
 retrieving revision 1.5
 retrieving revision 1.6
 diff -u -u -r1.5 -r1.6
 --- umount.c	1997/03/29 03:33:12	1.5
 +++ umount.c	1997/04/29 09:10:11	1.6
 @@ -219,12 +219,12 @@
  	if (!selected(type))
  		return (0);
  
 -	if ((delimp = strchr(name, '@')) != NULL) {
 +	if ((delimp = strchr(name, '@')) != NULL && type != MOUNT_UNION) {
  		hostp = delimp + 1;
  		*delimp = '\0';
  		hp = gethostbyname(hostp);
  		*delimp = '@';
 -	} else if ((delimp = strchr(name, ':')) != NULL) {
 +	} else if ((delimp = strchr(name, ':')) != NULL && type != MOUNT_UNION) {
  		*delimp = '\0';
  		hostp = name;
  		hp = gethostbyname(hostp);
 
 I think the logic should be reversed: only if the type is MOUNT_NFS,
 there should be a hostname lookup.  Everything else is local.
 
 -- 
 cheers, J"org
 
 joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
 Never trust an operating system you don't have sources for. ;-)

From: Doug Rabson <dfr@nlsystems.com>
To: Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>
Cc: yugawa@orleans.rim.or.jp, FreeBSD-gnats-submit@freebsd.org,
        dfr@freebsd.org
Subject: Re: bin/3588: Memory Filesystem unmounting problem
Date: Fri, 16 May 1997 08:39:51 +0100 (BST)

 On Fri, 16 May 1997, J Wunsch wrote:
 
 > [snip]
 >
 > That's the wrong fix, IMHO.  Umounting other mount points that use the
 > same syntax will still yield the same problem (e.g., amd writes a
 > similar entry to mfs).
 > 
 > Doug recently fixed some problem like:
 > 
 > [snip]
 > 
 > I think the logic should be reversed: only if the type is MOUNT_NFS,
 > there should be a hostname lookup.  Everything else is local.
 
 You're right.  I should have thought of that at the time.  I will fix it
 today.
 
 --
 Doug Rabson				Mail:  dfr@nlsystems.com
 Nonlinear Systems Ltd.			Phone: +44 181 951 1891
 
State-Changed-From-To: open->closed 
State-Changed-By: dfr 
State-Changed-When: Fri May 16 03:27:14 PDT 1997 
State-Changed-Why:  
Fixed in rev1.7 of umount.c. 
>Unformatted:
