home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
lan
/
soss.arj
/
SRC
/
NETD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-04-11
|
3KB
|
140 lines
/*
* netd.c --
* Net daemon for PC NFS file server. It sets up and
* arbitrates the port mapper daemon, mount daemon and
* the NFS server.
*
* Author:
* See-Mong Tan, 6/11/88
* Modified by:
* Rich Braun, 3/29/91
*
* Revision history:
*
* $Log: netd.c_v $
* Revision 1.4 1991/04/11 20:39:04 richb
* Add -t option and use standard parser (getopt).
*
*/
#ifdef RCSID
static char _rcsid_ = "$Id: netd.c_v 1.4 1991/04/11 20:39:04 richb Exp $";
#endif
#include "common.h"
bool_t NFS_VERBOSE = FALSE; /* flag for nfs verbose mode */
bool_t NFS_READONLYFS = FALSE; /* true if started as a read only filesystem */
bool_t NFS_TRUNCATENAMES = FALSE; /* true if long names should be truncated */
main(argc, argv)
int argc;
char *argv[];
{
time_t now;
netd_init(argc, argv); /* initialize netd */
time (&now);
(void) printf("SOSS v%s %s (compiled %s)\n\nStarting net services at %s",
VERSION_NUM, VERSION_DATE, __DATE__, ctime (&now));
Netinit(800);
in_init();
IcmpInit();
GgpInit();
UdpInit();
/* initialize and register services */
if (! pmap_init())
netd_Punt("portmapper");
DBGPRT0 (nfsdebug, "netd: port mapper created");
if (! mountd_init())
netd_Punt("mount daemon");
DBGPRT0 (nfsdebug, "netd: mount daemon created");
if (! nfs_init())
netd_Punt("nfs server");
DBGPRT0 (nfsdebug, "netd: nfs server created");
if (! inode_init())
netd_Punt("inode interface");
if (! dtime_init())
netd_Punt("dos time interface");
(void) printf("netd: port mapper, mountd and nfs server running\n\n");
DBGPRT1 (nfsdebug, "Memory available = %d\n", _memavl());
(void) svc_run(); /* wait for and service net requests */
netd_Punt("net daemon returned");
}
/*
* void netd_Punt(char *s) --
* Prints net daemon error message and exits.
* For irrecoverable errors.
*/
void netd_Punt(s)
char *s;
{
int i;
(void) fprintf(stderr, "net daemon error: %s\n", s);
for(i = 0; i < 3; i++)
sock_close(i);
exit(1);
}
/*
* void netd_init(int argc, char **argv) --
* Initializes the net daemon. Should be called before any other
* routine in the server.
*/
void netd_init(argc, argv)
int argc;
char *argv[];
{
dbg_init ();
netd_parsecmdln(argc, argv); /* parse command line */
signal(SIGINT, netd_break); /* break handler */
}
/*
* void netd_break() --
* Break handler. Closes all sockets and exits.
*/
void netd_break()
{
int i;
(void) fprintf(stderr, "Netd: break caught... exiting\n");
for(i = 0; i < 3; i++)
sock_close(i);
exit(1);
}
/*
* void netd_parsecmdln(int argc, char **argv) --
* Parse command line arguments.
*/
void netd_parsecmdln(argc, argv)
int argc;
char *argv[];
{
int c;
extern int optind;
while ((c = getopt (argc, argv, "rtv")) != -1)
switch (c) {
case 'r': NFS_READONLYFS = TRUE; break;
case 't': NFS_TRUNCATENAMES = TRUE; break;
case 'v': NFS_VERBOSE = TRUE; break;
default: netd_Punt("Usage: soss [ -rtv ]");
}
if (optind < argc)
netd_Punt("Usage: soss [ -rtv ]");
}