Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751225AbVIGOWe (ORCPT ); Wed, 7 Sep 2005 10:22:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751221AbVIGOWe (ORCPT ); Wed, 7 Sep 2005 10:22:34 -0400 Received: from shop.atmark-techno.com ([210.191.215.173]:28581 "EHLO mail2.atmark-techno.com") by vger.kernel.org with ESMTP id S932134AbVIGOWd (ORCPT ); Wed, 7 Sep 2005 10:22:33 -0400 Date: Wed, 07 Sep 2005 23:22:19 +0900 Message-ID: <87k6htt0tg.wl@mail2.atmark-techno.com> From: Yasushi SHOJI To: linux-kernel@vger.kernel.org Cc: Janos Farkas Subject: [PATCH] add romfs_get_size() User-Agent: Wanderlust/2.14.0 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1707 Lines: 59 Many embedded linux products have been using romfs and it's still growing. most, if not all, of them implement thier own way to check its romfs size. this patch provides this commonly used function. Signed-off-by: Yasushi SHOJI --- diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c --- a/fs/romfs/inode.c +++ b/fs/romfs/inode.c @@ -84,6 +84,17 @@ struct romfs_inode_info { struct inode vfs_inode; }; +int romfs_get_size(struct romfs_super_block *rsb) +{ + int sz = be32_to_cpu(rsb->size); + if (rsb->word0 != ROMSB_WORD0 || rsb->word1 != ROMSB_WORD1 + || sz < ROMFH_SIZE) { + sz = -1; + } + return sz; +} +EXPORT_SYMBOL(romfs_get_size); + /* instead of private superblock data */ static inline unsigned long romfs_maxsize(struct super_block *sb) { @@ -132,9 +143,8 @@ static int romfs_fill_super(struct super } rsb = (struct romfs_super_block *)bh->b_data; - sz = be32_to_cpu(rsb->size); - if (rsb->word0 != ROMSB_WORD0 || rsb->word1 != ROMSB_WORD1 - || sz < ROMFH_SIZE) { + sz = romfs_get_size(rsb); + if (sz == -1) { if (!silent) printk ("VFS: Can't find a romfs filesystem on dev " "%s.\n", s->s_id); diff --git a/include/linux/romfs_fs.h b/include/linux/romfs_fs.h --- a/include/linux/romfs_fs.h +++ b/include/linux/romfs_fs.h @@ -55,7 +55,7 @@ struct romfs_inode { #ifdef __KERNEL__ -/* Not much now */ +int romfs_get_size(struct romfs_super_block *rsb); #endif /* __KERNEL__ */ #endif - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/