[PATCH][MTD-UTILS] Set mkfs.jffs2 page size runtime instead of fixed.

Ricard Wanderlof ricard.wanderlof at axis.com
Thu Dec 6 06:43:47 EST 2007


This patch reads the default PAGE_SIZE from sysconf(), i.e. the system
mkfs.jffs2 is running on, instead of just setting it to 4096 (which of 
course is valid for most systems but not all).

This is useful if mkfs.jffs2 is running on the target system, e.g. to 
create a backup image during firmware upgrade, so that the page size does 
not have to be set explicitly using a command line parameter.

The --pagesize option is supported just as before.

Patch is included both as an attachment for patching and inline for 
review. (Patch made against git head).

Signed-off-by Ricard Wanderlöf <ricardw at axis.com> .

Index: mkfs.jffs2.c
===================================================================
RCS file: /usr/local/cvs/linux/apps/utils/mtdutils/mkfs.jffs2.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- mkfs.jffs2.c	17 Oct 2006 11:40:40 -0000	1.2
+++ mkfs.jffs2.c	6 Dec 2007 07:46:47 -0000	1.3
@@ -672,9 +672,9 @@
  	0xff, 0xff, 0xff, 0xff, 0xff
  };

-/* We default to 4096, per x86.  When building a fs for
- * 64-bit arches and whatnot, use the --pagesize=SIZE option */
-int page_size = 4096;
+/* We set this at start of main() using sysconf(), -1 means we don't know */
+/* When building an fs for non-native systems, use --pagesize=SIZE option */
+int page_size = -1;

  #include "compr.h"

@@ -787,6 +787,10 @@
  	struct stat *statbuf;
  	unsigned int totcomp = 0;

+	page_size = sysconf(_SC_PAGESIZE);
+	if (page_size < 0) /* System doesn't know so ... */
+		page_size = 4096; /* ... we make an educated guess */
+
  	statbuf = &(e->sb);
  	if (statbuf->st_size >= JFFS2_MAX_FILE_SIZE) {
  		error_msg("Skipping file \"%s\" too large.", e->path);

/Ricard
--
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mkfs.jffs2.c-pagesize.patch
Type: text/x-diff
Size: 1106 bytes
Desc: patch file
Url : http://lists.infradead.org/pipermail/linux-mtd/attachments/20071206/50719129/attachment-0001.bin 


More information about the linux-mtd mailing list