From patchwork Tue Aug 8 10:50:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Marcher X-Patchwork-Id: 799100 X-Patchwork-Delegate: david.oberhollenzer@sigma-star.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="l5QhdyGc"; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=drkhsh.at header.i=@drkhsh.at header.b="nGeUaJR1"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xRWR75sdnz9s72 for ; Tue, 8 Aug 2017 20:51:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=OKNfqEreEorZiOjP1Ub+ObuN5/pZ2pfBmIn0p4VYtCU=; b=l5Q hdyGcV7tcF9pmrvU6fDNTmx58TdJiJiRHYholwSU/weXQ54/3TUqxTpbgE+Trbji+fvS/3j3LYuFX JGAzxQzMKWnQwhsg72GwHwNG3Ylp8kMScFxdQVuAq9O2afhQ5D0v1XY2IjxIlaaePwWuqiJCAV9mo dXYZ2GEQRrXkF0/of0YQpL9C+Ivjc5O/VVLDz9KL9amaA07+Nb82irpA+mQWMiTuyGEtsXSHsjXZB BuDNdXaHDX/9kMKo3KetjHXX26bp04U0CEJF6aGs5wZRFoomfsQ4gujd4Zn7ACNkqOEPwXhwCABWs KpC8yrpJBa/AFLka4ryJwb+NpviHZoQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1df26L-0007sn-68; Tue, 08 Aug 2017 10:51:05 +0000 Received: from oxygenium.servers.drkhsh.at ([5.9.5.62]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1df26I-0007qH-4q for linux-mtd@lists.infradead.org; Tue, 08 Aug 2017 10:51:03 +0000 Received: by oxygenium.servers.drkhsh.at (OpenSMTPD) with ESMTP id cb791cd0 for ; Tue, 8 Aug 2017 12:50:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=drkhsh.at; h=from:to:cc :subject:date:message-id; s=default; bh=1hoE93jWr9OToWfDacQp7/e8 IA0=; b=nGeUaJR1xcBW89GK6ktXra3Az9oJBZf6gCWgP8omiYnuxFzmXbFOQuNa BcQE+AGO6fXwVRLG7DFndvA+40+YWSylbOdHuZMcL0h+RWQjm99ffhf9H1mSl3EE HtBPTx6w143RMzWYvTvdLYLXR6fbvpwV2mDzO4AS2++PG4lf0Ms= DomainKey-Signature: a=rsa-sha1; c=nofws; d=drkhsh.at; h=from:to:cc :subject:date:message-id; q=dns; s=default; b=3W0uflIKRw/bB+9SBB XWtwZ8LLRazoQJ5QDlJkGgvAJAsddqcYS9FabA9kid+UKEu4PFV95YyoJPLgITrD eUouWeQCszqq7u0JKacZacgmJ8RruiMJoszg95IVUTZyzs4Iph5LA6URsqSeu9Fw fRuGSrzw4vZgrkT1xWelVKa9I= Received: by oxygenium.servers.drkhsh.at (OpenSMTPD) with ESMTPSA id 58b91060 (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO); Tue, 8 Aug 2017 12:50:23 +0200 (CEST) From: Aaron Marcher To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd-utils: ubinfo, add parameter check Date: Tue, 8 Aug 2017 12:50:28 +0200 Message-Id: <20170808105028.11758-1-me@drkhsh.at> X-Mailer: git-send-email 2.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170808_035102_573209_4533186C X-CRM114-Status: UNSURE ( 7.17 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aaron marcher MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: aaron marcher without specifying the UBI device number, ubinfo with the volume name parameter returns an error that it cannot find the specified volume on ubi-1. -1 comes from the default value of devn used for internal checks. i added a check to fix this behaviour and print out an error message instead. --- ubi-utils/ubinfo.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ubi-utils/ubinfo.c b/ubi-utils/ubinfo.c index 82d4f18..29530be 100644 --- a/ubi-utils/ubinfo.c +++ b/ubi-utils/ubinfo.c @@ -399,6 +399,12 @@ int main(int argc, char * const argv[]) goto out_libubi; } + if (args.vol_name && args.devn == -1) { + errmsg("volume name is specified, but UBI device number is not " + "(use -h for help)\n"); + goto out_libubi; + } + if (args.vol_name) { err = get_vol_id_by_name(libubi, args.devn, args.vol_name); if (err)