X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fcramfs%2Finode.c;fp=fs%2Fcramfs%2Finode.c;h=30fdd5dc73bd1cd89586f2f99499401ab6fbf292;hb=64ba3f394c830ec48a1c31b53dcae312c56f1604;hp=0e2294c035e5400eebb64f8f389b780a6b4d5607;hpb=be1e6109ac94a859551f8e1774eb9a8469fe055c;p=linux-2.6.git diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 0e2294c03..30fdd5dc7 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -22,17 +22,16 @@ #include #include #include -#include #include #include static struct super_operations cramfs_ops; static struct inode_operations cramfs_dir_inode_operations; -static const struct file_operations cramfs_directory_operations; -static const struct address_space_operations cramfs_aops; +static struct file_operations cramfs_directory_operations; +static struct address_space_operations cramfs_aops; -static DEFINE_MUTEX(read_mutex); +static DECLARE_MUTEX(read_mutex); /* These two macros may change in future, to provide better st_ino @@ -73,6 +72,7 @@ static int cramfs_iget5_set(struct inode *inode, void *opaque) inode->i_uid = cramfs_inode->uid; inode->i_size = cramfs_inode->size; inode->i_blocks = (cramfs_inode->size - 1) / 512 + 1; + inode->i_blksize = PAGE_CACHE_SIZE; inode->i_gid = cramfs_inode->gid; /* Struct copy intentional */ inode->i_mtime = inode->i_atime = inode->i_ctime = zerotime; @@ -180,7 +180,9 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i struct page *page = NULL; if (blocknr + i < devsize) { - page = read_mapping_page(mapping, blocknr + i, NULL); + page = read_cache_page(mapping, blocknr + i, + (filler_t *)mapping->a_ops->readpage, + NULL); /* synchronous error? */ if (IS_ERR(page)) page = NULL; @@ -248,20 +250,20 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent) memset(sbi, 0, sizeof(struct cramfs_sb_info)); /* Invalidate the read buffers on mount: think disk change.. */ - mutex_lock(&read_mutex); + down(&read_mutex); for (i = 0; i < READ_BUFFERS; i++) buffer_blocknr[i] = -1; /* Read the first block and get the superblock from it */ memcpy(&super, cramfs_read(sb, 0, sizeof(super)), sizeof(super)); - mutex_unlock(&read_mutex); + up(&read_mutex); /* Do sanity checks on the superblock */ if (super.magic != CRAMFS_MAGIC) { /* check at 512 byte offset */ - mutex_lock(&read_mutex); + down(&read_mutex); memcpy(&super, cramfs_read(sb, 512, sizeof(super)), sizeof(super)); - mutex_unlock(&read_mutex); + up(&read_mutex); if (super.magic != CRAMFS_MAGIC) { if (!silent) printk(KERN_ERR "cramfs: wrong magic\n"); @@ -319,10 +321,8 @@ out: return -EINVAL; } -static int cramfs_statfs(struct dentry *dentry, struct kstatfs *buf) +static int cramfs_statfs(struct super_block *sb, struct kstatfs *buf) { - struct super_block *sb = dentry->d_sb; - buf->f_type = CRAMFS_MAGIC; buf->f_bsize = PAGE_CACHE_SIZE; buf->f_blocks = CRAMFS_SB(sb)->blocks; @@ -366,7 +366,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir) mode_t mode; int namelen, error; - mutex_lock(&read_mutex); + down(&read_mutex); de = cramfs_read(sb, OFFSET(inode) + offset, sizeof(*de)+256); name = (char *)(de+1); @@ -379,7 +379,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir) memcpy(buf, name, namelen); ino = CRAMINO(de); mode = de->mode; - mutex_unlock(&read_mutex); + up(&read_mutex); nextoffset = offset + sizeof(*de) + namelen; for (;;) { if (!namelen) { @@ -410,7 +410,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s unsigned int offset = 0; int sorted; - mutex_lock(&read_mutex); + down(&read_mutex); sorted = CRAMFS_SB(dir->i_sb)->flags & CRAMFS_FLAG_SORTED_DIRS; while (offset < dir->i_size) { struct cramfs_inode *de; @@ -433,7 +433,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s for (;;) { if (!namelen) { - mutex_unlock(&read_mutex); + up(&read_mutex); return ERR_PTR(-EIO); } if (name[namelen-1]) @@ -447,7 +447,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s continue; if (!retval) { struct cramfs_inode entry = *de; - mutex_unlock(&read_mutex); + up(&read_mutex); d_add(dentry, get_cramfs_inode(dir->i_sb, &entry)); return NULL; } @@ -455,7 +455,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s if (sorted) break; } - mutex_unlock(&read_mutex); + up(&read_mutex); d_add(dentry, NULL); return NULL; } @@ -474,23 +474,23 @@ static int cramfs_readpage(struct file *file, struct page * page) u32 start_offset, compr_len; start_offset = OFFSET(inode) + maxblock*4; - mutex_lock(&read_mutex); + down(&read_mutex); if (page->index) start_offset = *(u32 *) cramfs_read(sb, blkptr_offset-4, 4); compr_len = (*(u32 *) cramfs_read(sb, blkptr_offset, 4) - start_offset); - mutex_unlock(&read_mutex); + up(&read_mutex); pgdata = kmap(page); if (compr_len == 0) ; /* hole */ else if (compr_len > (PAGE_CACHE_SIZE << 1)) printk(KERN_ERR "cramfs: bad compressed blocksize %u\n", compr_len); else { - mutex_lock(&read_mutex); + down(&read_mutex); bytes_filled = cramfs_uncompress_block(pgdata, PAGE_CACHE_SIZE, cramfs_read(sb, start_offset, compr_len), compr_len); - mutex_unlock(&read_mutex); + up(&read_mutex); } } else pgdata = kmap(page); @@ -502,7 +502,7 @@ static int cramfs_readpage(struct file *file, struct page * page) return 0; } -static const struct address_space_operations cramfs_aops = { +static struct address_space_operations cramfs_aops = { .readpage = cramfs_readpage }; @@ -513,7 +513,7 @@ static const struct address_space_operations cramfs_aops = { /* * A directory can only readdir */ -static const struct file_operations cramfs_directory_operations = { +static struct file_operations cramfs_directory_operations = { .llseek = generic_file_llseek, .read = generic_read_dir, .readdir = cramfs_readdir, @@ -529,11 +529,10 @@ static struct super_operations cramfs_ops = { .statfs = cramfs_statfs, }; -static int cramfs_get_sb(struct file_system_type *fs_type, - int flags, const char *dev_name, void *data, struct vfsmount *mnt) +static struct super_block *cramfs_get_sb(struct file_system_type *fs_type, + int flags, const char *dev_name, void *data) { - return get_sb_bdev(fs_type, flags, dev_name, data, cramfs_fill_super, - mnt); + return get_sb_bdev(fs_type, flags, dev_name, data, cramfs_fill_super); } static struct file_system_type cramfs_fs_type = {