patch-2.1.75 linux/fs/coda/file.c

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

diff -u --recursive --new-file v2.1.74/linux/fs/coda/file.c linux/fs/coda/file.c
@@ -18,11 +18,11 @@
 #include <linux/string.h>
 #include <asm/uaccess.h>
 
-#include <linux/coda_namecache.h>
 #include <linux/coda.h>
 #include <linux/coda_linux.h>
 #include <linux/coda_cnode.h>
 #include <linux/coda_psdev.h>
+#include <linux/coda_cache.h>
 
 /* file operations */
 static int coda_readpage(struct inode * inode, struct page * page);
@@ -31,6 +31,8 @@
 static int coda_file_mmap(struct file * file, struct vm_area_struct * vma);
 
 /* exported from this file */
+int coda_fsync(struct file *, struct dentry *dentry);
+
 struct inode_operations coda_file_inode_operations = {
 	&coda_file_operations,	/* default file operations */
 	NULL,			/* create */
@@ -64,7 +66,11 @@
 	coda_file_mmap,         /* mmap */
 	coda_open,              /* open */
 	coda_release,           /* release */
-	NULL,		        /* fsync */
+	coda_fsync,		/* fsync */
+	NULL,                   /* fasync */
+	NULL,                   /* check_media_change */
+	NULL,                   /* revalidate */
+	NULL                    /* lock */
 };
 
 /*  File file operations */
@@ -181,8 +187,44 @@
         return result;
 }
 
+int coda_fsync(struct file *coda_file, struct dentry *coda_dentry)
+{
+        struct cnode *cnp;
+	struct inode *coda_inode = coda_dentry->d_inode;
+        struct inode *cont_inode = NULL;
+        struct file  cont_file;
+	struct dentry cont_dentry;
+        int result = 0;
+        ENTRY;
+
+	if (!(S_ISREG(coda_inode->i_mode) || S_ISDIR(coda_inode->i_mode) ||
+	      S_ISLNK(coda_inode->i_mode)))
+		return -EINVAL;
+
+        cnp = ITOC(coda_inode);
+        CHECK_CNODE(cnp);
+
+        cont_inode = cnp->c_ovp;
+        if ( cont_inode == NULL ) {
+                printk("coda_file_write: cached inode is 0!\n");
+                return -1; 
+        }
+
+        coda_prepare_openfile(coda_inode, coda_file, cont_inode, 
+			      &cont_file, &cont_dentry);
+
+	down(&cont_inode->i_sem);
+
+        result = file_fsync(&cont_file ,&cont_dentry);
+	if ( result == 0 ) {
+		result = venus_fsync(coda_inode->i_sb, &(cnp->c_fid));
+	}
 
+	up(&cont_inode->i_sem);
 
+        coda_restore_codafile(coda_inode, coda_file, cont_inode, &cont_file);
+        return result;
+}
 /* 
  * support routines
  */

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