This required splitting the Tux3 magic number up into two parts, the
four byte magic string "tux3", and the BCD encoded date of most recent
format revision.  Doing the magic as a string is a little different
from all other filesystems, which do it as a 32 or 16 bit int, except
for ReiserFS, which does it as three different strings and has an int
version too, for good measure.  So we are a little tidier than that.

Regards,

Daniel
diff -r 06afad8b4502 user/kernel/commit.c
--- a/user/kernel/commit.c	Wed Mar 11 20:18:36 2009 -0700
+++ b/user/kernel/commit.c	Thu Mar 12 22:16:03 2009 -0700
@@ -16,7 +16,7 @@ int load_sb(struct sb *sb)
 
 	if (err)
 		return err;
-	if (memcmp(super->magic, (char[])TUX3_MAGIC, sizeof(super->magic)))
+	if (memcmp(super->magic, TUX3_MAGIC, sizeof(super->magic)))
 		return -EINVAL;
 	sb->blockbits = from_be_u16(super->blockbits);
 	sb->blocksize = 1 << sb->blockbits;
diff -r 06afad8b4502 user/kernel/tux3.h
--- a/user/kernel/tux3.h	Wed Mar 11 20:18:36 2009 -0700
+++ b/user/kernel/tux3.h	Thu Mar 12 22:16:03 2009 -0700
@@ -10,6 +10,7 @@
 #include <linux/buffer_head.h>
 #include <linux/bio.h>
 #include <linux/mutex.h>
+#include <linux/magic.h>
 
 typedef loff_t block_t;
 
@@ -34,8 +35,6 @@ typedef u32 millisecond_t;
 typedef u32 millisecond_t;
 typedef u64 inum_t;
 typedef u64 tuxkey_t;
-
-#include "magic.h"
 
 #ifdef __KERNEL__
 /* Endian support */
@@ -208,6 +207,20 @@ static inline void flink_last_del(struct
 
 /* Tux3 disk format */
 
+#define TUX3_MAGIC TUX3_SUPER_MAGIC "\xdd\x09\x03\x10"
+/*
+ * TUX3_LABEL includes the date of the last incompatible disk format change
+ * NOTE: Always update this history for each incompatible change!
+ *
+ * Disk Format Revision History
+ *
+ * 2008-08-06: Beginning of time
+ * 2008-09-06: Actual checking starts
+ * 2008-12-12: Atom dictionary size in disksuper instead of atable->i_size
+ * 2009-02-28: Attributes renumbered, rdev added
+ * 2009-03-10: Alignment fix of disksuper
+ */
+
 #define MAX_INODES_BITS 48
 #define MAX_BLOCKS_BITS 48
 #define MAX_FILESIZE_BITS 60
@@ -227,7 +240,7 @@ struct disksuper
 struct disksuper
 {
 	/* Update magic on any incompatible format change */
-	char magic[TUX3_MAGIC_SIZE];
+	char magic[8];		/* Contains TUX3_LABEL magic string */
 	be_u64 birthdate;	/* Volume creation date */
 	be_u64 flags;		/* Need to assign some flags */
 	be_u64 iroot;		/* Root of the inode table btree */
diff -r 06afad8b4502 user/tux3.c
--- a/user/tux3.c	Wed Mar 11 20:18:36 2009 -0700
+++ b/user/tux3.c	Thu Mar 12 22:16:03 2009 -0700
@@ -110,6 +110,7 @@ int main(int argc, char *argv[])
 	/* dev->bits is still unknown. Note, some structure can't use yet. */
 	struct dev *dev = &(struct dev){ .fd = fd };
 	struct sb *sb = rapid_sb(dev);
+
 	if ((errno = -load_sb(sb)))
 		goto eek;
 	dev->bits = sb->blockbits;
diff -r 06afad8b4502 user/tux3.h
--- a/user/tux3.h	Wed Mar 11 20:18:36 2009 -0700
+++ b/user/tux3.h	Thu Mar 12 22:16:03 2009 -0700
@@ -174,6 +174,8 @@ void __free_pages(struct page *page, uns
 }
 #define __free_page(page) __free_pages((page), 0)
 
+#define TUX3_SUPER_MAGIC "tux3"
+
 #include "kernel/tux3.h"
 
 static inline struct inode *buffer_inode(struct buffer_head *buffer)
diff --git a/include/linux/magic.h b/include/linux/magic.h
index 439f6f3..fd18181 100644
--- a/include/linux/magic.h
+++ b/include/linux/magic.h
@@ -41,6 +41,7 @@
 #define REISER2FS_JR_SUPER_MAGIC_STRING	"ReIsEr3Fs"
 
 #define SMB_SUPER_MAGIC		0x517B
+#define TUX3_SUPER_MAGIC	"tux3"
 #define USBDEVICE_SUPER_MAGIC	0x9fa2
 #define CGROUP_SUPER_MAGIC	0x27e0eb
 
_______________________________________________
Tux3 mailing list
Tux3@tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3

Reply via email to