patch-2.4.0-test3 linux/fs/ncpfs/inode.c

Next file: linux/fs/ncpfs/ioctl.c
Previous file: linux/fs/ncpfs/file.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test2/linux/fs/ncpfs/inode.c linux/fs/ncpfs/inode.c
@@ -25,6 +25,7 @@
 #include <linux/file.h>
 #include <linux/fcntl.h>
 #include <linux/malloc.h>
+#include <linux/vmalloc.h>
 #include <linux/init.h>
 
 #include <linux/ncp_fs.h>
@@ -61,7 +62,6 @@
 #ifdef CONFIG_NCPFS_STRONG
 	NCP_FINFO(inode)->nwattr = nwinfo->i.attributes;
 #endif
-	NCP_FINFO(inode)->opened = nwinfo->opened;
 	NCP_FINFO(inode)->access = nwinfo->access;
 	NCP_FINFO(inode)->server_file_handle = nwinfo->server_file_handle;
 	memcpy(NCP_FINFO(inode)->file_handle, nwinfo->file_handle,
@@ -76,7 +76,7 @@
 	struct nw_info_struct *nwi = &nwinfo->i;
 	struct ncp_server *server = NCP_SERVER(inode);
 
-	if (!NCP_FINFO(inode)->opened) {
+	if (!atomic_read(&NCP_FINFO(inode)->opened)) {
 #ifdef CONFIG_NCPFS_STRONG
 		NCP_FINFO(inode)->nwattr = nwi->attributes;
 #endif
@@ -216,6 +216,9 @@
 
 	inode = get_empty_inode();
 	if (inode) {
+		init_MUTEX(&NCP_FINFO(inode)->open_sem);
+		atomic_set(&NCP_FINFO(inode)->opened, info->opened);
+
 		inode->i_sb = sb;
 		inode->i_dev = sb->s_dev;
 		inode->i_ino = info->ino;
@@ -245,7 +248,7 @@
 		DDPRINTK("ncp_delete_inode: put directory %ld\n", inode->i_ino);
 	}
 
-	if (NCP_FINFO(inode)->opened && ncp_make_closed(inode) != 0) {
+	if (ncp_make_closed(inode) != 0) {
 		/* We can't do anything but complain. */
 		printk(KERN_ERR "ncp_delete_inode: could not close\n");
 	}
@@ -259,8 +262,10 @@
 	struct ncp_server *server;
 	struct file *ncp_filp;
 	struct inode *root_inode;
-	kdev_t dev = sb->s_dev;
+	struct inode *sock_inode;
+	struct socket *sock;
 	int error;
+	int default_bufsize;
 #ifdef CONFIG_NCPFS_PACKET_SIGNING
 	int options;
 #endif
@@ -312,13 +317,21 @@
 	ncp_filp = fget(data.ncp_fd);
 	if (!ncp_filp)
 		goto out_bad_file;
-	if (!S_ISSOCK(ncp_filp->f_dentry->d_inode->i_mode))
+	sock_inode = ncp_filp->f_dentry->d_inode;
+	if (!S_ISSOCK(sock_inode->i_mode))
+		goto out_bad_file2;
+	sock = &sock_inode->u.socket_i;
+	if (!sock)
 		goto out_bad_file2;
+		
+	if (sock->type == SOCK_STREAM)
+		default_bufsize = 61440;
+	else
+		default_bufsize = 1024;
 
 	sb->s_blocksize = 1024;	/* Eh...  Is this correct? */
 	sb->s_blocksize_bits = 10;
 	sb->s_magic = NCP_SUPER_MAGIC;
-	sb->s_dev = dev;
 	sb->s_op = &ncp_sops;
 
 	server = NCP_SBP(sb);
@@ -364,8 +377,10 @@
 
 	server->dentry_ttl = 0;	/* no caching */
 
+#undef NCP_PACKET_SIZE
+#define NCP_PACKET_SIZE 65536
 	server->packet_size = NCP_PACKET_SIZE;
-	server->packet = ncp_kmalloc(NCP_PACKET_SIZE, GFP_KERNEL);
+	server->packet = vmalloc(NCP_PACKET_SIZE);
 	if (server->packet == NULL)
 		goto out_no_packet;
 
@@ -377,13 +392,13 @@
 	DPRINTK("ncp_read_super: NCP_SBP(sb) = %x\n", (int) NCP_SBP(sb));
 
 #ifdef CONFIG_NCPFS_PACKET_SIGNING
-	if (ncp_negotiate_size_and_options(server, NCP_DEFAULT_BUFSIZE,
+	if (ncp_negotiate_size_and_options(server, default_bufsize,
 		NCP_DEFAULT_OPTIONS, &(server->buffer_size), &options) == 0)
 	{
 		if (options != NCP_DEFAULT_OPTIONS)
 		{
 			if (ncp_negotiate_size_and_options(server, 
-				NCP_DEFAULT_BUFSIZE,
+				default_bufsize,
 				options & 2, 
 				&(server->buffer_size), &options) != 0)
 				
@@ -396,7 +411,7 @@
 	}
 	else 
 #endif	/* CONFIG_NCPFS_PACKET_SIGNING */
-	if (ncp_negotiate_buffersize(server, NCP_DEFAULT_BUFSIZE,
+	if (ncp_negotiate_buffersize(server, default_bufsize,
   				     &(server->buffer_size)) != 0)
 		goto out_no_bufsize;
 	DPRINTK("ncpfs: bufsize = %d\n", server->buffer_size);
@@ -447,7 +462,7 @@
 out_no_connect:
 	printk(KERN_ERR "ncp_read_super: Failed connection, error=%d\n", error);
 out_free_packet:
-	ncp_kfree_s(server->packet, server->packet_size);
+	vfree(server->packet);
 	goto out_free_server;
 out_no_packet:
 	printk(KERN_ERR "ncp_read_super: could not alloc packet\n");
@@ -508,7 +523,7 @@
 		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);
-	ncp_kfree_s(server->packet, server->packet_size);
+	vfree(server->packet);
 
 }
 
@@ -676,6 +691,7 @@
 
 		/* According to ndir, the changes only take effect after
 		   closing the file */
+		ncp_inode_close(inode);
 		result = ncp_make_closed(inode);
 		if (!result)
 			vmtruncate(inode, attr->ia_size);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)