Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / fs / ncpfs / inode.c
index bea651f..a1f3e97 100644 (file)
@@ -63,7 +63,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 +72,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;
@@ -142,12 +143,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;
@@ -235,8 +233,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 +287,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 +463,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 +521,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 +558,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 +626,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,10 +717,8 @@ 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);
@@ -794,7 +793,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 +916,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,11 +957,6 @@ 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)
 {
@@ -986,10 +975,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 +993,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)