summaryrefslogtreecommitdiff
path: root/c_src/cmd_fsck.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-07-04 12:34:24 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-07-04 12:47:30 -0400
commite7cc6bb9cfd0d5de310d5eb61fd17693a2b4d60b (patch)
tree71c4c24abd6cfed054555c0de906827fe5266d8e /c_src/cmd_fsck.c
parent7d69a303d1c5eafd860c2377a013fd2aaad43ba2 (diff)
getopt() -> getopt_long()
Kill all remaining getopt() uses - all options can now be passed as longopts. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'c_src/cmd_fsck.c')
-rw-r--r--c_src/cmd_fsck.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/c_src/cmd_fsck.c b/c_src/cmd_fsck.c
index a3fd1d6a..66669e67 100644
--- a/c_src/cmd_fsck.c
+++ b/c_src/cmd_fsck.c
@@ -47,6 +47,24 @@ static int do_splice(int rfd, int wfd)
return 1;
do {
ssize_t w = write(wfd, b, r);
+
+ /*
+ * Ugly, but we have no way of doing nonblocking reads and
+ * blocking writes.
+ *
+ * Yes, this means that if one thread has stopped reading (or
+ * isn't keeping up) we block traffic on the other direction of
+ * the pipe. No, I don't care.
+ */
+ if (w < 0 && errno == EAGAIN) {
+ fd_set fds;
+ FD_ZERO(&fds);
+ FD_SET(wfd, &fds);
+ if (select(wfd + 1, NULL, &fds, NULL, NULL) < 0)
+ die("select error: %m");
+ continue;
+ }
+
if (w < 0)
die("%s: write error: %m", __func__);
r -= w;