From patchwork Wed Nov 6 23:15:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 3149711 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B9CCF9F407 for ; Wed, 6 Nov 2013 23:16:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F0C9D202FF for ; Wed, 6 Nov 2013 23:16:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2BFDC20304 for ; Wed, 6 Nov 2013 23:16:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752228Ab3KFXQe (ORCPT ); Wed, 6 Nov 2013 18:16:34 -0500 Received: from sandeen.net ([63.231.237.45]:56126 "EHLO sandeen.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751232Ab3KFXP6 (ORCPT ); Wed, 6 Nov 2013 18:15:58 -0500 Received: by sandeen.net (Postfix, from userid 500) id 8DAE9654E648; Wed, 6 Nov 2013 17:15:57 -0600 (CST) From: Eric Sandeen To: linux-btrfs@vger.kernel.org Subject: [PATCH 10/16] btrfs-progs: Check for open failure in btrfs_scan_lblkid() Date: Wed, 6 Nov 2013 17:15:49 -0600 Message-Id: <1383779755-18228-11-git-send-email-sandeen@redhat.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1383779755-18228-1-git-send-email-sandeen@redhat.com> References: <1383779755-18228-1-git-send-email-sandeen@redhat.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP open can fail, of course. Resolves-Coverity-CID: 1125925 Resolves-Coverity-CID: 1125930 Signed-off-by: Eric Sandeen --- utils.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/utils.c b/utils.c index d8ce153..8471148 100644 --- a/utils.c +++ b/utils.c @@ -1955,12 +1955,16 @@ int btrfs_scan_lblkid(int update_kernel) dev = blkid_verify(cache, dev); if (!dev) continue; - /* if we are here its definitly a btrfs disk*/ + /* if we are here its definitely a btrfs disk*/ strncpy(path, blkid_dev_devname(dev), PATH_MAX); if (test_skip_this_disk(path)) continue; fd = open(path, O_RDONLY); + if (fd < 0) { + printf("ERROR: could not open %s\n", path); + continue; + } btrfs_scan_one_device(fd, path, &tmp_devices, &num_devices, BTRFS_SUPER_INFO_OFFSET); close(fd);