Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ac8d35c5658377c280dc830352f66233e2f76f73
Commit:     ac8d35c5658377c280dc830352f66233e2f76f73
Parent:     7f44c3621a41576d755668c48d0caf894c228fa9
Author:     Andi Drebes <[EMAIL PROTECTED]>
AuthorDate: Tue Oct 16 23:27:12 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Wed Oct 17 08:42:53 2007 -0700

    cramfs: error message about endianess
    
    The README file in the cramfs subdirectory says: "All data is currently in
    host-endian format; neither mkcramfs nor the kernel ever do swabbing."
    
    If somebody tries to mount a cramfs with the wrong endianess, cramfs only
    complains about a wrong magic but doesn't inform the user that only the
    endianess isn't right.
    
    The following patch adds an error message to the cramfs sources.  If a user
    tries to mount a cramfs with the wrong endianess using the patched sources,
    cramfs will display the message "cramfs: wrong endianess".
    
    Signed-off-by: Andi Drebes <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/cramfs/inode.c         |   11 ++++++++++-
 include/linux/cramfs_fs.h |    1 +
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 3d194a2..5c817bd 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -258,12 +258,21 @@ static int cramfs_fill_super(struct super_block *sb, void 
*data, int silent)
 
        /* Do sanity checks on the superblock */
        if (super.magic != CRAMFS_MAGIC) {
+               /* check for wrong endianess */
+               if (super.magic == CRAMFS_MAGIC_WEND) {
+                       if (!silent)
+                               printk(KERN_ERR "cramfs: wrong endianess\n");
+                       goto out;
+               }
+
                /* check at 512 byte offset */
                mutex_lock(&read_mutex);
                memcpy(&super, cramfs_read(sb, 512, sizeof(super)), 
sizeof(super));
                mutex_unlock(&read_mutex);
                if (super.magic != CRAMFS_MAGIC) {
-                       if (!silent)
+                       if (super.magic == CRAMFS_MAGIC_WEND && !silent)
+                               printk(KERN_ERR "cramfs: wrong endianess\n");
+                       else if (!silent)
                                printk(KERN_ERR "cramfs: wrong magic\n");
                        goto out;
                }
diff --git a/include/linux/cramfs_fs.h b/include/linux/cramfs_fs.h
index 1dba681..3be4e5a 100644
--- a/include/linux/cramfs_fs.h
+++ b/include/linux/cramfs_fs.h
@@ -4,6 +4,7 @@
 #include <linux/types.h>
 
 #define CRAMFS_MAGIC           0x28cd3d45      /* some random number */
+#define CRAMFS_MAGIC_WEND      0x453dcd28      /* magic number with the wrong 
endianess */
 #define CRAMFS_SIGNATURE       "Compressed ROMFS"
 
 /*
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to