patch-2.2.15 linux/fs/ncpfs/file.c

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

diff -u --new-file --recursive --exclude-from ../../exclude v2.2.14/fs/ncpfs/file.c linux/fs/ncpfs/file.c
@@ -36,9 +36,8 @@
  */
 int ncp_make_open(struct inode *inode, int right)
 {
-	int error, result;
+	int error;
 	int access;
-	struct nw_file_info finfo;
 
 	error = -EINVAL;
 	if (!inode) {
@@ -53,6 +52,9 @@
 	error = -EACCES;
 	lock_super(inode->i_sb);
 	if (!NCP_FINFO(inode)->opened) {
+		int result;
+		struct nw_file_info finfo;
+		
 		finfo.i.dirEntNum = NCP_FINFO(inode)->dirEntNum;
 		finfo.i.volNumber = NCP_FINFO(inode)->volNumber;
 		/* tries max. rights */
@@ -62,10 +64,20 @@
 					0, AR_READ | AR_WRITE, &finfo);
 		if (!result)
 			goto update;
-		finfo.access = O_RDONLY;
-		result = ncp_open_create_file_or_subdir(NCP_SERVER(inode),
+		switch (right) {
+			case O_RDONLY:
+				finfo.access = O_RDONLY;
+				result = ncp_open_create_file_or_subdir(NCP_SERVER(inode),
+ 					NULL, NULL, OC_MODE_OPEN,
+ 					0, AR_READ, &finfo);
+				break;
+			case O_WRONLY:
+				finfo.access = O_WRONLY;
+				result = ncp_open_create_file_or_subdir(NCP_SERVER(inode),
 					NULL, NULL, OC_MODE_OPEN,
-					0, AR_READ, &finfo);
+					0, AR_WRITE, &finfo);
+				break;
+		}		
 		if (result) {
 #ifdef NCPFS_PARANOIA
 printk(KERN_DEBUG "ncp_make_open: failed, result=%d\n", result);
@@ -134,7 +146,7 @@
 
 	error = ncp_make_open(inode, O_RDONLY);
 	if (error) {
-		printk(KERN_ERR "ncp_file_read: open failed, error=%d\n", error);
+		DPRINTK(KERN_ERR "ncp_file_read: open failed, error=%d\n", error);
 		goto out;
 	}
 
@@ -212,9 +224,9 @@
 	errno = 0;
 	if (!count)
 		goto out;
-	errno = ncp_make_open(inode, O_RDWR);
+	errno = ncp_make_open(inode, O_WRONLY);
 	if (errno) {
-		printk(KERN_ERR "ncp_file_write: open failed, error=%d\n", errno);
+		DPRINTK(KERN_ERR "ncp_file_write: open failed, error=%d\n", errno);
 		return errno;
 	}
 	pos = *ppos;

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