ash: in tryexec(), ensure we don't try to run embedded scripts as applets
[oweals/busybox.git] / procps / nmeter.c
index 33de3790f83ec91c33ca91864b3ce60f3ffda2c1..166c8ab18e9c597932b82868ebbb6d46b6d07e87 100644 (file)
@@ -5,12 +5,11 @@
  *
  * Contact me: vda.linux@googlemail.com
  */
-
 //config:config NMETER
-//config:      bool "nmeter"
+//config:      bool "nmeter (10 kb)"
 //config:      default y
 //config:      help
-//config:        Prints selected system stats continuously, one line per update.
+//config:      Prints selected system stats continuously, one line per update.
 
 //applet:IF_NMETER(APPLET(nmeter, BB_DIR_USR_BIN, BB_SUID_DROP))
 
@@ -24,7 +23,7 @@
 //usage:     "\n -d MSEC       Milliseconds between updates, default:1000, none:-1"
 //usage:     "\n"
 //usage:     "\nFormat specifiers:"
-//usage:     "\n %Nc or %[cN]  CPU. N - bar size (default:10)"
+//usage:     "\n %Nc or %[cN]  CPU. N - bar size (default 10)"
 //usage:     "\n               (displays: S:system U:user N:niced D:iowait I:irq i:softirq)"
 //usage:     "\n %[nINTERFACE] Network INTERFACE"
 //usage:     "\n %m            Allocated memory"
@@ -53,6 +52,7 @@
 //  totalswap=134209536, freeswap=134209536, procs=157})
 
 #include "libbb.h"
+#include "common_bufsiz.h"
 
 typedef unsigned long long ullong;
 
@@ -108,16 +108,15 @@ struct globals {
 #define proc_meminfo       (G.proc_meminfo      )
 #define proc_diskstats     (G.proc_diskstats    )
 #define proc_sys_fs_filenr (G.proc_sys_fs_filenr)
+#define outbuf bb_common_bufsiz1
 #define INIT_G() do { \
+       setup_common_bufsiz(); \
        SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
        cur_outbuf = outbuf; \
        G.final_char = '\n'; \
        G.deltanz = G.delta = 1000000; \
 } while (0)
 
-// We depend on this being a char[], not char* - we take sizeof() of it
-#define outbuf bb_common_bufsiz1
-
 static inline void reset_outbuf(void)
 {
        cur_outbuf = outbuf;
@@ -140,7 +139,7 @@ static void print_outbuf(void)
 static void put(const char *s)
 {
        char *p = cur_outbuf;
-       int sz = outbuf + sizeof(outbuf) - p;
+       int sz = outbuf + COMMON_BUFSIZE - p;
        while (*s && --sz >= 0)
                *p++ = *s++;
        cur_outbuf = p;
@@ -148,7 +147,7 @@ static void put(const char *s)
 
 static void put_c(char c)
 {
-       if (cur_outbuf < outbuf + sizeof(outbuf))
+       if (cur_outbuf < outbuf + COMMON_BUFSIZE)
                *cur_outbuf++ = c;
 }