patch-2.1.109 linux/fs/coda/coda_linux.c

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

diff -u --recursive --new-file v2.1.108/linux/fs/coda/coda_linux.c linux/fs/coda/coda_linux.c
@@ -123,20 +123,27 @@
 unsigned short coda_flags_to_cflags(unsigned short flags)
 {
 	unsigned short coda_flags = 0;
-
-	if ( (flags & 0xf) == O_RDONLY )
+	
+	if ( (flags & O_ACCMODE) == O_RDONLY ){ 
+		CDEBUG(D_FILE, "--> C_O_READ added\n");
 		coda_flags |= C_O_READ;
+	}
 
-	if ( flags &  O_RDWR )
-		coda_flags |= C_O_READ;
+	if ( (flags & O_ACCMODE) ==  O_RDWR ) { 
+		CDEBUG(D_FILE, "--> C_O_READ | C_O_WRITE added\n");
+		coda_flags |= C_O_READ | C_O_WRITE;
+	}
 
-	if ( flags & (O_WRONLY | O_RDWR) )
+	if ( (flags & O_ACCMODE) == O_WRONLY ){ 
+		CDEBUG(D_FILE, "--> C_O_WRITE added\n");
 		coda_flags |= C_O_WRITE;
+	}
 
 	if ( flags & O_TRUNC )  { 
 		CDEBUG(D_FILE, "--> C_O_TRUNC added\n");
 		coda_flags |= C_O_TRUNC;
 	}
+
 	if ( flags & O_EXCL ) {
 		coda_flags |= C_O_EXCL;
 		CDEBUG(D_FILE, "--> C_O_EXCL added\n");
@@ -181,12 +188,10 @@
 	        inode->i_nlink = attr->va_nlink;
 	if (attr->va_size != -1)
 	        inode->i_size = attr->va_size;
-	/*  XXX This needs further study */
-	/*
-        inode->i_blksize = attr->va_blocksize;
-	inode->i_blocks = attr->va_size/attr->va_blocksize 
-	  + (attr->va_size % attr->va_blocksize ? 1 : 0); 
-	  */
+	if (attr->va_blocksize != -1)
+		inode->i_blksize = attr->va_blocksize;
+	if (attr->va_size != -1)
+		inode->i_blocks = (attr->va_size + 511) >> 9;
 	if (attr->va_atime.tv_sec != -1) 
 	        inode->i_atime = attr->va_atime.tv_sec;
 	if (attr->va_mtime.tv_sec != -1)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov