Skip to content

Commit ac8d35c

Browse files
andidrLinus Torvalds
authored andcommitted
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 <lists-receive@programmierforen.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7f44c36 commit ac8d35c

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎fs/cramfs/inode.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,21 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
258258

259259
/* Do sanity checks on the superblock */
260260
if (super.magic != CRAMFS_MAGIC) {
261+
/* check for wrong endianess */
262+
if (super.magic == CRAMFS_MAGIC_WEND) {
263+
if (!silent)
264+
printk(KERN_ERR "cramfs: wrong endianess\n");
265+
goto out;
266+
}
267+
261268
/* check at 512 byte offset */
262269
mutex_lock(&read_mutex);
263270
memcpy(&super, cramfs_read(sb, 512, sizeof(super)), sizeof(super));
264271
mutex_unlock(&read_mutex);
265272
if (super.magic != CRAMFS_MAGIC) {
266-
if (!silent)
273+
if (super.magic == CRAMFS_MAGIC_WEND && !silent)
274+
printk(KERN_ERR "cramfs: wrong endianess\n");
275+
else if (!silent)
267276
printk(KERN_ERR "cramfs: wrong magic\n");
268277
goto out;
269278
}

‎include/linux/cramfs_fs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/types.h>
55

66
#define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
7+
#define CRAMFS_MAGIC_WEND 0x453dcd28 /* magic number with the wrong endianess */
78
#define CRAMFS_SIGNATURE "Compressed ROMFS"
89

910
/*

0 commit comments

Comments
 (0)