Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / fs / ncpfs / inode.c
index bea651f..b76e57b 100644 (file)
@@ -9,7 +9,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 
 #include <asm/system.h>
@@ -39,7 +38,7 @@
 
 static void ncp_delete_inode(struct inode *);
 static void ncp_put_super(struct super_block *);
-static int  ncp_statfs(struct super_block *, struct kstatfs *);
+static int  ncp_statfs(struct dentry *, struct kstatfs *);
 
 static kmem_cache_t * ncp_inode_cachep;
 
@@ -63,7 +62,7 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
 
        if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
            SLAB_CTOR_CONSTRUCTOR) {
-               init_MUTEX(&ei->open_sem);
+               mutex_init(&ei->open_mutex);
                inode_init_once(&ei->vfs_inode);
        }
 }
@@ -72,7 +71,8 @@ static int init_inodecache(void)
 {
        ncp_inode_cachep = kmem_cache_create("ncp_inode_cache",
                                             sizeof(struct ncp_inode_info),
-                                            0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
+                                            0, (SLAB_RECLAIM_ACCOUNT|
+                                               SLAB_MEM_SPREAD),
                                             init_once, NULL);
        if (ncp_inode_cachep == NULL)
                return -ENOMEM;
@@ -104,7 +104,7 @@ static struct super_operations ncp_sops =
 
 extern struct dentry_operations ncp_root_dentry_operations;
 #if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
-extern struct address_space_operations ncp_symlink_aops;
+extern const struct address_space_operations ncp_symlink_aops;
 extern int ncp_symlink(struct inode*, struct dentry*, const char*);
 #endif
 
@@ -142,12 +142,9 @@ static void ncp_update_dates(struct inode *inode, struct nw_info_struct *nwi)
 
        inode->i_blocks = (inode->i_size + NCP_BLOCK_SIZE - 1) >> NCP_BLOCK_SHIFT;
 
-       inode->i_mtime.tv_sec = ncp_date_dos2unix(le16_to_cpu(nwi->modifyTime),
-                                          le16_to_cpu(nwi->modifyDate));
-       inode->i_ctime.tv_sec = ncp_date_dos2unix(le16_to_cpu(nwi->creationTime),
-                                          le16_to_cpu(nwi->creationDate));
-       inode->i_atime.tv_sec = ncp_date_dos2unix(0,
-                                          le16_to_cpu(nwi->lastAccessDate));
+       inode->i_mtime.tv_sec = ncp_date_dos2unix(nwi->modifyTime, nwi->modifyDate);
+       inode->i_ctime.tv_sec = ncp_date_dos2unix(nwi->creationTime, nwi->creationDate);
+       inode->i_atime.tv_sec = ncp_date_dos2unix(0, nwi->lastAccessDate);
        inode->i_atime.tv_nsec = 0;
        inode->i_mtime.tv_nsec = 0;
        inode->i_ctime.tv_nsec = 0;
@@ -227,7 +224,6 @@ static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo)
        inode->i_nlink = 1;
        inode->i_uid = server->m.uid;
        inode->i_gid = server->m.gid;
-       inode->i_blksize = NCP_BLOCK_SIZE;
 
        ncp_update_dates(inode, &nwinfo->i);
        ncp_update_inode(inode, nwinfo);
@@ -235,8 +231,9 @@ static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo)
 
 #if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
 static struct inode_operations ncp_symlink_inode_operations = {
-       .readlink       = page_readlink,
-       .follow_link    = page_follow_link,
+       .readlink       = generic_readlink,
+       .follow_link    = page_follow_link_light,
+       .put_link       = page_put_link,
        .setattr        = ncp_notify_change,
 };
 #endif
@@ -288,6 +285,8 @@ ncp_iget(struct super_block *sb, struct ncp_entry_info *info)
 static void
 ncp_delete_inode(struct inode *inode)
 {
+       truncate_inode_pages(&inode->i_data, 0);
+
        if (S_ISDIR(inode->i_mode)) {
                DDPRINTK("ncp_delete_inode: put directory %ld\n", inode->i_ino);
        }
@@ -462,7 +461,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
                        break;
                default:
                        error = -ECHRNG;
-                       if (*(__u32*)raw_data == cpu_to_be32(0x76657273)) {
+                       if (memcmp(raw_data, "vers", 4) == 0) {
                                error = ncp_parse_options(&data, raw_data);
                        }
                        if (error)
@@ -520,7 +519,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
        }
 
 /*     server->lock = 0;       */
-       init_MUTEX(&server->sem);
+       mutex_init(&server->mutex);
        server->packet = NULL;
 /*     server->buffer_size = 0;        */
 /*     server->conn_status = 0;        */
@@ -557,7 +556,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
        server->dentry_ttl = 0; /* no caching */
 
        INIT_LIST_HEAD(&server->tx.requests);
-       init_MUTEX(&server->rcv.creq_sem);
+       mutex_init(&server->rcv.creq_mutex);
        server->tx.creq         = NULL;
        server->rcv.creq        = NULL;
        server->data_ready      = sock->sk->sk_data_ready;
@@ -625,7 +624,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
 
        memset(&finfo, 0, sizeof(finfo));
        finfo.i.attributes      = aDIR;
-       finfo.i.dataStreamSize  = NCP_BLOCK_SIZE;
+       finfo.i.dataStreamSize  = 0;    /* ignored */
        finfo.i.dirEntNum       = 0;
        finfo.i.DosDirNum       = 0;
 #ifdef CONFIG_NCPFS_SMALLDOS
@@ -716,22 +715,21 @@ static void ncp_put_super(struct super_block *sb)
        fput(server->ncp_filp);
        kill_proc(server->m.wdog_pid, SIGTERM, 1);
 
-       if (server->priv.data) 
-               ncp_kfree_s(server->priv.data, server->priv.len);
-       if (server->auth.object_name)
-               ncp_kfree_s(server->auth.object_name, server->auth.object_name_len);
+       kfree(server->priv.data);
+       kfree(server->auth.object_name);
        vfree(server->packet);
        sb->s_fs_info = NULL;
        kfree(server);
 }
 
-static int ncp_statfs(struct super_block *sb, struct kstatfs *buf)
+static int ncp_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
        struct dentry* d;
        struct inode* i;
        struct ncp_inode_info* ni;
        struct ncp_server* s;
        struct ncp_volume_info vi;
+       struct super_block *sb = dentry->d_sb;
        int err;
        __u8 dh;
        
@@ -794,7 +792,7 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
 {
        struct inode *inode = dentry->d_inode;
        int result = 0;
-       int info_mask;
+       __le32 info_mask;
        struct nw_modify_dos_info info;
        struct ncp_server *server;
 
@@ -917,23 +915,18 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
        if ((attr->ia_valid & ATTR_CTIME) != 0) {
                info_mask |= (DM_CREATE_TIME | DM_CREATE_DATE);
                ncp_date_unix2dos(attr->ia_ctime.tv_sec,
-                            &(info.creationTime), &(info.creationDate));
-               info.creationTime = le16_to_cpu(info.creationTime);
-               info.creationDate = le16_to_cpu(info.creationDate);
+                            &info.creationTime, &info.creationDate);
        }
        if ((attr->ia_valid & ATTR_MTIME) != 0) {
                info_mask |= (DM_MODIFY_TIME | DM_MODIFY_DATE);
                ncp_date_unix2dos(attr->ia_mtime.tv_sec,
-                                 &(info.modifyTime), &(info.modifyDate));
-               info.modifyTime = le16_to_cpu(info.modifyTime);
-               info.modifyDate = le16_to_cpu(info.modifyDate);
+                                 &info.modifyTime, &info.modifyDate);
        }
        if ((attr->ia_valid & ATTR_ATIME) != 0) {
-               __u16 dummy;
+               __le16 dummy;
                info_mask |= (DM_LAST_ACCESS_DATE);
                ncp_date_unix2dos(attr->ia_atime.tv_sec,
-                                 &(dummy), &(info.lastAccessDate));
-               info.lastAccessDate = le16_to_cpu(info.lastAccessDate);
+                                 &dummy, &info.lastAccessDate);
        }
        if (info_mask != 0) {
                result = ncp_modify_file_or_subdir_dos_info(NCP_SERVER(inode),
@@ -963,15 +956,10 @@ out:
        return result;
 }
 
-#ifdef DEBUG_NCP_MALLOC
-int ncp_malloced;
-int ncp_current_malloced;
-#endif
-
-static struct super_block *ncp_get_sb(struct file_system_type *fs_type,
-       int flags, const char *dev_name, void *data)
+static int ncp_get_sb(struct file_system_type *fs_type,
+       int flags, const char *dev_name, void *data, struct vfsmount *mnt)
 {
-       return get_sb_nodev(fs_type, flags, data, ncp_fill_super);
+       return get_sb_nodev(fs_type, flags, data, ncp_fill_super, mnt);
 }
 
 static struct file_system_type ncp_fs_type = {
@@ -986,10 +974,6 @@ static int __init init_ncp_fs(void)
        int err;
        DPRINTK("ncpfs: init_module called\n");
 
-#ifdef DEBUG_NCP_MALLOC
-       ncp_malloced = 0;
-       ncp_current_malloced = 0;
-#endif
        err = init_inodecache();
        if (err)
                goto out1;
@@ -1008,10 +992,6 @@ static void __exit exit_ncp_fs(void)
        DPRINTK("ncpfs: cleanup_module called\n");
        unregister_filesystem(&ncp_fs_type);
        destroy_inodecache();
-#ifdef DEBUG_NCP_MALLOC
-       PRINTK("ncp_malloced: %d\n", ncp_malloced);
-       PRINTK("ncp_current_malloced: %d\n", ncp_current_malloced);
-#endif
 }
 
 module_init(init_ncp_fs)