From patchwork Mon Aug 31 16:09:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 512545 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id CB2871401E7 for ; Tue, 1 Sep 2015 02:10:24 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 28B094B7EF; Mon, 31 Aug 2015 18:10:19 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OSXq1qolD-KB; Mon, 31 Aug 2015 18:10:19 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3BBEA4B795; Mon, 31 Aug 2015 18:10:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D4ABA4A039 for ; Mon, 31 Aug 2015 18:10:00 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dP2BlDZAAtA5 for ; Mon, 31 Aug 2015 18:10:00 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by theia.denx.de (Postfix) with ESMTPS id 1E2C34B7BC for ; Mon, 31 Aug 2015 18:09:56 +0200 (CEST) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 352B2C1A128C; Mon, 31 Aug 2015 16:09:55 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-5-162.ams2.redhat.com [10.36.5.162]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7VG9p0H014512; Mon, 31 Aug 2015 12:09:54 -0400 From: Hans de Goede To: Tom Rini , Heiko Schocher Date: Mon, 31 Aug 2015 18:09:49 +0200 Message-Id: <1441037390-6334-3-git-send-email-hdegoede@redhat.com> In-Reply-To: <1441037390-6334-1-git-send-email-hdegoede@redhat.com> References: <1441037390-6334-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 2/3] ubifs: Add functions for generic fs use X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Implement the necessary functions for implementing generic fs support for ubifs. Signed-off-by: Hans de Goede Reviewed-by: Heiko Schocher --- fs/ubifs/ubifs.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/ubifs_uboot.h | 4 ++++ 2 files changed, 66 insertions(+) diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index 04e9a21..4b064a6 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -568,6 +568,22 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename) return 0; } +int ubifs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info) +{ + /* Check that ubifs is mounted and that we are not being a blkdev */ + if (!ubifs_is_mounted()) { + printf("UBIFS not mounted, use ubifsmount to mount volume first!\n"); + return -1; + } + + if (rbdd) { + printf("UBIFS cannot be used with normal block devices\n"); + return -1; + } + + return 0; +} + int ubifs_ls(const char *filename) { struct ubifs_info *c = ubifs_sb->s_fs_info; @@ -616,6 +632,48 @@ out: return ret; } +int ubifs_exists(const char *filename) +{ + struct ubifs_info *c = ubifs_sb->s_fs_info; + unsigned long inum; + + c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY); + inum = ubifs_findfile(ubifs_sb, (char *)filename); + ubi_close_volume(c->ubi); + + return inum != 0; +} + +int ubifs_size(const char *filename, loff_t *size) +{ + struct ubifs_info *c = ubifs_sb->s_fs_info; + unsigned long inum; + struct inode *inode; + int err = 0; + + c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY); + + inum = ubifs_findfile(ubifs_sb, (char *)filename); + if (!inum) { + err = -1; + goto out; + } + + inode = ubifs_iget(ubifs_sb, inum); + if (IS_ERR(inode)) { + printf("%s: Error reading inode %ld!\n", __func__, inum); + err = PTR_ERR(inode); + goto out; + } + + *size = inode->i_size; + + ubifs_iput(inode); +out: + ubi_close_volume(c->ubi); + return err; +} + /* * ubifsload... */ @@ -873,6 +931,10 @@ out: return err; } +void ubifs_close(void) +{ +} + /* Compat wrappers for common/cmd_ubifs.c */ int ubifs_load(char *filename, u32 addr, u32 size) { diff --git a/include/ubifs_uboot.h b/include/ubifs_uboot.h index 3e0cd72..dab433a 100644 --- a/include/ubifs_uboot.h +++ b/include/ubifs_uboot.h @@ -21,8 +21,12 @@ void uboot_ubifs_umount(void); int ubifs_is_mounted(void); int ubifs_load(char *filename, u32 addr, u32 size); +int ubifs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info); int ubifs_ls(const char *dir_name); +int ubifs_exists(const char *filename); +int ubifs_size(const char *filename, loff_t *size); int ubifs_read(const char *filename, void *buf, loff_t offset, loff_t size, loff_t *actread); +void ubifs_close(void); #endif /* __UBIFS_UBOOT_H__ */