blob: f3b7fc0c89e496f62aac2c94ffa7d7df71815d69 [file] [log] [blame]
Eric Andersencc8ed391999-10-05 16:24:54 +00001#include "internal.h"
2#include <linux/unistd.h>
3
4const char update_usage[] = "update\n"
5"\n"
6"\tFlush buffered data to the disk devices every 30 seconds.\n";
7
8#if defined(__GLIBC__)
9#include <sys/kdaemon.h>
10#else
11_syscall2(int, bdflush, int, func, int, data);
12#endif /* __GLIBC__ */
13
14extern int
15update_main(struct FileInfo * i, int argc, char * * argv)
16{
17 /*
18 * Update is actually two daemons, bdflush and update.
19 */
20 int pid;
21
22 pid = fork();
23 if ( pid < 0 )
24 return pid;
25 else if ( pid == 0 ) {
26 /*
27 * This is no longer necessary since 1.3.5x, but it will harmlessly
28 * exit if that is the case.
29 */
30 strcpy(argv[0], "bdflush (update)");
31 argv[1] = 0;
32 argv[2] = 0;
33 bdflush(1, 0);
34 _exit(0);
35 }
36 pid = fork();
37 if ( pid < 0 )
38 return pid;
39 else if ( pid == 0 ) {
40 argv[0] = "update";
41 for ( ; ; ) {
42 sync();
43 sleep(30);
44 }
45 }
46
47 return 0;
48}