starner@ISF.Unisys.COM (Mark Starner) (06/26/91)
I am trying to determine a way to tell if PC-NFS is running from within a C program... I have the Programmers Toolkit, but none of the functions return if NFS is running... they all print a message and exit, so i have no status code to check... if anyone has any thoughts on this, i would greatly appreciate it! Thanks ------------- Mark Starner Unisys Corporation/Integration Support Facility starner@isf.unisys.com -- ------------- Mark Starner Unisys Corporation/Integration Support Facility starner@isf.unisys.com
geoff@bodleian.East.Sun.COM (Geoff Arnold @ Sun BOS - R.H. coast near the top) (06/27/91)
Quoth starner@ISF.Unisys.COM (Mark Starner) (in <19@hpwisf1.ISF.Unisys.COM>):
#I am trying to determine a way to tell if PC-NFS is running
#from within a C program... I have the Programmers Toolkit, but
#none of the functions return if NFS is running... they all
#print a message and exit, so i have no status code to check...
The following code fragment does the job:
#include <dos.h>
/* abstracted from xioctl.h */
#define IOCTL_FUNC 0x44
#define IOCTL_SPECIAL_BASE 0x0E0
#define IOCTL_READ_8 IOCTL_SPECIAL_BASE + 0
#define X_GET_NFS_INFO 20
/*
* Extended IOCTL parameter block structure
*/
struct ipb_struc {
unsigned char ipb_key; /* key for X_ioctl calls */
unsigned char ipb_func; /* extended func number */
unsigned int ipb_offset; /* offset for data */
unsigned int ipb_segment; /* segment for data */
unsigned int ipb_count;
unsigned int ipb_pointer;
unsigned int ipb_nat_index;
};
/* end of xioctl.h extract */
static int we_already_found_it = 0;
pc_nfs_has_been_installed()
{
/*
* This routine uses the X_GET_NFS_INFO ioctl to see if PC-NFS has
* been installed
*/
struct ipb_struc ipb;
union REGS inregs, outregs;
struct SREGS segregs;
char far *p;
if(we_already_found_it)
return(1);
inregs.h.ah = IOCTL_FUNC;
inregs.h.al = IOCTL_READ_8;
ipb.ipb_func = X_GET_NFS_INFO;
segread (&segregs);
p = (char far *) &ipb;
inregs.x.dx = FP_OFF (p);
segregs.ds = FP_SEG (p);
intdosx (&inregs, &outregs, &segregs);
we_already_found_it = !(outregs.x.cflag);
return(we_already_found_it);
}
Warning: don't make any assumptions about any other IOCTL_SPECIAL's.
Geoff
--Geoff Arnold, PC-NFS architect(geoff@East.Sun.COM or geoff.arnold@Sun.COM)--
------------------------------------------------------------------------------
-- Sun Technology Enterprises : PC Networking group --
-- (officially from July 1, but effectively in place right now) --