From: Kamil Konieczny <kamil.konieczny@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Subject: [PATCH i-g-t 1/2] runner/executor: Check for error at writing dmesg dump
Date: Fri, 18 Oct 2024 18:18:19 +0200 [thread overview]
Message-ID: <20241018161820.76014-2-kamil.konieczny@linux.intel.com> (raw)
In-Reply-To: <20241018161820.76014-1-kamil.konieczny@linux.intel.com>
In processing kernel dmesg there are checks for error at reading
so add also one for writing.
Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
runner/executor.c | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/runner/executor.c b/runner/executor.c
index ac73e1dde..3939f92f1 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -600,7 +600,7 @@ static long dump_dmesg(int kmsgfd, int outfd)
bool underflow_once = false;
char cont;
char buf[2048];
- ssize_t r;
+ ssize_t r, w;
long written = 0;
if (kmsgfd < 0)
@@ -654,9 +654,32 @@ static long dump_dmesg(int kmsgfd, int outfd)
return written;
}
- write(outfd, buf, r);
- written += r;
+ w = write(outfd, buf, r);
+ if (w < r) {
+ if (w == -1 && errno == EINTR)
+ w = write(outfd, buf, r);
+
+ if (w < r && w >= 0)
+ w += write(outfd, buf + w, r - w);
+
+ if (w < r) {
+ long err = -errno;
+
+ if (err) {
+ errf("Write error while processing dmesg, errno=%d\n", errno);
+ } else {
+ errf("Cannot write dmesg chunk: %ld < %ld\n", w, r);
+ err = -1;
+ }
+ if (comparefd >= 0)
+ close(comparefd);
+
+ return err;
+ }
+ }
+
+ written += r;
if (comparefd < 0 && sscanf(buf, "%u,%llu,%llu,%c;",
&flags, &seq, &usec, &cont) == 4) {
/*
--
2.47.0
next prev parent reply other threads:[~2024-10-18 16:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 16:18 [PATCH i-g-t 0/2] runner: Allow limits at dumping dmesg Kamil Konieczny
2024-10-18 16:18 ` Kamil Konieczny [this message]
2024-10-24 13:45 ` [PATCH i-g-t 1/2] runner/executor: Check for error at writing dmesg dump Krzysztof Karas
2024-11-13 15:15 ` Kamil Konieczny
2024-10-18 16:18 ` [PATCH i-g-t 2/2] runner/executor: Limit reading dmesg to chunks Kamil Konieczny
2024-10-18 17:14 ` ✓ Fi.CI.BAT: success for runner: Allow limits at dumping dmesg Patchwork
2024-10-18 17:36 ` ✓ CI.xeBAT: " Patchwork
2024-10-18 18:50 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-10-19 8:41 ` ✗ CI.xeFULL: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241018161820.76014-2-kamil.konieczny@linux.intel.com \
--to=kamil.konieczny@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox