1 /*
2 * linux/fs/minix/file.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 *
6 * minix regular file handling primitives
7 */
8
9 #include <linux/fs.h>
10 #include <linux/minix_fs.h>
11
12 /*
13 * We have mostly NULLs here: the current defaults are OK for
14 * the minix filesystem.
15 */
16 int minix_sync_file(struct file *, struct dentry *, int);
17
18 struct file_operations minix_file_operations = {
19 llseek: generic_file_llseek,
20 read: generic_file_read,
21 write: generic_file_write,
22 mmap: generic_file_mmap,
23 fsync: minix_sync_file,
24 };
25
26 struct inode_operations minix_file_inode_operations = {
27 truncate: minix_truncate,
28 };
29
minix_sync_file(struct file * file,struct dentry * dentry,int datasync)30 int minix_sync_file(struct file * file, struct dentry *dentry, int datasync)
31 {
32 struct inode *inode = dentry->d_inode;
33 int err;
34
35 err = fsync_inode_buffers(inode);
36 err |= fsync_inode_data_buffers(inode);
37 if (!(inode->i_state & I_DIRTY))
38 return err;
39 if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
40 return err;
41
42 err |= minix_sync_inode(inode);
43 return err ? -EIO : 0;
44 }
45