diff options
author | Huang Ying <ying.huang@intel.com> | 2008-10-29 11:24:25 +0800 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2008-10-31 12:58:16 +1100 |
commit | ceb04ae1223ba5cdd40df744aa73a32b2cc7d879 (patch) | |
tree | 993024edfe07b9cd7150fb2131175104e4948ad4 /purgatory/printf.c | |
parent | 802a8a5e396e06a514251c44454c982bff3c5073 (diff) |
kexec jump support for kexec-tools
To support memory backup/restore an option named
--load-preserve-context is added to kexec. When it is specified
toggether with --mem-max, most segments for crash dump support are
loaded, and the memory range between mem_min to mem_max which has no
segments loaded are loaded as backup segments. To support jump back
from kexeced, options named --load-jump-back-helper and --entry are
added to load a helper image with specified entry to jump back.
Signed-off-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'purgatory/printf.c')
-rw-r--r-- | purgatory/printf.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/purgatory/printf.c b/purgatory/printf.c index 962683d..9a78243 100644 --- a/purgatory/printf.c +++ b/purgatory/printf.c @@ -33,19 +33,23 @@ PRINTF and friends %s - string Note: width specification not supported **************************************************************************/ -void printf(const char *fmt, ...) +void vsprintf(char *buffer, const char *fmt, va_list args) { - va_list args; char *p; - va_start(args, fmt); for ( ; *fmt != '\0'; ++fmt) { if (*fmt != '%') { - putchar(*fmt); + if (buffer) + *buffer++ = *fmt; + else + putchar(*fmt); continue; } if (*++fmt == 's') { for(p = va_arg(args, char *); *p != '\0'; p++) - putchar(*p); + if (buffer) + *buffer++ = *p; + else + putchar(*p); } else { /* Length of item is bounded */ char tmp[40], *q = tmp; @@ -121,8 +125,30 @@ void printf(const char *fmt, ...) *q++ = *fmt; /* now output the saved string */ for (p = tmp; p < q; ++p) - putchar(*p); + if (buffer) + *buffer++ = *p; + else + putchar(*p); } } + if (buffer) + *buffer = '\0'; +} + +void sprintf(char *buffer, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vsprintf(buffer, fmt, args); + va_end(args); +} + +void printf(const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vsprintf(0, fmt, args); va_end(args); } |