public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH][MTD-UTILS] Set mkfs.jffs2 page size runtime instead of fixed.
@ 2007-12-06 11:43 Ricard Wanderlof
  2007-12-07 13:03 ` Josh Boyer
  0 siblings, 1 reply; 5+ messages in thread
From: Ricard Wanderlof @ 2007-12-06 11:43 UTC (permalink / raw)
  To: Linux mtd

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1954 bytes --]


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@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

[-- Attachment #2: patch file --]
[-- Type: TEXT/x-diff, Size: 1106 bytes --]

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);

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-12-20 15:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-06 11:43 [PATCH][MTD-UTILS] Set mkfs.jffs2 page size runtime instead of fixed Ricard Wanderlof
2007-12-07 13:03 ` Josh Boyer
2007-12-10 20:00   ` Ricard Wanderlof
2007-12-20 11:46   ` [PATCH][MTD-UTILS] Set mkfs.jffs2 page size runtime instead of fixed [respoin] Ricard Wanderlof
2007-12-20 15:43     ` Josh Boyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox