From patchwork Fri Feb 22 16:47:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10826645 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 E760413B5 for ; Fri, 22 Feb 2019 16:47:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D37A2329D8 for ; Fri, 22 Feb 2019 16:47:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7C0D32A03; Fri, 22 Feb 2019 16:47:33 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 7EE0132A01 for ; Fri, 22 Feb 2019 16:47:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725986AbfBVQrd (ORCPT ); Fri, 22 Feb 2019 11:47:33 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:52012 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726229AbfBVQrc (ORCPT ); Fri, 22 Feb 2019 11:47:32 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1MGiL6R159692 for ; Fri, 22 Feb 2019 16:47:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=2Vaxo6BBpIb+AVkdEGV7bdFC6b7LMj5FivU2Z2/Iuj0=; b=NKoFCSMrM7deEWnxnnuSNMKUnul1H1F/KHbn6HnxrhjhmCeSy2/S5tdlAUgtVZhOMqFE Hx64t0MyUUoWUOeaRV/kaI/D+egP8GrwNRDMRLwJ/A1Z8iK1n4I1GLmtqz9LbXWyTgyM CjlVXOGURwC0+3fu5gmNUeVxFOh1+Fg+uT8Cx3dfcgH82ewpSFp8H9AsOBpbjrkOMQdM n8Nwz10wWCm7pNKYxXtNN+Hg5i5ez/dykeKoIcQYZsxht9BtufucjZ4Oc7uwqzG9UXga 1C3TF2sqH+SC6BoO5arWLhmYWXWMgd71iga0x8aw3EmwdaiJSr5uUUgzYQ4qSYg3ctdn MQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2qpb5s071p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 22 Feb 2019 16:47:31 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x1MGlVcZ010477 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 22 Feb 2019 16:47:31 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x1MGlVEV016733 for ; Fri, 22 Feb 2019 16:47:31 GMT Received: from localhost (/10.159.254.125) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 22 Feb 2019 08:47:30 -0800 Subject: [PATCH 2/4] xfs_restore: check return value From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Fri, 22 Feb 2019 08:47:30 -0800 Message-ID: <155085405082.5141.12150949924461780415.stgit@magnolia> In-Reply-To: <155085403848.5141.1866278990901950186.stgit@magnolia> References: <155085403848.5141.1866278990901950186.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9175 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=927 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902220118 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Check the return value of the unlink call when creating a new file. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins --- restore/dirattr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/restore/dirattr.c b/restore/dirattr.c index 0fb2877..4257a1b 100644 --- a/restore/dirattr.c +++ b/restore/dirattr.c @@ -67,7 +67,9 @@ create_filled_file( int fd; int ret; - (void)unlink(pathname); + ret = unlink(pathname); + if (ret && errno != ENOENT) + return ret; fd = open(pathname, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); if (fd < 0)