From patchwork Sat May 9 09:41:06 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 27038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id B9F3DB6F34 for ; Mon, 11 May 2009 16:11:13 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1M3Oep-0003HU-72; Mon, 11 May 2009 06:06:35 +0000 Received: from smtp23.services.sfr.fr ([93.17.128.19]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1M2jCJ-0006ik-5q for linux-mtd@lists.infradead.org; Sat, 09 May 2009 09:50:47 +0000 Received: from smtp23.services.sfr.fr (msfrf2324 [10.18.27.38]) by msfrf2320.sfr.fr (SMTP Server) with ESMTP id 9FB26700005F for ; Sat, 9 May 2009 11:43:06 +0200 (CEST) Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2324.sfr.fr (SMTP Server) with ESMTP id 3F73E7000094; Sat, 9 May 2009 11:42:52 +0200 (CEST) Received: from localhost.localdomain (65.135.199-77.rev.gaoland.net [77.199.135.65]) by msfrf2324.sfr.fr (SMTP Server) with ESMTP id AB13B7000089; Sat, 9 May 2009 11:42:51 +0200 (CEST) X-SFR-UUID: 20090509094251700.AB13B7000089@msfrf2324.sfr.fr From: Corentin Chary To: linux-mtd@lists.infradead.org Subject: [PATCH 1/3] libubi: add ubi_is_mapped() function Date: Sat, 9 May 2009 11:41:06 +0200 Message-Id: <1241862068-10596-2-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.6.3 In-Reply-To: <1241862068-10596-1-git-send-email-corentincj@iksaif.net> References: <1241862068-10596-1-git-send-email-corentincj@iksaif.net> X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. X-Spam-Score: 1.1 (+) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- 1.1 RCVD_IN_SORBS_WEB RBL: SORBS: sender is a abuseable web server [77.199.135.65 listed in dnsbl.sorbs.net] X-Mailman-Approved-At: Mon, 11 May 2009 02:06:26 -0400 Cc: Corentin Chary , vapier.adi@gmail.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Corentin Chary --- ubi-utils/include/libubi.h | 17 +++++++++++++++++ ubi-utils/src/libubi.c | 5 +++++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/ubi-utils/include/libubi.h b/ubi-utils/include/libubi.h index 4ffe1e8..f52904d 100644 --- a/ubi-utils/include/libubi.h +++ b/ubi-utils/include/libubi.h @@ -414,6 +414,23 @@ int ubi_set_property(int fd, uint8_t property, uint64_t value); */ int ubi_leb_unmap(int fd, int lnum); +/** + * ubi_is_mapped - check if logical eraseblock is mapped. + * @fd: volume character device file descriptor + * @lnum: logical eraseblock number + * + * This function checks if logical eraseblock @lnum is mapped to a physical + * eraseblock. If a logical eraseblock is un-mapped, this does not necessarily + * mean it will still be un-mapped after the UBI device is re-attached. The + * logical eraseblock may become mapped to the physical eraseblock it was last + * mapped to. + * + * This function returns %1 if the LEB is mapped, %0 if not, and %-1 in case of + * failure. If the volume is damaged because of an interrupted update errno + * set with %EBADF error code. + */ +int ubi_is_mapped(int fd, int lnum); + #ifdef __cplusplus } #endif diff --git a/ubi-utils/src/libubi.c b/ubi-utils/src/libubi.c index 5c8ce9e..a81173d 100644 --- a/ubi-utils/src/libubi.c +++ b/ubi-utils/src/libubi.c @@ -1255,3 +1255,8 @@ int ubi_leb_unmap(int fd, int lnum) { return ioctl(fd, UBI_IOCEBUNMAP, &lnum); } + +int ubi_is_mapped(int fd, int lnum) +{ + return ioctl(fd, UBI_IOCEBISMAP, &lnum); +}