Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp810060lqt; Thu, 6 Jun 2024 21:40:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUiW/KgLn9GbGEzMnwDXZnPXIA5W4OXilIkqubH9LkwzpUJdTKonCevetXILhdarkmwwjoePEg5UrIHB8dTnran09QuzqQ1eDfqHPm83A== X-Google-Smtp-Source: AGHT+IGvhLxC4tXPULpAyli5C0AIbzL1SZ2l4rfa0EMmjp+/kXQULPqxeZQuI4IM8+dxU/M8m9K7 X-Received: by 2002:a2e:8750:0:b0:2ea:7d8f:8d12 with SMTP id 38308e7fff4ca-2eadce91435mr7775901fa.48.1717735221605; Thu, 06 Jun 2024 21:40:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717735221; cv=pass; d=google.com; s=arc-20160816; b=xqj9wTdR7+mpE9o6IhJBH+IeuBkNOe/TKSZfeYbqJBBoyTtfQQyes2LfBWZ9u7SOC6 b/1uZ+SXqb1OAz4Snqg6hufolCj0JuvQmAP/cVjuLPJqbNY7TPEC36byG2PRyfdXGMJj IAGh8HPyddOI7tH9UpMr288wp0n9KsoDKsHykv107q82lv8vyr92CzAOSNgp4/jWfOaR fzu0WGTN4JPApxXqgTQNAcXEf+WxLE91nOY1y/m+U8GQd5c0Jn2UTag7g0XYqj0SXJKe /R+hPyJflQnY0u43KPzqxCPwn47oouln3+eVe1buGELHWFqc01wADVz9aNWrHfxsIY+n NWcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Cu4xjtL6YUzsxES4Jzwvo4fHX1mEIs/30poyJ5pCt5k=; fh=yXYChwFvQA/NaaLzCC0IJdkW11OhjXgO4DHXzVmnGFw=; b=jGV8PEIhS4RY2mMtH1xRjubFy5NRD/N0/oqHNBS+vxez4eI0dThoX26mznj1s5/eos s88u/1hyEGc7vzq2MNvmShmrhgTKkWLZknILFX8NiEDn3w/NbmcG8U0k0lO8AnzNh8hV g9nkJlUr0YUFuZyWCJSdW34kQ2YOI5PqL9DgJGz4zuSZEo94D/8U62ZWhtsE1q9Y7UrD frdnvcMqbu1VkJG1s/F8tiS8Rjy++otZBUu0W4lnSyPRgpF77qwsUujt3DX/VyGRQ1c1 GYdOV4H9hCgLAxuj7v56pl3PUwKOaotzpWhBZNRvijZoSFIXZ4ZHmoLA4Xe5VEjw8FYy 13BA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-205338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57c5f19fb13si39337a12.180.2024.06.06.21.40.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 21:40:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-205338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 50E031F25E37 for ; Fri, 7 Jun 2024 04:40:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8691F15B548; Fri, 7 Jun 2024 04:27:34 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E80315AAB1 for ; Fri, 7 Jun 2024 04:27:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717734452; cv=none; b=pV13nLr9I3SoLWQkfDxHCBGGRyVTY0Dx9NOzWHQoy6I9AoEAToNiS3W91oeOL2+zjP+HNiM2yOKN0nIOvt4cb40FZbrsQoIj1FnL3Q8ha2VOgm4v+/N9hjGv1KOfomB0bIrwjLivWZOqo6jGnTME7R/1fNkCdtXV8aFJmXg9D+I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717734452; c=relaxed/simple; bh=mPrAe2UVuBplSMLi2TXauuCSsb/mbFPlTH2FOWlYb6c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SC/aAcLHV5mVrkDDK5J1fzBGTztY5266RjkEAFh1paGdTqc5yZnoTWecis5CaxifF8hynHsSpAe9480fMKkPytHmavD9zZLizC1rDRRlK+Og3yEIUCmKRXFBBmGj2/EGO+T3UuTX0avDJd9Y9hiVCcB+hw4GIB5tIcDn8kC8yp4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VwSjP5d5lzmYRQ; Fri, 7 Jun 2024 12:22:49 +0800 (CST) Received: from kwepemm600013.china.huawei.com (unknown [7.193.23.68]) by mail.maildlp.com (Postfix) with ESMTPS id 97025180085; Fri, 7 Jun 2024 12:27:25 +0800 (CST) Received: from huawei.com (10.175.104.67) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 7 Jun 2024 12:27:08 +0800 From: Zhihao Cheng To: , , , , , CC: , Subject: [RFC PATCH mtd-utils 056/110] ubifs-utils: open_ubi: Set errno if the target is not char device Date: Fri, 7 Jun 2024 12:25:21 +0800 Message-ID: <20240607042615.2069840-57-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240607042615.2069840-1-chengzhihao1@huawei.com> References: <20240607042615.2069840-1-chengzhihao1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600013.china.huawei.com (7.193.23.68) Set errno if the target is not char device. It will be useful for fsck to print error message if open_ubi failed. Signed-off-by: Zhihao Cheng --- ubifs-utils/libubifs/super.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ubifs-utils/libubifs/super.c b/ubifs-utils/libubifs/super.c index 1cbbfcac..9fa366f3 100644 --- a/ubifs-utils/libubifs/super.c +++ b/ubifs-utils/libubifs/super.c @@ -43,9 +43,14 @@ int open_ubi(struct ubifs_info *c, const char *node) { struct stat st; - if (stat(node, &st) || !S_ISCHR(st.st_mode)) + if (stat(node, &st)) return -1; + if (!S_ISCHR(st.st_mode)) { + errno = ENODEV; + return -1; + } + c->libubi = libubi_open(); if (!c->libubi) return -1; -- 2.13.6