xref: /original-bsd/usr.sbin/update/update.c (revision a4d3ae46)
1 /*
2  * Copyright (c) 1987 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  */
6 
7 #ifndef lint
8 static char sccsid[] = "@(#)update.c	4.3 (Berkeley) 03/28/87";
9 #endif
10 
11 /*
12  * Update the file system every 30 seconds.
13  * For cache benefit, open certain system directories.
14  */
15 
16 #include <sys/time.h>
17 #include <sys/file.h>
18 #include <sys/signal.h>
19 #include <syslog.h>
20 #include <stdio.h>
21 
22 char *fillst[] = {
23 	"/bin",
24 	"/lib",
25 	"/usr",
26 	"/usr/bin",
27 	"/usr/lib",
28 	"/usr/ucb",
29 	0,
30 };
31 
32 main()
33 {
34 	struct itimerval	value;
35 	register char	**f;
36 	extern int	sync();
37 
38 	if (fork())
39 		exit(0);
40 	(void)close(0);
41 	(void)close(1);
42 	(void)close(2);
43 	for (f = fillst; *f; f++)
44 		(void)open(*f, O_RDONLY, 0);
45 	(void)signal(SIGALRM, sync);
46 	value.it_interval.tv_sec = 30;
47 	value.it_interval.tv_usec = 0;
48 	value.it_value = value.it_interval;
49 	if (setitimer(ITIMER_REAL, &value, (struct itimerval *)NULL)) {
50 		perror("update: setitimer");
51 		exit(1);
52 	}
53 	for (;;)
54 		pause();
55 	/*NOTREACHED*/
56 }
57