Import 2.4.0-test2pre7
[davej-history.git] / fs / coda / file.c
blob704b4d00b5cd0094dfde937fc65ce3ad61439fee
1 /*
2 * File operations for Coda.
3 * Original version: (C) 1996 Peter Braam
4 * Rewritten for Linux 2.1: (C) 1997 Carnegie Mellon University
6 * Carnegie Mellon encourages users of this code to contribute improvements
7 * to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>.
8 */
10 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/sched.h>
13 #include <linux/fs.h>
14 #include <linux/stat.h>
15 #include <linux/errno.h>
16 #include <linux/locks.h>
17 #include <linux/smp_lock.h>
18 #include <asm/segment.h>
19 #include <linux/string.h>
20 #include <asm/uaccess.h>
22 #include <linux/coda.h>
23 #include <linux/coda_linux.h>
24 #include <linux/coda_fs_i.h>
25 #include <linux/coda_psdev.h>
26 #include <linux/coda_cache.h>
27 #include <linux/coda_proc.h>
29 static ssize_t
30 coda_file_write(struct file *file,const char *buf,size_t count,loff_t *ppos)
32 struct inode *inode = file->f_dentry->d_inode;
33 ssize_t n;
35 n = generic_file_write(file, buf, count, ppos);
37 inode->i_size = ((struct inode*)inode->i_mapping->host)->i_size;
39 return n;
42 /* exported from this file (used for dirs) */
43 int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync)
45 struct inode *inode = coda_dentry->d_inode;
46 struct dentry cont_dentry;
47 int result = 0;
48 ENTRY;
49 coda_vfs_stat.fsync++;
51 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
52 S_ISLNK(inode->i_mode)))
53 return -EINVAL;
55 if ( inode->i_mapping == &inode->i_data ) {
56 printk("coda_fsync: no container inode!\n");
57 return -1;
60 cont_dentry.d_inode = (struct inode *)inode->i_mapping->host;
62 down(&cont_dentry.d_inode->i_sem);
63 result = file_fsync(NULL, &cont_dentry, datasync);
64 up(&cont_dentry.d_inode->i_sem);
66 if ( !datasync && result == 0 ) {
67 lock_kernel();
68 result = venus_fsync(inode->i_sb, coda_i2f(inode));
69 unlock_kernel();
72 return result;
75 struct file_operations coda_file_operations = {
76 read: generic_file_read,
77 write: coda_file_write,
78 mmap: generic_file_mmap,
79 open: coda_open,
80 release: coda_release,
81 fsync: coda_fsync,