public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yasushi SHOJI <yashi@atmark-techno.com>
To: linux-kernel@vger.kernel.org
Cc: Janos Farkas <jf-ml-k1-1087813225@lk8rp.mail.xeon.eu.org>
Subject: [PATCH] add romfs_get_size()
Date: Wed, 07 Sep 2005 23:22:19 +0900	[thread overview]
Message-ID: <87k6htt0tg.wl@mail2.atmark-techno.com> (raw)

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 <yashi@atmark-techno.com>
---
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


             reply	other threads:[~2005-09-07 14:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-07 14:22 Yasushi SHOJI [this message]
2005-09-07 14:26 ` [PATCH] add romfs_get_size() Christoph Hellwig
2005-09-07 14:31   ` Yasushi SHOJI
2005-09-07 15:04     ` Christoph Hellwig
2005-09-07 15:34       ` Yasushi SHOJI
2005-09-08  7:07         ` Greg Ungerer
2005-09-08  7:39           ` Yasushi SHOJI

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k6htt0tg.wl@mail2.atmark-techno.com \
    --to=yashi@atmark-techno.com \
    --cc=jf-ml-k1-1087813225@lk8rp.mail.xeon.eu.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox