Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/ufs/file.c |
| 3 | * |
| 4 | * Copyright (C) 1998 |
| 5 | * Daniel Pirkl <daniel.pirkl@email.cz> |
| 6 | * Charles University, Faculty of Mathematics and Physics |
| 7 | * |
| 8 | * from |
| 9 | * |
| 10 | * linux/fs/ext2/file.c |
| 11 | * |
| 12 | * Copyright (C) 1992, 1993, 1994, 1995 |
| 13 | * Remy Card (card@masi.ibp.fr) |
| 14 | * Laboratoire MASI - Institut Blaise Pascal |
| 15 | * Universite Pierre et Marie Curie (Paris VI) |
| 16 | * |
| 17 | * from |
| 18 | * |
| 19 | * linux/fs/minix/file.c |
| 20 | * |
| 21 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 22 | * |
| 23 | * ext2 fs regular file handling primitives |
| 24 | */ |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/fs.h> |
| 27 | #include <linux/ufs_fs.h> |
Evgeniy Dushistov | 577a827 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 28 | #include <linux/buffer_head.h> /* for sync_mapping_buffers() */ |
| 29 | |
| 30 | static int ufs_sync_file(struct file *file, struct dentry *dentry, int datasync) |
| 31 | { |
| 32 | struct inode *inode = dentry->d_inode; |
| 33 | int err; |
| 34 | int ret; |
| 35 | |
| 36 | ret = sync_mapping_buffers(inode->i_mapping); |
| 37 | if (!(inode->i_state & I_DIRTY)) |
| 38 | return ret; |
| 39 | if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) |
| 40 | return ret; |
| 41 | |
| 42 | err = ufs_sync_inode(inode); |
| 43 | if (ret == 0) |
| 44 | ret = err; |
| 45 | return ret; |
| 46 | } |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * We have mostly NULL's here: the current defaults are ok for |
| 51 | * the ufs filesystem. |
| 52 | */ |
| 53 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 54 | const struct file_operations ufs_file_operations = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | .llseek = generic_file_llseek, |
| 56 | .read = generic_file_read, |
| 57 | .write = generic_file_write, |
| 58 | .mmap = generic_file_mmap, |
| 59 | .open = generic_file_open, |
Evgeniy Dushistov | 577a827 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 60 | .fsync = ufs_sync_file, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | .sendfile = generic_file_sendfile, |
| 62 | }; |
| 63 | |
| 64 | struct inode_operations ufs_file_inode_operations = { |
| 65 | .truncate = ufs_truncate, |
| 66 | }; |