diff options
Diffstat (limited to 'update.c')
-rw-r--r-- | update.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/update.c b/update.c new file mode 100644 index 000000000..f3b7fc0c8 --- /dev/null +++ b/update.c | |||
@@ -0,0 +1,48 @@ | |||
1 | #include "internal.h" | ||
2 | #include <linux/unistd.h> | ||
3 | |||
4 | const 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 | |||
14 | extern int | ||
15 | update_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 | } | ||