1 /* vi: set sw=4 ts=4: */
3 * Mini update implementation for busybox; much pasted from update-2.11
6 * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
7 * Copyright (c) 1996, 1997, 1999 Torsten Poulin.
8 * Copyright (c) 2000 by Karl M. Hegbloom <karlheg@debian.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/unistd.h>
28 #include <sys/param.h>
29 #include <sys/syslog.h>
31 #if defined(__GLIBC__)
32 #include <sys/kdaemon.h>
34 _syscall2(int, bdflush, int, func, int, data);
35 #endif /* __GLIBC__ */
37 static char update_usage[] =
39 #ifndef BB_FEATURE_TRIVIAL_HELP
40 "\nPeriodically flushes filesystem buffers.\n\n"
42 "\t-S\tforce use of sync(2) instead of flushing\n"
43 "\t-s SECS\tcall sync this often (default 30)\n"
44 "\t-f SECS\tflush some buffers this often (default 5)\n"
48 static unsigned int sync_duration = 30;
49 static unsigned int flush_duration = 5;
50 static int use_sync = 0;
52 extern int update_main(int argc, char **argv)
58 while (argc>0 && **argv == '-') {
65 if (--argc < 1) usage(update_usage);
66 sync_duration = atoi(*(++argv));
69 if (--argc < 1) usage(update_usage);
70 flush_duration = atoi(*(++argv));
84 /* Become a proper daemon */
87 for (pid = 0; pid < OPEN_MAX; pid++) close(pid);
90 * This is no longer necessary since 1.3.5x, but it will harmlessly
91 * exit if that is the case.
93 argv[0] = "bdflush (update)";
101 sleep(flush_duration);
102 if (bdflush(1, 0) < 0) {
103 openlog("update", LOG_CONS, LOG_DAEMON);
105 "This kernel does not need update(8). Exiting.");
117 c-file-style: "linux"