[comp.protocols.nfs] When NFS fails

jdeitch@jadpc.cts.com (Jim Deitch) (04/30/91)

Does anyone have sample source for a program that checks to see if an
NFS mounted drive is valid?

What I need is a way to check to make sure that the server is alive
and that I can read/write the drive from PC-NFS.  I am writing an
automated system that will be reading/writing an NFS mounted drive
from about 2000 miles away.  If the NFS mounted drive is not valid for
any reason I can't have the machine sit there saying Abort, Retry or
Ignore.

Any help or suggestions would be GREATLY appreceiated.

Jim

-- 
ARPANET:    jadpc!jdeitch@nosc.mil
INTERNET:   jdeitch@jadpc.cts.com
UUCP:	    nosc!jadpc!jdeitch

geoff@hinode.East.Sun.COM (Geoff Arnold @ Sun BOS - R.H. coast near the top) (05/01/91)

Quoth jdeitch@jadpc.cts.com (Jim Deitch) (in <1991Apr30.165109.23950@jadpc.cts.com>):
#Does anyone have sample source for a program that checks to see if an
#NFS mounted drive is valid?
#
#What I need is a way to check to make sure that the server is alive
#and that I can read/write the drive from PC-NFS.  I am writing an
#automated system that will be reading/writing an NFS mounted drive
#from about 2000 miles away.  If the NFS mounted drive is not valid for
#any reason I can't have the machine sit there saying Abort, Retry or
#Ignore.

The way to think of this is to pretend the NFS drive is a diskette: the
problem is analogous to determining whether or not there's a diskette in
the drive before you access it. The solution for both is to write
an INT24H critical error handler. The DOS Tech Ref defines how you
should do this: what the stack frame looks like, and so forth. To avoid
the user "Abort, Retry, Fail" dialogue, your handler can simply set AL
to the desired value and IRET back to PC-NFS, which will take the
appropriate action. None of this is PC-NFS specific. 

Geoff

-- Geoff Arnold, PC-NFS architect, Sun Microsystems. (geoff@East.Sun.COM)   --
------------------------------------------------------------------------------
--     Sun Microsystems PC Distributed Systems ...                          --
--            ... soon to be a part of SunTech (stay tuned for details)     --

ted@arsocomvax.socom.mil (Ted Nolan) (05/01/91)

In article <1991Apr30.165109.23950@jadpc.cts.com> jdeitch@jadpc.cts.com (Jim Deitch) writes:
>Does anyone have sample source for a program that checks to see if an
>NFS mounted drive is valid?
>

We have used this from time to time, and it seems to work.  As presented,
it is intended to set the DOS errorlevel for batch file use, but it could
easily be incorporated into a larger program.  I think it was written in
MIX Power C, but probably Turbo or MS would work also:



#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <sys\stat.h>

int dstatus = 0;

main(int argc, char **argv)
{
	int harderror(int error, int ax, int bp, int si);
	char path[15];
	struct stat statbuf;

	if( argc != 2) {
		fprintf(stderr,"Usage %s  d\n",argv[0]);
		fprintf(stderr,"Where d is a drive letter\n");
		exit(1);
	}

	sprintf(path,"%s:\\foo\\bar",argv[1]);

	harderr(harderror);
	(void) stat(path,&statbuf);

	exit(dstatus);
}

int harderror(int error, int ax, int bp, int si)
{
	dstatus = 1;
	hardresume(0);
}

rcstack@rwa.urc.tue.nl (Studenten Vereniging Stack) (05/01/91)

In article <1991Apr30.221106.8559@usasoc.soc.mil> ted@usasoc.soc.mil (Ted Nolan) writes:
>We have used this from time to time, and it seems to work. 

Or: use: shell=command.com /p /e:1024 /f in your config.sys.
                                      ^^
This is an undocumented switch which, at least in dos 3.30 and 4.01 causes
dos to generate a Fail on any critical error. We use this on our BBS and it
works just fine.

-Harry
-- 
=============================================================================
Email: Internet: rcstack@urc.tue.nl              Bitnet: rcstack1@heitue5
Computer Association STACK, Computing Centre RC 1.82,
Eindhoven University of Technology, POBox 513, 5600 MB Eindhoven, Holland.

jdeitch@jadpc.cts.com (Jim Deitch) (05/07/91)

In article <578@rc6.urc.tue.nl> rcstack@urc.tue.nl writes:
>In article <1991Apr30.221106.8559@usasoc.soc.mil> ted@usasoc.soc.mil (Ted Nolan) writes:
>>We have used this from time to time, and it seems to work. 
>
>Or: use: shell=command.com /p /e:1024 /f in your config.sys.
>                                      ^^
>This is an undocumented switch which, at least in dos 3.30 and 4.01 causes
>dos to generate a Fail on any critical error. We use this on our BBS and it
>works just fine.
>

It does work, but I need to return an error to the process.  Does this
do that?

Jim
-- 
ARPANET:    jadpc!jdeitch@nosc.mil
INTERNET:   jdeitch@jadpc.cts.com
UUCP:	    nosc!jadpc!jdeitch