From patchwork Tue Feb 12 11:12:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cui Yue X-Patchwork-Id: 10807727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 141FA13B4 for ; Tue, 12 Feb 2019 11:13:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0628F2B59D for ; Tue, 12 Feb 2019 11:13:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEF192B575; Tue, 12 Feb 2019 11:13:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A48112B595 for ; Tue, 12 Feb 2019 11:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728607AbfBLLNO (ORCPT ); Tue, 12 Feb 2019 06:13:14 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:64581 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727428AbfBLLNO (ORCPT ); Tue, 12 Feb 2019 06:13:14 -0500 X-IronPort-AV: E=Sophos;i="5.58,361,1544457600"; d="scan'208";a="54165370" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 12 Feb 2019 19:13:11 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 0E07A4C4BB93 for ; Tue, 12 Feb 2019 19:13:12 +0800 (CST) Received: from cui-linux.localdomain (10.167.225.61) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 12 Feb 2019 19:13:18 +0800 From: Cui Yue To: Subject: [PATCH] generic/089: Add error check for unlock_mtab() Date: Tue, 12 Feb 2019 19:12:30 +0800 Message-ID: <1549969950-4886-1-git-send-email-cuiyue-fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.167.225.61] X-yoursite-MailScanner-ID: 0E07A4C4BB93.A6536 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: cuiyue-fnst@cn.fujitsu.com Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When unlink() fails, that is, when the lock file is not deleted successfully, variable we_created_lockfile is still set to 0. On the next iteration, the 3 processes will not be able to successfully create the lock file. Signed-off-by: Cui Yue --- src/t_mtab.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/t_mtab.c b/src/t_mtab.c index fd85c6b..6a17fbd 100644 --- a/src/t_mtab.c +++ b/src/t_mtab.c @@ -184,9 +184,15 @@ lock_mtab (void) { /* Remove lock file. */ void unlock_mtab (void) { + int ret; if (we_created_lockfile) { - unlink (mounted_lock); - we_created_lockfile = 0; + ret = unlink (mounted_lock); + if (ret) { + fprintf(stderr, "Cannot remove lock file: %s\n", strerror(errno)); + exit(1); + } else { + we_created_lockfile = 0; + } } }