Commit 2191d229 authored by Brian Gerst's avatar Brian Gerst Committed by Linus Torvalds

[PATCH] struct super_block cleanup - msdos/vfat

Seperates msdos_sb_info from struct super_block for msdos and vfat.
Umsdos is terminally broken and is not included.
parent be5fc736
...@@ -24,7 +24,7 @@ EXPORT_SYMBOL(fat_put_super); ...@@ -24,7 +24,7 @@ EXPORT_SYMBOL(fat_put_super);
EXPORT_SYMBOL(fat_attach); EXPORT_SYMBOL(fat_attach);
EXPORT_SYMBOL(fat_detach); EXPORT_SYMBOL(fat_detach);
EXPORT_SYMBOL(fat_build_inode); EXPORT_SYMBOL(fat_build_inode);
EXPORT_SYMBOL(fat_read_super); EXPORT_SYMBOL(fat_fill_super);
EXPORT_SYMBOL(fat_search_long); EXPORT_SYMBOL(fat_search_long);
EXPORT_SYMBOL(fat_readdir); EXPORT_SYMBOL(fat_readdir);
EXPORT_SYMBOL(fat_scan); EXPORT_SYMBOL(fat_scan);
......
...@@ -167,32 +167,36 @@ void fat_clear_inode(struct inode *inode) ...@@ -167,32 +167,36 @@ void fat_clear_inode(struct inode *inode)
void fat_put_super(struct super_block *sb) void fat_put_super(struct super_block *sb)
{ {
if (MSDOS_SB(sb)->cvf_format->cvf_version) { struct msdos_sb_info *sbi = MSDOS_SB(sb);
dec_cvf_format_use_count_by_version(MSDOS_SB(sb)->cvf_format->cvf_version);
MSDOS_SB(sb)->cvf_format->unmount_cvf(sb); if (sbi->cvf_format->cvf_version) {
dec_cvf_format_use_count_by_version(sbi->cvf_format->cvf_version);
sbi->cvf_format->unmount_cvf(sb);
} }
if (MSDOS_SB(sb)->fat_bits == 32) { if (sbi->fat_bits == 32) {
fat_clusters_flush(sb); fat_clusters_flush(sb);
} }
fat_cache_inval_dev(sb); fat_cache_inval_dev(sb);
set_blocksize (sb->s_dev,BLOCK_SIZE); set_blocksize (sb->s_dev,BLOCK_SIZE);
if (MSDOS_SB(sb)->nls_disk) { if (sbi->nls_disk) {
unload_nls(MSDOS_SB(sb)->nls_disk); unload_nls(sbi->nls_disk);
MSDOS_SB(sb)->nls_disk = NULL; sbi->nls_disk = NULL;
MSDOS_SB(sb)->options.codepage = 0; sbi->options.codepage = 0;
} }
if (MSDOS_SB(sb)->nls_io) { if (sbi->nls_io) {
unload_nls(MSDOS_SB(sb)->nls_io); unload_nls(sbi->nls_io);
MSDOS_SB(sb)->nls_io = NULL; sbi->nls_io = NULL;
} }
/* /*
* Note: the iocharset option might have been specified * Note: the iocharset option might have been specified
* without enabling nls_io, so check for it here. * without enabling nls_io, so check for it here.
*/ */
if (MSDOS_SB(sb)->options.iocharset) { if (sbi->options.iocharset) {
kfree(MSDOS_SB(sb)->options.iocharset); kfree(sbi->options.iocharset);
MSDOS_SB(sb)->options.iocharset = NULL; sbi->options.iocharset = NULL;
} }
sb->u.generic_sbp = NULL;
kfree(sbi);
} }
...@@ -582,18 +586,14 @@ static struct super_operations fat_sops = { ...@@ -582,18 +586,14 @@ static struct super_operations fat_sops = {
/* /*
* Read the super block of an MS-DOS FS. * Read the super block of an MS-DOS FS.
*
* Note that this may be called from vfat_read_super
* with some fields already initialized.
*/ */
struct super_block * int fat_fill_super(struct super_block *sb, void *data, int silent,
fat_read_super(struct super_block *sb, void *data, int silent, struct inode_operations *fs_dir_inode_ops, int isvfat)
struct inode_operations *fs_dir_inode_ops)
{ {
struct inode *root_inode; struct inode *root_inode;
struct buffer_head *bh; struct buffer_head *bh;
struct fat_boot_sector *b; struct fat_boot_sector *b;
struct msdos_sb_info *sbi = MSDOS_SB(sb); struct msdos_sb_info *sbi;
int logical_sector_size, fat_clusters, debug, cp; int logical_sector_size, fat_clusters, debug, cp;
unsigned int total_sectors, rootdir_sectors; unsigned int total_sectors, rootdir_sectors;
long error = -EIO; long error = -EIO;
...@@ -602,12 +602,19 @@ fat_read_super(struct super_block *sb, void *data, int silent, ...@@ -602,12 +602,19 @@ fat_read_super(struct super_block *sb, void *data, int silent,
char cvf_format[21]; char cvf_format[21];
char cvf_options[101]; char cvf_options[101];
sbi = kmalloc(sizeof(struct msdos_sb_info), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->u.generic_sbp = sbi;
memset(sbi, 0, sizeof(struct msdos_sb_info));
cvf_format[0] = '\0'; cvf_format[0] = '\0';
cvf_options[0] = '\0'; cvf_options[0] = '\0';
sbi->private_data = NULL; sbi->private_data = NULL;
sb->s_magic = MSDOS_SUPER_MAGIC; sb->s_magic = MSDOS_SUPER_MAGIC;
sb->s_op = &fat_sops; sb->s_op = &fat_sops;
sbi->options.isvfat = isvfat;
sbi->dir_ops = fs_dir_inode_ops; sbi->dir_ops = fs_dir_inode_ops;
sbi->cvf_format = &default_cvf; sbi->cvf_format = &default_cvf;
...@@ -830,10 +837,10 @@ fat_read_super(struct super_block *sb, void *data, int silent, ...@@ -830,10 +837,10 @@ fat_read_super(struct super_block *sb, void *data, int silent,
sbi->cvf_format = cvf_formats[i]; sbi->cvf_format = cvf_formats[i];
++cvf_format_use_count[i]; ++cvf_format_use_count[i];
} }
return sb; return 0;
out_invalid: out_invalid:
error = 0; error = -EINVAL;
out_fail: out_fail:
if (sbi->nls_io) if (sbi->nls_io)
...@@ -845,8 +852,10 @@ fat_read_super(struct super_block *sb, void *data, int silent, ...@@ -845,8 +852,10 @@ fat_read_super(struct super_block *sb, void *data, int silent,
if (sbi->private_data) if (sbi->private_data)
kfree(sbi->private_data); kfree(sbi->private_data);
sbi->private_data = NULL; sbi->private_data = NULL;
sb->u.generic_sbp = NULL;
kfree(sbi);
return ERR_PTR(error); return error;
} }
int fat_statfs(struct super_block *sb,struct statfs *buf) int fat_statfs(struct super_block *sb,struct statfs *buf)
......
...@@ -603,17 +603,14 @@ struct inode_operations msdos_dir_inode_operations = { ...@@ -603,17 +603,14 @@ struct inode_operations msdos_dir_inode_operations = {
int msdos_fill_super(struct super_block *sb,void *data, int silent) int msdos_fill_super(struct super_block *sb,void *data, int silent)
{ {
struct super_block *res; int res;
MSDOS_SB(sb)->options.isvfat = 0; res = fat_fill_super(sb, data, silent, &msdos_dir_inode_operations, 0);
res = fat_read_super(sb, data, silent, &msdos_dir_inode_operations); if (res) {
if (IS_ERR(res))
return PTR_ERR(res);
if (res == NULL) {
if (!silent) if (!silent)
printk(KERN_INFO "VFS: Can't find a valid" printk(KERN_INFO "VFS: Can't find a valid"
" MSDOS filesystem on dev %s.\n", sb->s_id); " MSDOS filesystem on dev %s.\n", sb->s_id);
return -EINVAL; return res;
} }
sb->s_root->d_op = &msdos_dentry_operations; sb->s_root->d_op = &msdos_dentry_operations;
......
...@@ -1285,25 +1285,25 @@ struct inode_operations vfat_dir_inode_operations = { ...@@ -1285,25 +1285,25 @@ struct inode_operations vfat_dir_inode_operations = {
int vfat_fill_super(struct super_block *sb, void *data, int silent) int vfat_fill_super(struct super_block *sb, void *data, int silent)
{ {
struct super_block *res; int res;
struct msdos_sb_info *sbi;
MSDOS_SB(sb)->options.isvfat = 1; res = fat_fill_super(sb, data, silent, &vfat_dir_inode_operations, 1);
res = fat_read_super(sb, data, silent, &vfat_dir_inode_operations); if (res) {
if (IS_ERR(res))
return PTR_ERR(res);
if (res == NULL) {
if (!silent) if (!silent)
printk(KERN_INFO "VFS: Can't find a valid" printk(KERN_INFO "VFS: Can't find a valid"
" VFAT filesystem on dev %s.\n", sb->s_id); " VFAT filesystem on dev %s.\n", sb->s_id);
return -EINVAL; return res;
} }
if (parse_options((char *) data, &(MSDOS_SB(sb)->options))) { sbi = MSDOS_SB(sb);
MSDOS_SB(sb)->options.dotsOK = 0;
if (MSDOS_SB(sb)->options.posixfs) { if (parse_options((char *) data, &(sbi->options))) {
MSDOS_SB(sb)->options.name_check = 's'; sbi->options.dotsOK = 0;
if (sbi->options.posixfs) {
sbi->options.name_check = 's';
} }
if (MSDOS_SB(sb)->options.name_check != 's') { if (sbi->options.name_check != 's') {
sb->s_root->d_op = &vfat_dentry_ops[0]; sb->s_root->d_op = &vfat_dentry_ops[0];
} else { } else {
sb->s_root->d_op = &vfat_dentry_ops[2]; sb->s_root->d_op = &vfat_dentry_ops[2];
......
...@@ -648,7 +648,6 @@ struct quota_mount_options ...@@ -648,7 +648,6 @@ struct quota_mount_options
#include <linux/ext3_fs_sb.h> #include <linux/ext3_fs_sb.h>
#include <linux/hpfs_fs_sb.h> #include <linux/hpfs_fs_sb.h>
#include <linux/ntfs_fs_sb.h> #include <linux/ntfs_fs_sb.h>
#include <linux/msdos_fs_sb.h>
#include <linux/iso_fs_sb.h> #include <linux/iso_fs_sb.h>
#include <linux/sysv_fs_sb.h> #include <linux/sysv_fs_sb.h>
#include <linux/affs_fs_sb.h> #include <linux/affs_fs_sb.h>
...@@ -700,7 +699,6 @@ struct super_block { ...@@ -700,7 +699,6 @@ struct super_block {
struct ext3_sb_info ext3_sb; struct ext3_sb_info ext3_sb;
struct hpfs_sb_info hpfs_sb; struct hpfs_sb_info hpfs_sb;
struct ntfs_sb_info ntfs_sb; struct ntfs_sb_info ntfs_sb;
struct msdos_sb_info msdos_sb;
struct isofs_sb_info isofs_sb; struct isofs_sb_info isofs_sb;
struct sysv_sb_info sysv_sb; struct sysv_sb_info sysv_sb;
struct affs_sb_info affs_sb; struct affs_sb_info affs_sb;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* The MS-DOS filesystem constants/structures * The MS-DOS filesystem constants/structures
*/ */
#include <linux/msdos_fs_i.h> #include <linux/msdos_fs_i.h>
#include <linux/msdos_fs_sb.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
...@@ -53,7 +54,11 @@ ...@@ -53,7 +54,11 @@
#define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO) #define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
/* valid file mode bits */ /* valid file mode bits */
#define MSDOS_SB(s) (&((s)->u.msdos_sb)) static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb)
{
return sb->u.generic_sbp;
}
static inline struct msdos_inode_info *MSDOS_I(struct inode *inode) static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
{ {
return list_entry(inode, struct msdos_inode_info, vfs_inode); return list_entry(inode, struct msdos_inode_info, vfs_inode);
...@@ -282,9 +287,8 @@ extern struct inode *fat_build_inode(struct super_block *sb, ...@@ -282,9 +287,8 @@ extern struct inode *fat_build_inode(struct super_block *sb,
extern void fat_delete_inode(struct inode *inode); extern void fat_delete_inode(struct inode *inode);
extern void fat_clear_inode(struct inode *inode); extern void fat_clear_inode(struct inode *inode);
extern void fat_put_super(struct super_block *sb); extern void fat_put_super(struct super_block *sb);
extern struct super_block * int fat_fill_super(struct super_block *sb, void *data, int silent,
fat_read_super(struct super_block *sb, void *data, int silent, struct inode_operations *fs_dir_inode_ops, int isvfat);
struct inode_operations *fs_dir_inode_ops);
extern int fat_statfs(struct super_block *sb, struct statfs *buf); extern int fat_statfs(struct super_block *sb, struct statfs *buf);
extern void fat_write_inode(struct inode *inode, int wait); extern void fat_write_inode(struct inode *inode, int wait);
extern int fat_notify_change(struct dentry * dentry, struct iattr * attr); extern int fat_notify_change(struct dentry * dentry, struct iattr * attr);
......
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