Fixed definitions.

BR,
Darius


Index: Busybox/include/usage.h
===================================================================
--- Busybox.orig/include/usage.h
+++ Busybox/include/usage.h
@@ -2661,6 +2661,7 @@
        "       [a]sync         Writes are asynchronous / synchronous\n" \
        "       [no]atime       Disable / enable updates to inode access 
times\n" \
        "       [no]diratime    Disable / enable atime updates to 
directories\n" \
+       "       [no]relatime    Disable / enable atime updates relative to 
modification time\n" \
        "       [no]dev         Allow use of special device files / disallow 
them\n" \
        "       [no]exec        Allow use of executable files / disallow 
them\n" \
        "       [no]suid        Allow set-user-id-root programs / disallow 
them\n" \
@@ -2924,13 +2925,13 @@
      "\n       -u      Unlock (re-enable) account" \
 
 #define chpasswd_trivial_usage \
-       USE_GETOPT_LONG("[--md5|--encrypt]") SKIP_GETOPT_LONG("[-m|-e]")
+       USE_GETOPT_LONG("[--md5|--encrypted]") SKIP_GETOPT_LONG("[-m|-e]")
 #define chpasswd_full_usage "\n\n" \
-       "Read user:password information from stdin\n" \
+       "Read user:password information from stdin " \
        "and update /etc/passwd accordingly.\n" \
      "\nOptions:" \
        USE_GETOPT_LONG( \
-     "\n       -e,--encrypt    Supplied passwords are in encrypted form" \
+     "\n       -e,--encrypted  Supplied passwords are in encrypted form" \
      "\n       -m,--md5        Use MD5 encryption instead of DES" \
        ) \
        SKIP_GETOPT_LONG( \
@@ -3943,9 +3944,9 @@
        "nameserver 10.0.0.1\n"
 
 #define tar_trivial_usage \
-       "-[" USE_FEATURE_TAR_CREATE("c") USE_FEATURE_TAR_GZIP("z") \
-       USE_FEATURE_TAR_BZIP2("j") USE_FEATURE_TAR_LZMA("a") \
-       USE_FEATURE_TAR_COMPRESS("Z") "xtvO] " \
+       "-[" USE_FEATURE_TAR_CREATE("c") USE_FEATURE_SEAMLESS_GZ("z") \
+       USE_FEATURE_SEAMLESS_BZ2("j") USE_FEATURE_SEAMLESS_LZMA("a") \
+       USE_FEATURE_SEAMLESS_Z("Z") "xtvO] " \
        USE_FEATURE_TAR_FROM("[-X FILE] ") \
        "[-f TARFILE] [-C DIR] [FILE(s)]..."
 #define tar_full_usage "\n\n" \
@@ -3956,16 +3957,16 @@
      "\n       x       Extract" \
      "\n       t       List" \
      "\nArchive format selection:" \
-       USE_FEATURE_TAR_GZIP( \
+       USE_FEATURE_SEAMLESS_GZ( \
      "\n       z       Filter the archive through gzip" \
        ) \
-       USE_FEATURE_TAR_BZIP2( \
+       USE_FEATURE_SEAMLESS_BZ2( \
      "\n       j       Filter the archive through bzip2" \
        ) \
-       USE_FEATURE_TAR_LZMA( \
+       USE_FEATURE_SEAMLESS_LZMA( \
      "\n       a       Filter the archive through lzma" \
        ) \
-       USE_FEATURE_TAR_COMPRESS( \
+       USE_FEATURE_SEAMLESS_Z( \
      "\n       Z       Filter the archive through compress" \
        ) \
      "\nFile selection:" \
@@ -4497,11 +4498,12 @@
        "Mon Dec 17 10:31:44 GMT 2000"
 
 #define watchdog_trivial_usage \
-       "[-t N[ms]] [-F] DEV"
+       "[-t N[ms]] [-T] [-F] DEV"
 #define watchdog_full_usage "\n\n" \
        "Periodically write to watchdog device DEV\n" \
      "\nOptions:" \
-     "\n       -t N    Timer period (default 30)" \
+     "\n       -t N    Userspace timer period (default 30)" \
+     "\n       -T N    Hardware WD timer period (default 60)" \
      "\n       -F      Run in foreground" \
      "\n" \
      "\nUse -t 500ms to specify period in milliseconds" \
Index: Busybox/miscutils/watchdog.c
===================================================================
--- Busybox.orig/miscutils/watchdog.c
+++ Busybox/miscutils/watchdog.c
@@ -4,14 +4,17 @@
  *
  * Copyright (C) 2003  Paul Mundt <[EMAIL PROTECTED]>
  * Copyright (C) 2006  Bernhard Fischer <[email protected]>
+ * Copyright (C) 2008  Darius Augulis <[EMAIL PROTECTED]>
  *
  * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
  */
 
 #include "libbb.h"
+#include "linux/watchdog.h"
 
-#define OPT_FOREGROUND 0x01
-#define OPT_TIMER      0x02
+#define OPT_FOREGROUND  (1<<0)
+#define OPT_STIMER             (1<<1)
+#define OPT_HTIMER             (1<<2)
 
 static void watchdog_shutdown(int sig UNUSED_PARAM)
 {
@@ -27,37 +30,40 @@ int watchdog_main(int argc, char **argv)
 int watchdog_main(int argc, char **argv)
 {
        unsigned opts;
-       unsigned timer_duration = 30000; /* Userspace timer duration, in 
milliseconds */
-       char *t_arg;
+       unsigned stimer_duration = 30000; /* Userspace timer duration, in 
milliseconds */
+       unsigned htimer_duration = 60000; /* Hardware WD timer duration, in 
milliseconds */
+       char *st_arg;   /* Software timer */
+       char *ht_arg;   /* Hardware Watchdog timer */
 
        opt_complementary = "=1"; /* must have 1 argument */
-       opts = getopt32(argv, "Ft:", &t_arg);
+       opts = getopt32(argv, "Ft:T:", &st_arg, &ht_arg);
 
-       if (opts & OPT_TIMER) {
+       if (opts & OPT_STIMER) {
                static const struct suffix_mult suffixes[] = {
                        { "ms", 1 },
                        { "", 1000 },
                        { }
                };
-               timer_duration = xatou_sfx(t_arg, suffixes);
+               stimer_duration = xatou_sfx(st_arg, suffixes);
        }
 
-       if (!(opts & OPT_FOREGROUND)) {
-               bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv);
-       }
+       if (opts & OPT_HTIMER)
+               htimer_duration = xatou16(ht_arg);
 
        bb_signals(BB_FATAL_SIGS, watchdog_shutdown);
 
        /* Use known fd # - avoid needing global 'int fd' */
        xmove_fd(xopen(argv[argc - 1], O_WRONLY), 3);
 
-// TODO?
-//     if (!(opts & OPT_TIMER)) {
-//             if (ioctl(fd, WDIOC_GETTIMEOUT, &timer_duration) == 0)
-//                     timer_duration *= 500;
-//             else
-//                     timer_duration = 30000;
-//     }
+       ioctl_or_warn(3, WDIOC_SETTIMEOUT, &htimer_duration);
+       ioctl_or_warn(3, WDIOC_GETTIMEOUT, &htimer_duration);
+
+       printf("watchdog: SW timer is %dms, HW timer is %dms\n",
+               stimer_duration, htimer_duration * 1000);
+
+       if (!(opts & OPT_FOREGROUND)) {
+               bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv);
+       }
 
        while (1) {
                /*
@@ -65,7 +71,7 @@ int watchdog_main(int argc, char **argv)
                 * is undefined at this point -- PFM
                 */
                write(3, "", 1); /* write zero byte */
-               usleep(timer_duration * 1000L);
+               usleep(stimer_duration * 1000L);
        }
        return EXIT_SUCCESS; /* - not reached, but gcc 4.2.1 is too dumb! */
 }
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to