initialize inode and directory buffer pointers for each run
[unix-history] / usr / src / sbin / nfsiod / nfsiod.c
CommitLineData
15791df4
KM
1/*
2 * Copyright (c) 1989 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the University of California, Berkeley. The name of the
14 * University may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 */
20
21#ifndef lint
22char copyright[] =
23"@(#) Copyright (c) 1989 Regents of the University of California.\n\
24 All rights reserved.\n";
25#endif not lint
26
27#ifndef lint
8fbf001c 28static char sccsid[] = "@(#)nfsiod.c 5.2 (Berkeley) %G%";
15791df4
KM
29#endif not lint
30
31#include <stdio.h>
15791df4
KM
32#include <signal.h>
33#include <fcntl.h>
34#include <sys/types.h>
35#include <sys/ioctl.h>
36
37/* Global defs */
38#ifdef DEBUG
15791df4
KM
39int debug = 1;
40#else
41int debug = 0;
42#endif
43
44/*
8fbf001c
KM
45 * Nfsiod does asynchronous buffered I/O on behalf of the NFS client.
46 * It does not have to be running for correct operation, but will improve
47 * throughput. The one optional argument is the number of children to fork.
15791df4
KM
48 */
49main(argc, argv)
50 int argc;
51 char *argv[];
52{
53 register int i;
54 int cnt;
55
56 if (debug == 0) {
57 if (fork())
58 exit(0);
59 { int s;
60 for (s = 0; s < 10; s++)
61 (void) close(s);
62 }
63 (void) open("/", O_RDONLY);
64 (void) dup2(0, 1);
65 (void) dup2(0, 2);
66 { int tt = open("/dev/tty", O_RDWR);
67 if (tt > 0) {
68 ioctl(tt, TIOCNOTTY, (char *)0);
69 close(tt);
70 }
71 }
72 (void) setpgrp(0, 0);
73 signal(SIGTSTP, SIG_IGN);
74 signal(SIGTTIN, SIG_IGN);
75 signal(SIGTTOU, SIG_IGN);
76 signal(SIGINT, SIG_IGN);
77 signal(SIGQUIT, SIG_IGN);
78 signal(SIGTERM, SIG_IGN);
79 signal(SIGHUP, SIG_IGN);
80 }
15791df4
KM
81 if (argc != 2 || (cnt = atoi(argv[1])) <= 0 || cnt > 20)
82 cnt = 1;
83 for (i = 1; i < cnt; i++)
84 if (fork() == 0)
85 break;
8fbf001c
KM
86 async_daemon(); /* Never returns */
87 exit(1);
15791df4 88}