From patchwork Mon Nov 25 17:45:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe REYNES X-Patchwork-Id: 1200510 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::237; helo=mail-lj1-x237.google.com; envelope-from=swupdate+bncbaabbovg6dxakgqepsd5y6i@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="VP2aBCAl"; dkim-atps=neutral Received: from mail-lj1-x237.google.com (mail-lj1-x237.google.com [IPv6:2a00:1450:4864:20::237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47MDvz03dpz9sNx for ; Tue, 26 Nov 2019 04:45:34 +1100 (AEDT) Received: by mail-lj1-x237.google.com with SMTP id u6sf3180740ljg.8 for ; Mon, 25 Nov 2019 09:45:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1574703930; cv=pass; d=google.com; s=arc-20160816; b=C7sY2VL6hhytztl/P/EeEcWLpQiLb0bPTr435bR2Y6O7I49Kb3o+m6LCEbrI2wbq1a aajSKuMp9q4h0eQ8PcpD4yUWDzJg937D++T0ppgJoQbfFj8UNzeuepnRN11R5mTD1u7g XDSqPKBV3E+2mtw9GN8ljRnyXNt41ByWoGpYxzewOLdCKLbHgxZXJ+s3G2anydOG77T+ UbIk2NZ9zuJ3VqcGHMZxlhhTnKFQW26hkhsR1Hg2zdYjJuPbzKOAsFCEhSmdOlbTdATv KbWkJvIKVRCUbkstNvM2CquOi/JY3/ZmKj39tXcdMsU30DddO8HvxvoKEI25w4iAPYv6 oSxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:message-id:date:subject:cc:to:from :mime-version:sender:dkim-signature; bh=8VXX/ABMnFuJGJ1lwXtSVeLKdJaJV+FO4pNJgpEVy7M=; b=g9cfIBDJY+eKnMQUnspzXxWkhyLHGmGxWIs9U9OuX4SDMx8QzmLV+hS/XxSFnPP+vL QTc+EyGtmbL4Bmupt4ius9mdlWVQ1fOiEoN+bEM25KDUa7l7ewRO4Jv5/YTG1kPNcklD V9NgeKaT9l8RYVDCYaXST/60W+BA5hfGMEJu9LjGmMcCP2BRNmncbpFenVKVz3SYCHMN 2PmhzwGZaw611wU6WFrErzMtpi+NfSn33TLo3QTxX8tBBQE4KsLTi71TAcPI99DKIz0+ WSmZa8XAZGm9K/fvjz6ahe75i28bDjVG1JA8eQf1+RGBEv3NSKSoArISYDwncwI3B84p f/TA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=softfail (google.com: domain of transitioning philippe.reynes@softathome.com does not designate 185.56.204.56 as permitted sender) smtp.mailfrom=philippe.reynes@softathome.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=8VXX/ABMnFuJGJ1lwXtSVeLKdJaJV+FO4pNJgpEVy7M=; b=VP2aBCAlWMxJVu+0WVdnG3xdamwjgrF53zFk5oETNCyASc5TPHobAcKc5pwf1aE8Rb L5bPbMCZFYTjBtjzyx+n2HJTQzkTvIDwnnCoxeIbWqmc+vF87LNZL6aRHt7j9WXKjOVw qscvCXEAfyJ1ylTM2+swR3Uhoy2FkOHExWmQnPulVibeMzXxtqao+gpZMT/s/KWGi40y D92voycO1UkAuy5EdIRw2A79hq+f5lBWo9jfbmuW9gZGYFYJ0VckIyCyGNuI+FZTszOy z52so2btjRIZo7sYH/IpuvWu+UvVBeB0FkKOB1Pdvflxp0DOHVnhwMM8EtaLVP40CJOj 1yww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=8VXX/ABMnFuJGJ1lwXtSVeLKdJaJV+FO4pNJgpEVy7M=; b=t5gm4AeZ271ZWSJM2e8TKWow5rmPZrySX9T4nJjIVIvl9lVeSpD63i23PGVq5QRsTS Z7s0S3b9CTqfsQrmHFB+uvdv9q8TPdpnjVwLeLP/pjdkGUtjFz1ZOeiKLl36/HA/h71b PovgqIV2CWlD8S+j1Szqn42cpiNI0T59+Ju6mViG9y4T4h5X0CCc2XsFDdpMbsOvHVe+ 7EJm+tA/iqZfoC593ZXBiGLIsFsDDBw+zKKslvOhBEBZdJtT3WLdTPNE+xPbD37I0LFl 8XK+8HsYQi6P9jGhSOIhxuGoDrh7GY8HJXOBTSfbpBE3toZ7QZ0Jdi/bZUrDzFbBOqnc OZ5g== Sender: swupdate@googlegroups.com X-Gm-Message-State: APjAAAX6aKj0uyiuKBy5hivPyezKppJmkkvJNzaP4wIBBGakSkSlEvlQ COowvSLuNcXIbpLwBgKdzYE= X-Google-Smtp-Source: APXvYqykbmHgSI1THPSt/OqXlFTp1nnnDSDpm43OEZRlGayXNQGbkvJoASXz3BzA7zP298Ebi/C1jA== X-Received: by 2002:ac2:4d10:: with SMTP id r16mr22442055lfi.70.1574703930536; Mon, 25 Nov 2019 09:45:30 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:15b:: with SMTP id m27ls1761880lfo.1.gmail; Mon, 25 Nov 2019 09:45:30 -0800 (PST) X-Received: by 2002:ac2:52a3:: with SMTP id r3mr18198162lfm.189.1574703929984; Mon, 25 Nov 2019 09:45:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574703929; cv=none; d=google.com; s=arc-20160816; b=CT4eaZ0w0CnbeNfKqAk0/Bmm/0j0WzFDUlo7wEUXoAr/HriCzr01DKoV3pxgXvRxMv Av9L0UYuPJYKzYsfoLUJmlAEwy9yMhz5P9niV75rvemL4VzZ1rn75HQ8PJs/GmwcY9RI d1uzOIelX+Z/XNNBSx7V6AIr2UpuduZqGny7bQcmgbdsAW+l3TUBkEgh8Zw39nPXji69 CQw7HdY1asJHIDLbuadqI5f+LiXQjbyNHfRfQTihcsEH1B0OX7xWAlp/ytXwRc1/0Ln7 n26QGUnpPN96ly9HF+ia0ZiDXbdikAT+Y0C6GPq4l7eIPeNxEn5anwxDNbf9u5nd1ZUz 2sgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=OK49GO8/74f3u96tgtP9v6FtX4AYNM28jtkrbXJBdws=; b=VKKC/bvRUdfcRlNa/7etCjw32x910Gzad5YYdIUFDalaNHGb1XY7GlixYS3POS4vMj j6joRmt9uvPs4aAf33CORl9DOS5LJ7PnVFN4YSp3jx+fDXNWbMK7+D3yLA/NSjpjb/Vg drF4HzZ/xYP83hajYOFVhpB12r8U7X9QSbudL0rOwPDtriTl7fHLW6/WZS2CEX4EHkOT /XYxmVeUkk2xH+r5I4LWSCLoyK5/m7Y6KwG91v3870IZWWEvoPJQFlfFoRU7XcKlnRvI EhZwHMvPw+IJXK3vQWn55xhIHRaaThXqQRLpqI+UnrauwwX4r0JjFnAmTreFlJDDLji+ uYPw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=softfail (google.com: domain of transitioning philippe.reynes@softathome.com does not designate 185.56.204.56 as permitted sender) smtp.mailfrom=philippe.reynes@softathome.com Received: from vrout10.yaziba.net (vrout10-bl2.yaziba.net. [185.56.204.56]) by gmr-mx.google.com with ESMTPS id h21si364768lja.5.2019.11.25.09.45.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Nov 2019 09:45:29 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning philippe.reynes@softathome.com does not designate 185.56.204.56 as permitted sender) client-ip=185.56.204.56; Received: from mtaout10.int.yaziba.net (mtaout10.int.yaziba.net [10.4.20.36]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout10.yaziba.net (mx10.yaziba.net) with ESMTPS id 13B5E52053 for ; Mon, 25 Nov 2019 18:45:29 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mtaout10.int.yaziba.net (Postfix) with ESMTP id 32C6B1601C9; Mon, 25 Nov 2019 18:45:29 +0100 (CET) Received: from mtaout10.int.yaziba.net ([127.0.0.1]) by localhost (mtaout10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 232i0CORhCJq; Mon, 25 Nov 2019 18:45:29 +0100 (CET) Received: from sahnlpt0333.softathome.com (unknown [149.6.166.170]) by mtaout10.int.yaziba.net (Postfix) with ESMTPSA id 206591601A7; Mon, 25 Nov 2019 18:45:29 +0100 (CET) From: Philippe Reynes To: swupdate@googlegroups.com Cc: Philippe Reynes Subject: [swupdate] [PATCH] uboot_env: fix the resarch of ubi volume Date: Mon, 25 Nov 2019 18:45:27 +0100 Message-Id: <1574703927-19823-1-git-send-email-philippe.reynes@softathome.com> X-Mailer: git-send-email 2.7.4 X-CLAMAV-SCAN: ok X-VRSPAM-SCORE: 0 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeiuddguddthecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofestddtredtredttdenucfhrhhomheprfhhihhlihhpphgvucftvgihnhgvshcuoehphhhilhhiphhpvgdrrhgvhihnvghssehsohhfthgrthhhohhmvgdrtghomheqnecukfhppedugeelrdeirdduieeirddujedtnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhht X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht X-Original-Sender: philippe.reynes@softathome.com X-Original-Authentication-Results: gmr-mx.google.com; spf=softfail (google.com: domain of transitioning philippe.reynes@softathome.com does not designate 185.56.204.56 as permitted sender) smtp.mailfrom=philippe.reynes@softathome.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , In the function ubi_get_vol_id, when we search the volume id with the volume name, we try all id from 0 to num_volume. But the volume id may be greater than the actual number of volume. To avoid this issue, we try all the id from 0 to 128 (max ubi volume id). Signed-off-by: Philippe Reynes --- src/uboot_env.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/uboot_env.c b/src/uboot_env.c index b59b140..0f33931 100644 --- a/src/uboot_env.c +++ b/src/uboot_env.c @@ -36,6 +36,8 @@ #include "uboot_private.h" +#define UBI_MAX_VOLUME 128 + #define DEVICE_MTD_NAME "/dev/mtd" #define DEVICE_UBI_NAME "/dev/ubi" #define SYS_UBI_VOLUME_COUNT "/sys/class/ubi/ubi%d/volumes_count" @@ -230,13 +232,15 @@ out: static int ubi_get_vol_id(char *device, char *volname) { - int i, ret, num_vol, vol_id = -1; + int i, n, ret, num_vol, vol_id = -1; num_vol = ubi_get_num_volume(device); if (num_vol < 0) goto out; - for (i=0; i