Subject: bin/431: umount(1) doesn't return error codes properly
To: None <gnats-admin>
From: Mark Weaver <mhw@cs.brown.edu>
List: netbsd-bugs
Date: 08/22/1994 12:20:05
>Number:         431
>Category:       bin
>Synopsis:       umount(1) doesn't return error codes properly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   mhw
>Arrival-Date:   Mon Aug 22 12:20:03 1994
>Originator:     Mark Weaver
>Organization:
--------------------------------------------------------------------
Email: Mark_Weaver@brown.edu           | Brown University
PGP Key: finger mhw@cs.brown.edu       | Dept of Computer Science
>Release:        NetBSD 1.0_BETA (15-July-1994)
>Environment:

System: NetBSD cis-ts3-slip4.cis.brown.edu 1.0_BETA NetBSD 1.0_BETA (EXCELSIOR) #2: Mon Aug 22 00:02:40 EDT 1994 mhw@excelsior.cis.brown.edu:/usr/src/sys/arch/i386/compile/EXCELSIOR i386

>Description:
	umount(1) doesn't return error codes properly.  umountfs() in
	umount.c can't decide whether returning 0 or 1 signifies an
	error.  From looking at the last call to umountfs() from main(),
	it appears that 0 signifies an error.  From looking at where
	umountall() calls umountfs(), it appears that 1 signifies an
	error.  Within umountfs() itself, some errors cause 0 to be
	returned and some cause 1 to be returned.

	The majority of the code seems to think that 1 signifies an error,
	and that is consistent with umountall() as well, so I decided to
	go with that.

>How-To-Repeat:

	umount ....
	echo $?

	notice that even though the umount succeeded and didn't print an
	error, that the result code is 1.

>Fix:
diff -c  src/sbin/umount/umount.c.mhw1 src/sbin/umount/umount.c
*** src/sbin/umount/umount.c.mhw1	Thu Jun  9 06:11:44 1994
--- src/sbin/umount/umount.c	Mon Aug 22 01:14:35 1994
***************
*** 129,135 ****
  		errs = umountall();
  	} else
  		for (errs = 0; *argv != NULL; ++argv)
! 			if (umountfs(*argv) == 0)
  				errs = 1;
  	exit(errs);
  }
--- 129,135 ----
  		errs = umountall();
  	} else
  		for (errs = 0; *argv != NULL; ++argv)
! 			if (umountfs(*argv))
  				errs = 1;
  	exit(errs);
  }
***************
*** 186,192 ****
  
  	if (realpath(name, rname) == NULL) {
  		warn("%s", rname);
! 		return (0);
  	}
  
  	name = rname;
--- 186,192 ----
  
  	if (realpath(name, rname) == NULL) {
  		warn("%s", rname);
! 		return (1);
  	}
  
  	name = rname;
***************
*** 214,220 ****
  	}
  
  	if (!selected(type))
! 		return (0);
  
  	if ((delimp = strchr(name, '@')) != NULL) {
  		hostp = delimp + 1;
--- 214,220 ----
  	}
  
  	if (!selected(type))
! 		return (1);
  
  	if ((delimp = strchr(name, '@')) != NULL) {
  		hostp = delimp + 1;
***************
*** 230,236 ****
  	} else
  		hp = NULL;
  	if (!namematch(hp))
! 		return (0);
  
  	if (vflag)
  		(void)printf("%s: unmount from %s\n", name, mntpt);
--- 230,236 ----
  	} else
  		hp = NULL;
  	if (!namematch(hp))
! 		return (1);
  
  	if (vflag)
  		(void)printf("%s: unmount from %s\n", name, mntpt);
>Audit-Trail:
>Unformatted:


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