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

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

diff -u --recursive --new-file v2.4.0-test2/linux/fs/ncpfs/ncplib_kernel.c linux/fs/ncpfs/ncplib_kernel.c
@@ -86,11 +86,11 @@
 	server->has_subfunction = 0;
 }
 
-static void ncp_init_request_s(struct ncp_server *server, int subfunction)
+static inline void ncp_init_request_s(struct ncp_server *server, int subfunction)
 {
-	ncp_init_request(server);
-	ncp_add_word(server, 0);	/* preliminary size */
-
+	ncp_lock_server(server);
+	
+	server->current_size = sizeof(struct ncp_request_header) + 2;
 	ncp_add_byte(server, subfunction);
 
 	server->has_subfunction = 1;
@@ -221,20 +221,23 @@
 	return result;
 }
 
-/*
- * Called with the superblock locked.
- */
 int
 ncp_make_closed(struct inode *inode)
 {
 	int err;
-	NCP_FINFO(inode)->opened = 0;
-	err = ncp_close_file(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle);
 
-	if (!err)
-		PPRINTK("ncp_make_closed: volnum=%d, dirent=%u, error=%d\n",
-			NCP_FINFO(inode)->volNumber,
-			NCP_FINFO(inode)->dirEntNum, err);
+	err = 0;
+	down(&NCP_FINFO(inode)->open_sem);	
+	if (atomic_read(&NCP_FINFO(inode)->opened) == 1) {
+		atomic_set(&NCP_FINFO(inode)->opened, 0);
+		err = ncp_close_file(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle);
+
+		if (!err)
+			PPRINTK("ncp_make_closed: volnum=%d, dirent=%u, error=%d\n",
+				NCP_FINFO(inode)->volNumber,
+				NCP_FINFO(inode)->dirEntNum, err);
+	}
+	up(&NCP_FINFO(inode)->open_sem);
 	return err;
 }
 
@@ -613,7 +616,8 @@
 
 	if ((result = ncp_request(server, 87)) != 0)
 		goto out;
-	target->opened = 1;
+	if (!(create_attributes & aDIR))
+		target->opened = 1;
 	target->server_file_handle = ncp_reply_dword(server, 0);
 	target->open_create_action = ncp_reply_byte(server, 4);
 

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