Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / fs / befs / linuxvfs.c
index 9dd86d6..aa50dc6 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/buffer_head.h>
 #include <linux/vfs.h>
 #include <linux/parser.h>
+#include <linux/namei.h>
 
 #include "befs.h"
 #include "btree.h"
@@ -40,8 +41,8 @@ static struct inode *befs_alloc_inode(struct super_block *sb);
 static void befs_destroy_inode(struct inode *inode);
 static int befs_init_inodecache(void);
 static void befs_destroy_inodecache(void);
-static int befs_follow_link(struct dentry *, struct nameidata *);
-static void befs_put_link(struct dentry *, struct nameidata *);
+static void *befs_follow_link(struct dentry *, struct nameidata *);
+static void befs_put_link(struct dentry *, struct nameidata *, void *);
 static int befs_utf2nls(struct super_block *sb, const char *in, int in_len,
                        char **out, int *out_len);
 static int befs_nls2utf(struct super_block *sb, const char *in, int in_len,
@@ -63,22 +64,16 @@ static const struct super_operations befs_sops = {
 /* slab cache for befs_inode_info objects */
 static kmem_cache_t *befs_inode_cachep;
 
-struct file_operations befs_dir_operations = {
+static const struct file_operations befs_dir_operations = {
        .read           = generic_read_dir,
        .readdir        = befs_readdir,
 };
 
-struct inode_operations befs_dir_inode_operations = {
+static struct inode_operations befs_dir_inode_operations = {
        .lookup         = befs_lookup,
 };
 
-struct file_operations befs_file_operations = {
-       .llseek         = default_llseek,
-       .read           = generic_file_read,
-       .mmap           = generic_file_readonly_mmap,
-};
-
-struct address_space_operations befs_aops = {
+static struct address_space_operations befs_aops = {
        .readpage       = befs_readpage,
        .sync_page      = block_sync_page,
        .bmap           = befs_bmap,
@@ -397,7 +392,7 @@ befs_read_inode(struct inode *inode)
        inode->i_mapping->a_ops = &befs_aops;
 
        if (S_ISREG(inode->i_mode)) {
-               inode->i_fop = &befs_file_operations;
+               inode->i_fop = &generic_ro_fops;
        } else if (S_ISDIR(inode->i_mode)) {
                inode->i_op = &befs_dir_inode_operations;
                inode->i_fop = &befs_dir_operations;
@@ -432,7 +427,8 @@ befs_init_inodecache(void)
 {
        befs_inode_cachep = kmem_cache_create("befs_inode_cache",
                                              sizeof (struct befs_inode_info),
-                                             0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
+                                             0, (SLAB_RECLAIM_ACCOUNT|
+                                               SLAB_MEM_SPREAD),
                                              init_once, NULL);
        if (befs_inode_cachep == NULL) {
                printk(KERN_ERR "befs_init_inodecache: "
@@ -460,7 +456,7 @@ befs_destroy_inodecache(void)
  * The data stream become link name. Unless the LONG_SYMLINK
  * flag is set.
  */
-static int
+static void *
 befs_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
        befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
@@ -486,10 +482,10 @@ befs_follow_link(struct dentry *dentry, struct nameidata *nd)
        }
 
        nd_set_link(nd, link);
-       return 0;
+       return NULL;
 }
 
-static void befs_put_link(struct dentry *dentry, struct nameidata *nd)
+static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
 {
        befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
        if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
@@ -516,7 +512,11 @@ befs_utf2nls(struct super_block *sb, const char *in,
        wchar_t uni;
        int unilen, utflen;
        char *result;
-       int maxlen = in_len; /* The utf8->nls conversion can't make more chars */
+       /* The utf8->nls conversion won't make the final nls string bigger
+        * than the utf one, but if the string is pure ascii they'll have the
+        * same width and an extra char is needed to save the additional \0
+        */
+       int maxlen = in_len + 1;
 
        befs_debug(sb, "---> utf2nls()");
 
@@ -566,7 +566,7 @@ befs_utf2nls(struct super_block *sb, const char *in,
  * @sb: Superblock
  * @src: Input string buffer in NLS format
  * @srclen: Length of input string in bytes
- * @dest: The output string in UTF8 format
+ * @dest: The output string in UTF-8 format
  * @destlen: Length of the output buffer
  * 
  * Converts input string @src, which is in the format of the loaded NLS map,
@@ -592,7 +592,10 @@ befs_nls2utf(struct super_block *sb, const char *in,
        wchar_t uni;
        int unilen, utflen;
        char *result;
-       int maxlen = 3 * in_len;
+       /* There're nls characters that will translate to 3-chars-wide UTF-8
+        * characters, a additional byte is needed to save the final \0
+        * in special cases */
+       int maxlen = (3 * in_len) + 1;
 
        befs_debug(sb, "---> nls2utf()\n");
 
@@ -730,20 +733,16 @@ parse_options(char *options, befs_mount_options * opts)
 static void
 befs_put_super(struct super_block *sb)
 {
-       if (BEFS_SB(sb)->mount_opts.iocharset) {
-               kfree(BEFS_SB(sb)->mount_opts.iocharset);
-               BEFS_SB(sb)->mount_opts.iocharset = NULL;
-       }
+       kfree(BEFS_SB(sb)->mount_opts.iocharset);
+       BEFS_SB(sb)->mount_opts.iocharset = NULL;
 
        if (BEFS_SB(sb)->nls) {
                unload_nls(BEFS_SB(sb)->nls);
                BEFS_SB(sb)->nls = NULL;
        }
 
-       if (sb->s_fs_info) {
-               kfree(sb->s_fs_info);
-               sb->s_fs_info = NULL;
-       }
+       kfree(sb->s_fs_info);
+       sb->s_fs_info = NULL;
        return;
 }
 
@@ -856,10 +855,14 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
                befs_sb->nls = load_nls(befs_sb->mount_opts.iocharset);
                if (!befs_sb->nls) {
                        befs_warning(sb, "Cannot load nls %s"
-                                    "loding default nls",
-                                    befs_sb->mount_opts.iocharset);
+                                       " loading default nls",
+                                       befs_sb->mount_opts.iocharset);
                        befs_sb->nls = load_nls_default();
                }
+       /* load default nls if none is specified  in mount options */
+       } else {
+               befs_debug(sb, "Loading default nls");
+               befs_sb->nls = load_nls_default();
        }
 
        return 0;