[PATCH][makedumpfile -R] Promptly return error on truncated regular file.
Aureau, Georges (Kernel Tools ERT)
georges.aureau at hpe.com
Sun Nov 2 02:48:42 PST 2025
Hello,
Forget about this PATCH, it is missing some option as to control the behavior.
What I'm really after is to promptly detect truncated flatten files without the 10-minute timeout.
This would be assuming stdin is not a file in the process of being created (where eof is a moving target).
Maybe something like "makedumpfile -R --some-option", where some-option would cause returning an
immediate error in premature EOF:
- if (TIMEOUT_STDIN < (tm - last_time)) {
+ if (some_option || TIMEOUT_STDIN < (tm - last_time)) {
Thanks,
Georges
I
|-----Original Message-----
|From: Aureau, Georges (Kernel Tools ERT)
|Sent: Friday, October 31, 2025 9:41 PM
|To: kexec at lists.infradead.org
|Cc: yamazaki-msmt at nec.com; HAGIO KAZUHITO(萩尾 一仁) <k-hagio-
|ab at nec.com>
|Subject: [PATCH][makedumpfile -R] Promptly return error on truncated regular
|file.
|
|[PATCH][makedumpfile -R] Promptly return error on truncated regular file.
|
|When reaching the end-of-file on a truncated input regular file,
|makedumpfile -R is looping for 10 minutes before producing an error.
|This is confusing for users. When stdin is a regular file, an improved
|behavior is to promptly return an EOF error.
|
|Signed-off-by: Georges Aureau <georges.aureau at hpe.com>
|--
|diff --git a/makedumpfile.c b/makedumpfile.c
|index 12fb0d8..295b3cc 100644
|--- a/makedumpfile.c
|+++ b/makedumpfile.c
|@@ -5135,6 +5135,21 @@ write_cache_zero(struct cache_data *cd, size_t size)
| return write_cache_bufsz(cd);
| }
|
|+int
|+is_stdin_regular_file(void)
|+{
|+ struct stat st;
|+ static int regular_file = -1;
|+ if (regular_file == -1) {
|+ if (fstat(STDIN_FILENO, &st) == -1) {
|+ regular_file = FALSE;
|+ } else {
|+ regular_file = S_ISREG(st.st_mode) ? TRUE : FALSE;
|+ }
|+ }
|+ return regular_file;
|+}
|+
| int
| read_buf_from_stdin(void *buf, int buf_size)
| {
|@@ -5154,11 +5169,12 @@ read_buf_from_stdin(void *buf, int buf_size)
|
| } else if (0 == tmp_read_size) {
| /*
|- * If it cannot get any data from a standard input
|+ * If we reach end-of-file on regular file, or
|+ * if we cannot get any data from a standard input
| * for a long time, break this loop.
| */
| tm = time(NULL);
|- if (TIMEOUT_STDIN < (tm - last_time)) {
|+ if (is_stdin_regular_file() || TIMEOUT_STDIN < (tm - last_time)) {
| ERRMSG("Can't get any data from STDIN.\n");
| return FALSE;
| }
|
|
More information about the kexec
mailing list