[comp.sys.hp] setmntent problem

jtb@cs.edinburgh.ac.uk (Jo Blishen) (03/15/91)

I am experiencing an intermittent problem when running AMD 5.2 on a
HP9000/375 under HP-UX version 7.0.  AMD reports the following errors:

setmntent ("/etc/mnttab","a") permission denied
couldn't find how to unmount /a/server/whichever/partition...

It seems that AMD is failing to add a record of a new NFS mount to the 
mount table.  AMD then fails to unmount this NFS-mounted partition at some
time later on and so I end up in an inconsistent state with a partition 
mounted and no record of it.  This leads to further errors when someone
tries to use that partition again as it is already NFS-mounted and I get
"device busy" messages.

Has anyone else seen this?  Has anyone else fixed this already?  Is there
any known problem with "setmntent" - it seems to me that it shouldn't
be giving "permission denied" messages to a program running as root
trying to append to /etc/mnttab?

Jo
-- 
Jo Blishen                         JANET: jtb@uk.ac.ed.lfcs
LFCS, Dept. of Computer Science    UUCP:  ..!mcvax!ukc!lfcs!jtb
University of Edinburgh            ARPA:  jtb%lfcs.ed.ac.uk@nsfnet-relay.ac.uk
Edinburgh EH9 3JZ, UK.             Tel:   031-650-5192

mark@comp.vuw.ac.nz (Mark Davies) (03/19/91)

In article <7760@skye.cs.ed.ac.uk>, jtb@cs.edinburgh.ac.uk (Jo Blishen) writes:
|> I am experiencing an intermittent problem when running AMD 5.2 on a
|> HP9000/375 under HP-UX version 7.0.  AMD reports the following errors:

|> setmntent ("/etc/mnttab","a") permission denied
|> couldn't find how to unmount /a/server/whichever/partition...

|> Has anyone else seen this?  Has anyone else fixed this already?  Is there
|> any known problem with "setmntent" - it seems to me that it shouldn't
|> be giving "permission denied" messages to a program running as root
|> trying to append to /etc/mnttab?

Yes I've seen this.  HP's setmntent() is seriously broken. The mnttab
routines do not correctly lock the mnttab file.  I would have to scratch
around for the details as it was 6 months ago I was playing with this
but I think the following patch to amd got around the problem:

*** mtab_file.c~	Sun Jun 24 09:17:07 1990
--- mtab_file.c	Wed Sep 26 22:57:01 1990
***************
*** 207,213 ****
  			plog(XLOG_ERROR, "Couldn't write %s: %m", mtab);
  		endmntent(mfp);
  	} else {
! 		if (errno == ENFILE && retries < NFILE_RETRIES) {
  			sleep(1);
  			goto enfile;
  		}
--- 207,215 ----
  			plog(XLOG_ERROR, "Couldn't write %s: %m", mtab);
  		endmntent(mfp);
  	} else {
! 		if (errno == EACCES || errno == EAGAIN) {
! 			goto enfile;
! 		} else if (errno == ENFILE && retries < NFILE_RETRIES) {
  			sleep(1);
  			goto enfile;
  		}

You will also probably get problems with "df" failing on occassion (if
its trying to read the mnttab while amd is updating it).  This is the
same problem and we fixed it here by replacing df with our own copy.

cheers
mark

longstre@erb1.engr.wisc.edu (Jon C. Longstreth) (03/21/91)

On the subject of AMD, can someone please tell me where I can get
the source or binaries for this beastie?


   ////////        //\\        \\\\\\\\\\  :: Jon Longstreth
  ////////        ///\\\        \\\\\\\\\\ :: longstre@cae.wisc.edu
 ////            ////\\\\        \\E\      :: longstre@engr.wisc.edu
////            ////  \\A\        \\n\\\   :: University Wisconsin Madison
\\C\           //////\\\\i\       //g///   :: Pick a quote:
 \\o\         ///////\\\\\d\     //i/      ::    1). a Deo et Rege  
  \\m\\\\\   ////        \\e\   //n/////// ::    2). GGGRRROOOWWWWL!
   \\puter\ ////          \\d\ //eering//  ::    3). Yeah, life is like that.