From 6ff5313cbe0432fb34605aea2f861cfc5c5fdb32 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 17 Feb 2024 20:57:07 -0500 Subject: [PATCH] cmd_fsck: Collect return code of kernel fsck with close() Signed-off-by: Kent Overstreet --- Makefile | 2 +- c_src/cmd_fsck.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 876efbb7..8e850ec4 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=1.4.0 +VERSION=1.6.2 PREFIX?=/usr/local LIBEXECDIR?=$(PREFIX)/libexec diff --git a/c_src/cmd_fsck.c b/c_src/cmd_fsck.c index 321463ca..0d4070a3 100644 --- a/c_src/cmd_fsck.c +++ b/c_src/cmd_fsck.c @@ -70,15 +70,17 @@ static int splice_fd_to_stdinout(int fd) select(fd + 1, &fds, NULL, NULL, NULL); int r = do_splice(fd, STDOUT_FILENO); + if (r < 0) + return r; if (r) - return r < 0 ? r : 0; + break; r = do_splice(STDIN_FILENO, fd); if (r < 0) return r; } - return 0; + return close(fd); } static int fsck_online(const char *dev_path)