]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/cramfs/inode.c
class: rename "subsys" to "class_subsys" in internal class structure
[linux-2.6-omap-h63xx.git] / fs / cramfs / inode.c
index 3d194a2be3f511e869a541d9b782d6cbe5dddaec..0c3b618c15b3f05bd1adee50fada78b7561a36dc 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/buffer_head.h>
 #include <linux/vfs.h>
 #include <linux/mutex.h>
-#include <asm/semaphore.h>
 
 #include <asm/uaccess.h>
 
@@ -148,7 +147,7 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i
 {
        struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
        struct page *pages[BLKS_PER_BUF];
-       unsigned i, blocknr, buffer, unread;
+       unsigned i, blocknr, buffer;
        unsigned long devsize;
        char *data;
 
@@ -175,7 +174,6 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i
        devsize = mapping->host->i_size >> PAGE_CACHE_SHIFT;
 
        /* Ok, read in BLKS_PER_BUF pages completely first. */
-       unread = 0;
        for (i = 0; i < BLKS_PER_BUF; i++) {
                struct page *page = NULL;
 
@@ -258,12 +256,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;
                }
@@ -353,7 +360,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
        if (offset & 3)
                return -EINVAL;
 
-       buf = kmalloc(256, GFP_KERNEL);
+       buf = kmalloc(CRAMFS_MAXPATHLEN, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
 
@@ -367,7 +374,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
                int namelen, error;
 
                mutex_lock(&read_mutex);
-               de = cramfs_read(sb, OFFSET(inode) + offset, sizeof(*de)+256);
+               de = cramfs_read(sb, OFFSET(inode) + offset, sizeof(*de)+CRAMFS_MAXPATHLEN);
                name = (char *)(de+1);
 
                /*
@@ -417,7 +424,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s
                char *name;
                int namelen, retval;
 
-               de = cramfs_read(dir->i_sb, OFFSET(dir) + offset, sizeof(*de)+256);
+               de = cramfs_read(dir->i_sb, OFFSET(dir) + offset, sizeof(*de)+CRAMFS_MAXPATHLEN);
                name = (char *)(de+1);
 
                /* Try to take advantage of sorted directories */