From patchwork Thu Aug 9 08:35:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Czerner X-Patchwork-Id: 955406 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41mM6t2kSfz9s1x for ; Thu, 9 Aug 2018 18:36:38 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729793AbeHILAY (ORCPT ); Thu, 9 Aug 2018 07:00:24 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33826 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727879AbeHILAY (ORCPT ); Thu, 9 Aug 2018 07:00:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1851D40241C3 for ; Thu, 9 Aug 2018 08:36:37 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.17.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 892722314C; Thu, 9 Aug 2018 08:36:36 +0000 (UTC) From: Lukas Czerner To: linux-ext4@vger.kernel.org Cc: Lukas Czerner Subject: [PATCH 2/2] e2fsck: remove unnecessary reserve_stdio_fds() Date: Thu, 9 Aug 2018 10:35:46 +0200 Message-Id: <20180809083546.17419-2-lczerner@redhat.com> In-Reply-To: <20180809083546.17419-1-lczerner@redhat.com> References: <20180809083546.17419-1-lczerner@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 09 Aug 2018 08:36:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 09 Aug 2018 08:36:37 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lczerner@redhat.com' RCPT:'' Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 Reviewed-by: Lukas Czerner --- 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) {