X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=init%2Fbootchartd.c;h=b5dd174399bdb6e57e0c81187c36808e284ddb66;hb=f3fa86525850620d31e48a742a25fd4965b1dba2;hp=9fd62335782d7f4570e0e2bf97eeb9b5e702ebcc;hpb=c158601d50c2fab56ed0043989ba83fa9cd7f96a;p=oweals%2Fbusybox.git diff --git a/init/bootchartd.c b/init/bootchartd.c index 9fd623357..b5dd17439 100644 --- a/init/bootchartd.c +++ b/init/bootchartd.c @@ -8,45 +8,46 @@ //kbuild:lib-$(CONFIG_BOOTCHARTD) += bootchartd.o //config:config BOOTCHARTD -//config: bool "bootchartd" +//config: bool "bootchartd (10 kb)" //config: default y //config: help -//config: bootchartd is commonly used to profile the boot process -//config: for the purpose of speeding it up. In this case, it is started -//config: by the kernel as the init process. This is configured by adding -//config: the init=/sbin/bootchartd option to the kernel command line. +//config: bootchartd is commonly used to profile the boot process +//config: for the purpose of speeding it up. In this case, it is started +//config: by the kernel as the init process. This is configured by adding +//config: the init=/sbin/bootchartd option to the kernel command line. //config: -//config: It can also be used to monitor the resource usage of a specific -//config: application or the running system in general. In this case, -//config: bootchartd is started interactively by running bootchartd start -//config: and stopped using bootchartd stop. +//config: It can also be used to monitor the resource usage of a specific +//config: application or the running system in general. In this case, +//config: bootchartd is started interactively by running bootchartd start +//config: and stopped using bootchartd stop. //config: //config:config FEATURE_BOOTCHARTD_BLOATED_HEADER //config: bool "Compatible, bloated header" //config: default y //config: depends on BOOTCHARTD //config: help -//config: Create extended header file compatible with "big" bootchartd. -//config: "Big" bootchartd is a shell script and it dumps some -//config: "convenient" info int the header, such as: -//config: title = Boot chart for `hostname` (`date`) -//config: system.uname = `uname -srvm` -//config: system.release = `cat /etc/DISTRO-release` -//config: system.cpu = `grep '^model name' /proc/cpuinfo | head -1` ($cpucount) -//config: system.kernel.options = `cat /proc/cmdline` -//config: This data is not mandatory for bootchart graph generation, -//config: and is considered bloat. Nevertheless, this option -//config: makes bootchartd applet to dump a subset of it. +//config: Create extended header file compatible with "big" bootchartd. +//config: "Big" bootchartd is a shell script and it dumps some +//config: "convenient" info int the header, such as: +//config: title = Boot chart for `hostname` (`date`) +//config: system.uname = `uname -srvm` +//config: system.release = `cat /etc/DISTRO-release` +//config: system.cpu = `grep '^model name' /proc/cpuinfo | head -1` ($cpucount) +//config: system.kernel.options = `cat /proc/cmdline` +//config: This data is not mandatory for bootchart graph generation, +//config: and is considered bloat. Nevertheless, this option +//config: makes bootchartd applet to dump a subset of it. //config: //config:config FEATURE_BOOTCHARTD_CONFIG_FILE //config: bool "Support bootchartd.conf" //config: default y //config: depends on BOOTCHARTD //config: help -//config: Enable reading and parsing of $PWD/bootchartd.conf -//config: and /etc/bootchartd.conf files. +//config: Enable reading and parsing of $PWD/bootchartd.conf +//config: and /etc/bootchartd.conf files. #include "libbb.h" +#include "common_bufsiz.h" /* After libbb.h, since it needs sys/types.h on some systems */ #include @@ -60,6 +61,12 @@ # endif #endif +#if !ENABLE_TAR && !ENABLE_WERROR +# warning Note: bootchartd requires tar command, but you did not select it. +#elif !ENABLE_FEATURE_SEAMLESS_GZ && !ENABLE_WERROR +# warning Note: bootchartd requires tar -z support, but you did not select it. +#endif + #define BC_VERSION_STR "0.8" /* For debugging, set to 0: @@ -109,8 +116,8 @@ struct globals { char jiffy_line[COMMON_BUFSIZE]; } FIX_ALIASING; -#define G (*(struct globals*)&bb_common_bufsiz1) -#define INIT_G() do { } while (0) +#define G (*(struct globals*)bb_common_bufsiz1) +#define INIT_G() do { setup_common_bufsiz(); } while (0) static void dump_file(FILE *fp, const char *filename) { @@ -164,7 +171,9 @@ static int dump_procs(FILE *fp, int look_for_login_process) p++; strchrnul(p, ')')[0] = '\0'; /* Is it gdm, kdm or a getty? */ - if (((p[0] == 'g' || p[0] == 'k' || p[0] == 'x') && p[1] == 'd' && p[2] == 'm') + if (((p[0] == 'g' || p[0] == 'k' || p[0] == 'x') + && p[1] == 'd' && p[2] == 'm' && p[3] == '\0' + ) || strstr(p, "getty") ) { found_login_process = 1; @@ -183,11 +192,11 @@ static char *make_tempdir(void) if (!tempdir) { #ifdef __linux__ /* /tmp is not writable (happens when we are used as init). - * Try to mount a tmpfs, them cd and lazily unmount it. + * Try to mount a tmpfs, then cd and lazily unmount it. * Since we unmount it at once, we can mount it anywhere. * Try a few locations which are likely ti exist. */ - static const char dirs[] = "/mnt\0""/tmp\0""/boot\0""/proc\0"; + static const char dirs[] ALIGN1 = "/mnt\0""/tmp\0""/boot\0""/proc\0"; const char *try_dir = dirs; while (mount("none", try_dir, "tmpfs", MS_SILENT, "size=16m") != 0) { try_dir += strlen(try_dir) + 1;