mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Use the directory specified by the shell environment variable TMPDIR for temporary objects creation and ngdump job simulation. If TMPDIR is not set, then use "/tmp" for the mentioned purposes; While running ngdump job in 'dry-run' mode: . Don't format/mount the target dump device. Instead, create the bootmap file and the meta-file at the temporary mount point without mounting anything to it. Thus, the mentioned files to be acrually created in the "proxy" file system owning the temporary mount point; . Retrieve base disk info from the read-only dump device and complete that info with the block size of the proxy file system; Separate the steps on retrieving/setting file system block size into a dedicated procedure; Use definitions instead of hardcoded file names; Fix a bug in an error path (accessing freed memory); Make misc_open_simulate() and misc_open_exclusive() static; Update man pages with the requirements on the system environment (resources) for ngdump job being executed in dry-run mode; Provide hints for user (in stderr) in case when ngdump job in dry-run mode failed due to inappropriate system environment. Tested-by: Mikhail Zaslonko <zaslonko@linux.ibm.com> Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com> Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
90 lines
1.9 KiB
C
90 lines
1.9 KiB
C
/*
|
|
* zipl - zSeries Initial Program Loader tool
|
|
*
|
|
* Functions to handle error messages
|
|
*
|
|
* Copyright IBM Corp. 2001, 2017
|
|
*
|
|
* s390-tools is free software; you can redistribute it and/or modify
|
|
* it under the terms of the MIT license. See LICENSE for details.
|
|
*/
|
|
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
|
|
#include "error.h"
|
|
|
|
|
|
#define ERROR_STRING_SIZE 1024
|
|
|
|
static char error_reason_string[ERROR_STRING_SIZE];
|
|
static char error_text_string[ERROR_STRING_SIZE];
|
|
|
|
static int error_is_reason = 0;
|
|
static int error_is_text = 0;
|
|
|
|
|
|
/* Specify the actual reason why an operation failed by providing a formatted
|
|
* text string FMT and a variable amount of extra arguments. */
|
|
void
|
|
error_reason(const char* fmt, ...)
|
|
{
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
vsnprintf(error_reason_string, ERROR_STRING_SIZE, fmt, args);
|
|
va_end(args);
|
|
error_is_reason = 1;
|
|
}
|
|
|
|
|
|
/* Specify the (higher level) tool operation failure by providing a formatted
|
|
* text string FMT and a variable amount of extra arguments. */
|
|
void
|
|
error_text(const char* fmt, ...)
|
|
{
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
vsnprintf(error_text_string, ERROR_STRING_SIZE, fmt, args);
|
|
va_end(args);
|
|
error_is_text = 1;
|
|
}
|
|
|
|
|
|
/* Clear a previously specified error_reason() message. */
|
|
void
|
|
error_clear_reason(void)
|
|
{
|
|
error_is_reason = 0;
|
|
}
|
|
|
|
|
|
/* Clear a previously specified error_text() message. */
|
|
void
|
|
error_clear_text(void)
|
|
{
|
|
error_is_text = 0;
|
|
}
|
|
|
|
|
|
/* Print out the error reason and text message to stderr. */
|
|
void
|
|
error_print(void)
|
|
{
|
|
if (error_is_text && error_is_reason) {
|
|
fprintf(stderr, "Error: %s: %s\n", error_text_string,
|
|
error_reason_string);
|
|
} else if (error_is_text)
|
|
fprintf(stderr, "Error: %s\n", error_text_string);
|
|
else if (error_is_reason)
|
|
fprintf(stderr, "Error: %s\n", error_reason_string);
|
|
else
|
|
fprintf(stderr, "Error: An unspecified error occurred\n");
|
|
}
|
|
|
|
int is_error(const char *this)
|
|
{
|
|
return strcmp(error_reason_string, this) == 0;
|
|
}
|