[PATCH 2/2] e2fsck: remove unnecessary reserve_stdio_fds()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Standard stream are always open, we do not need to "check" it
specifically. Remove reserve_stdio_fds().

This also fixes the file descriptor leak.

Signed-off-by: Lukas Czerner <lczerner@xxxxxxxxxx>
---
 e2fsck/unix.c | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 90065b39..268feee0 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -603,25 +603,6 @@ static int e2fsck_update_progress(e2fsck_t ctx, int pass,
 
 #define PATH_SET "PATH=/sbin"
 
-/*
- * Make sure 0,1,2 file descriptors are open, so that we don't open
- * the filesystem using the same file descriptor as stdout or stderr.
- */
-static void reserve_stdio_fds(void)
-{
-	int	fd = 0;
-
-	while (fd <= 2) {
-		fd = open("/dev/null", O_RDWR);
-		if (fd < 0) {
-			fprintf(stderr, _("ERROR: Couldn't open "
-				"/dev/null (%s)\n"),
-				strerror(errno));
-			break;
-		}
-	}
-}
-
 #ifdef HAVE_SIGNAL_H
 static void signal_progress_on(int sig EXT2FS_ATTR((unused)))
 {
@@ -1411,7 +1392,6 @@ int main (int argc, char *argv[])
 			_("while trying to initialize program"));
 		exit(FSCK_ERROR);
 	}
-	reserve_stdio_fds();
 
 	set_up_logging(ctx);
 	if (ctx->logf) {
-- 
2.17.1




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux