Commit fa5a4901 authored by Brian Gerst's avatar Brian Gerst Committed by Linus Torvalds

[PATCH] struct super_block cleanup - cramfs

Seperates cramfs_sb_info from struct super_block.
parent 10caf7bf
...@@ -20,16 +20,12 @@ ...@@ -20,16 +20,12 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/cramfs_fs.h> #include <linux/cramfs_fs.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/slab.h>
#include <linux/cramfs_fs_sb.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#define CRAMFS_SB_MAGIC u.cramfs_sb.magic
#define CRAMFS_SB_SIZE u.cramfs_sb.size
#define CRAMFS_SB_BLOCKS u.cramfs_sb.blocks
#define CRAMFS_SB_FILES u.cramfs_sb.files
#define CRAMFS_SB_FLAGS u.cramfs_sb.flags
static struct super_operations cramfs_ops; static struct super_operations cramfs_ops;
static struct inode_operations cramfs_dir_inode_operations; static struct inode_operations cramfs_dir_inode_operations;
static struct file_operations cramfs_directory_operations; static struct file_operations cramfs_directory_operations;
...@@ -188,12 +184,23 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i ...@@ -188,12 +184,23 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i
return read_buffers[buffer] + offset; return read_buffers[buffer] + offset;
} }
static void cramfs_put_super(struct super_block *sb)
{
kfree(sb->u.generic_sbp);
sb->u.generic_sbp = NULL;
}
static int cramfs_fill_super(struct super_block *sb, void *data, int silent) static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
{ {
int i; int i;
struct cramfs_super super; struct cramfs_super super;
unsigned long root_offset; unsigned long root_offset;
struct cramfs_sb_info *sbi;
sbi = kmalloc(sizeof(struct cramfs_sb_info), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->u.generic_sbp = sbi;
sb_set_blocksize(sb, PAGE_CACHE_SIZE); sb_set_blocksize(sb, PAGE_CACHE_SIZE);
...@@ -229,16 +236,16 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -229,16 +236,16 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
} }
root_offset = super.root.offset << 2; root_offset = super.root.offset << 2;
if (super.flags & CRAMFS_FLAG_FSID_VERSION_2) { if (super.flags & CRAMFS_FLAG_FSID_VERSION_2) {
sb->CRAMFS_SB_SIZE=super.size; sbi->size=super.size;
sb->CRAMFS_SB_BLOCKS=super.fsid.blocks; sbi->blocks=super.fsid.blocks;
sb->CRAMFS_SB_FILES=super.fsid.files; sbi->files=super.fsid.files;
} else { } else {
sb->CRAMFS_SB_SIZE=1<<28; sbi->size=1<<28;
sb->CRAMFS_SB_BLOCKS=0; sbi->blocks=0;
sb->CRAMFS_SB_FILES=0; sbi->files=0;
} }
sb->CRAMFS_SB_MAGIC=super.magic; sbi->magic=super.magic;
sb->CRAMFS_SB_FLAGS=super.flags; sbi->flags=super.flags;
if (root_offset == 0) if (root_offset == 0)
printk(KERN_INFO "cramfs: empty filesystem"); printk(KERN_INFO "cramfs: empty filesystem");
else if (!(super.flags & CRAMFS_FLAG_SHIFTED_ROOT_OFFSET) && else if (!(super.flags & CRAMFS_FLAG_SHIFTED_ROOT_OFFSET) &&
...@@ -254,6 +261,8 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -254,6 +261,8 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
sb->s_root = d_alloc_root(get_cramfs_inode(sb, &super.root)); sb->s_root = d_alloc_root(get_cramfs_inode(sb, &super.root));
return 0; return 0;
out: out:
kfree(sbi);
sb->u.generic_sbp = NULL;
return -EINVAL; return -EINVAL;
} }
...@@ -261,10 +270,10 @@ static int cramfs_statfs(struct super_block *sb, struct statfs *buf) ...@@ -261,10 +270,10 @@ static int cramfs_statfs(struct super_block *sb, struct statfs *buf)
{ {
buf->f_type = CRAMFS_MAGIC; buf->f_type = CRAMFS_MAGIC;
buf->f_bsize = PAGE_CACHE_SIZE; buf->f_bsize = PAGE_CACHE_SIZE;
buf->f_blocks = sb->CRAMFS_SB_BLOCKS; buf->f_blocks = CRAMFS_SB(sb)->blocks;
buf->f_bfree = 0; buf->f_bfree = 0;
buf->f_bavail = 0; buf->f_bavail = 0;
buf->f_files = sb->CRAMFS_SB_FILES; buf->f_files = CRAMFS_SB(sb)->files;
buf->f_ffree = 0; buf->f_ffree = 0;
buf->f_namelen = CRAMFS_MAXPATHLEN; buf->f_namelen = CRAMFS_MAXPATHLEN;
return 0; return 0;
...@@ -334,7 +343,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry) ...@@ -334,7 +343,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry)
int sorted; int sorted;
lock_kernel(); lock_kernel();
sorted = dir->i_sb->CRAMFS_SB_FLAGS & CRAMFS_FLAG_SORTED_DIRS; sorted = CRAMFS_SB(dir->i_sb)->flags & CRAMFS_FLAG_SORTED_DIRS;
while (offset < dir->i_size) { while (offset < dir->i_size) {
struct cramfs_inode *de; struct cramfs_inode *de;
char *name; char *name;
...@@ -445,6 +454,7 @@ static struct inode_operations cramfs_dir_inode_operations = { ...@@ -445,6 +454,7 @@ static struct inode_operations cramfs_dir_inode_operations = {
}; };
static struct super_operations cramfs_ops = { static struct super_operations cramfs_ops = {
put_super: cramfs_put_super,
statfs: cramfs_statfs, statfs: cramfs_statfs,
}; };
......
...@@ -12,4 +12,9 @@ struct cramfs_sb_info { ...@@ -12,4 +12,9 @@ struct cramfs_sb_info {
unsigned long flags; unsigned long flags;
}; };
static inline struct cramfs_sb_info *CRAMFS_SB(struct super_block *sb)
{
return sb->u.generic_sbp;
}
#endif #endif
...@@ -290,7 +290,6 @@ extern void set_bh_page(struct buffer_head *bh, struct page *page, unsigned long ...@@ -290,7 +290,6 @@ extern void set_bh_page(struct buffer_head *bh, struct page *page, unsigned long
#include <linux/pipe_fs_i.h> #include <linux/pipe_fs_i.h>
/* #include <linux/umsdos_fs_i.h> */ /* #include <linux/umsdos_fs_i.h> */
#include <linux/romfs_fs_i.h> #include <linux/romfs_fs_i.h>
#include <linux/cramfs_fs_sb.h>
/* /*
* Attribute flags. These should be or-ed together to figure out what * Attribute flags. These should be or-ed together to figure out what
...@@ -669,7 +668,6 @@ struct quota_mount_options ...@@ -669,7 +668,6 @@ struct quota_mount_options
#include <linux/bfs_fs_sb.h> #include <linux/bfs_fs_sb.h>
#include <linux/udf_fs_sb.h> #include <linux/udf_fs_sb.h>
#include <linux/ncp_fs_sb.h> #include <linux/ncp_fs_sb.h>
#include <linux/cramfs_fs_sb.h>
#include <linux/jffs2_fs_sb.h> #include <linux/jffs2_fs_sb.h>
extern struct list_head super_blocks; extern struct list_head super_blocks;
...@@ -728,7 +726,6 @@ struct super_block { ...@@ -728,7 +726,6 @@ struct super_block {
struct udf_sb_info udf_sb; struct udf_sb_info udf_sb;
struct ncp_sb_info ncpfs_sb; struct ncp_sb_info ncpfs_sb;
struct jffs2_sb_info jffs2_sb; struct jffs2_sb_info jffs2_sb;
struct cramfs_sb_info cramfs_sb;
void *generic_sbp; void *generic_sbp;
} u; } u;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment