BSD 4_3_Tahoe release
[unix-history] / usr / src / etc / update.c
CommitLineData
9f49a1fa
KB
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
ca67e7b4 8static char sccsid[] = "@(#)update.c 4.3 (Berkeley) 3/28/87";
9f49a1fa
KB
9#endif
10
a675940b
BJ
11/*
12 * Update the file system every 30 seconds.
13 * For cache benefit, open certain system directories.
14 */
15
9f49a1fa
KB
16#include <sys/time.h>
17#include <sys/file.h>
18#include <sys/signal.h>
19#include <syslog.h>
20#include <stdio.h>
a675940b
BJ
21
22char *fillst[] = {
23 "/bin",
9f40bd24 24 "/lib",
a675940b
BJ
25 "/usr",
26 "/usr/bin",
9f40bd24
BJ
27 "/usr/lib",
28 "/usr/ucb",
a675940b
BJ
29 0,
30};
31
32main()
33{
9f49a1fa
KB
34 struct itimerval value;
35 register char **f;
36 extern int sync();
a675940b 37
9f49a1fa 38 if (fork())
a675940b 39 exit(0);
9f49a1fa
KB
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 (;;)
a675940b 54 pause();
9f49a1fa 55 /*NOTREACHED*/
a675940b 56}