patch-2.2.10 linux/fs/ncpfs/sock.c

Next file: linux/fs/nfs/read.c
Previous file: linux/fs/ncpfs/ncplib_kernel.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.9/linux/fs/ncpfs/sock.c linux/fs/ncpfs/sock.c
@@ -83,7 +83,8 @@
 
 #define NCP_SLACK_SPACE 1024
 
-static int do_ncp_rpc_call(struct ncp_server *server, int size)
+static int do_ncp_rpc_call(struct ncp_server *server, int size,
+		struct ncp_reply_header* reply_buf, int max_reply_size)
 {
 	struct file *file;
 	struct inode *inode;
@@ -276,7 +277,7 @@
 	 * we have the correct reply, so read into the correct place and
 	 * return it
 	 */
-	result = _recv(sock, (void *) start, server->packet_size, MSG_DONTWAIT);
+	result = _recv(sock, (void *)reply_buf, max_reply_size, MSG_DONTWAIT);
 	if (result < 0) {
 		printk(KERN_WARNING "NCP: notice message: result=%d\n", result);
 	} else if (result < sizeof(struct ncp_reply_header)) {
@@ -299,7 +300,8 @@
  * We need the server to be locked here, so check!
  */
 
-static int ncp_do_request(struct ncp_server *server, int size)
+static int ncp_do_request(struct ncp_server *server, int size,
+		void* reply, int max_reply_size)
 {
 	int result;
 
@@ -316,7 +318,7 @@
 		sign_packet(server, &size);
 	}
 #endif /* CONFIG_NCPFS_PACKET_SIGNING */
-	result = do_ncp_rpc_call(server, size);
+	result = do_ncp_rpc_call(server, size, reply, max_reply_size);
 
 	DDPRINTK(KERN_DEBUG "do_ncp_rpc_call returned %d\n", result);
 
@@ -332,10 +334,11 @@
  * received. It assumes that server->current_size contains the ncp
  * request size
  */
-int ncp_request(struct ncp_server *server, int function)
+int ncp_request2(struct ncp_server *server, int function, 
+		void* rpl, int size)
 {
 	struct ncp_request_header *h;
-	struct ncp_reply_header *reply;
+	struct ncp_reply_header* reply = rpl;
 	int request_size = server->current_size
 			 - sizeof(struct ncp_request_header);
 	int result;
@@ -357,12 +360,11 @@
 	h->task = 2; /* (current->pid) & 0xff; */
 	h->function = function;
 
-	result = ncp_do_request(server, request_size + sizeof(*h));
+	result = ncp_do_request(server, request_size + sizeof(*h), reply, size);
 	if (result < 0) {
 		DPRINTK(KERN_WARNING "ncp_request_error: %d\n", result);
 		goto out;
 	}
-	reply = (struct ncp_reply_header *) (server->packet);
 	server->completion = reply->completion_code;
 	server->conn_status = reply->connection_state;
 	server->reply_size = result;
@@ -393,7 +395,7 @@
 	h->task		= 2; /* see above */
 	h->function	= 0;
 
-	result = ncp_do_request(server, sizeof(*h));
+	result = ncp_do_request(server, sizeof(*h), server->packet, server->packet_size);
 	if (result < 0)
 		goto out;
 	server->sequence = 0;
@@ -417,7 +419,7 @@
 	h->task		= 2; /* see above */
 	h->function	= 0;
 
-	return ncp_do_request(server, sizeof(*h));
+	return ncp_do_request(server, sizeof(*h), server->packet, server->packet_size);
 }
 
 void ncp_lock_server(struct ncp_server *server)
@@ -428,16 +430,18 @@
 		DPRINTK(KERN_WARNING "ncpfs: server locked!!!\n");
 	}
 #endif
-	while (server->lock)
-		sleep_on(&server->wait);
+	down(&server->sem);
+	if (server->lock)
+		printk(KERN_WARNING "ncp_lock_server: was locked!\n");
 	server->lock = 1;
 }
 
 void ncp_unlock_server(struct ncp_server *server)
 {
-	if (server->lock != 1) {
+	if (!server->lock) {
 		printk(KERN_WARNING "ncp_unlock_server: was not locked!\n");
+		return;
 	}
 	server->lock = 0;
-	wake_up(&server->wait);
+	up(&server->sem);
 }

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