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