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> |
Evgeniy Dushistov | 577a827 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 27 | #include <linux/buffer_head.h> /* for sync_mapping_buffers() */ |
| 28 | |
Mike Frysinger | e542059 | 2008-02-08 04:21:31 -0800 | [diff] [blame] | 29 | #include "ufs_fs.h" |
Christoph Hellwig | bcd6d4e | 2007-10-16 23:26:51 -0700 | [diff] [blame] | 30 | #include "ufs.h" |
| 31 | |
| 32 | |
Evgeniy Dushistov | 577a827 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 33 | static int ufs_sync_file(struct file *file, struct dentry *dentry, int datasync) |
| 34 | { |
| 35 | struct inode *inode = dentry->d_inode; |
| 36 | int err; |
| 37 | int ret; |
| 38 | |
| 39 | ret = sync_mapping_buffers(inode->i_mapping); |
| 40 | if (!(inode->i_state & I_DIRTY)) |
| 41 | return ret; |
| 42 | if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) |
| 43 | return ret; |
| 44 | |
| 45 | err = ufs_sync_inode(inode); |
| 46 | if (ret == 0) |
| 47 | ret = err; |
| 48 | return ret; |
| 49 | } |
| 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
| 52 | /* |
| 53 | * We have mostly NULL's here: the current defaults are ok for |
| 54 | * the ufs filesystem. |
| 55 | */ |
| 56 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 57 | const struct file_operations ufs_file_operations = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | .llseek = generic_file_llseek, |
Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 59 | .read = do_sync_read, |
| 60 | .aio_read = generic_file_aio_read, |
| 61 | .write = do_sync_write, |
| 62 | .aio_write = generic_file_aio_write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | .mmap = generic_file_mmap, |
| 64 | .open = generic_file_open, |
Evgeniy Dushistov | 577a827 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 65 | .fsync = ufs_sync_file, |
Jens Axboe | 5ffc4ef | 2007-06-01 11:49:19 +0200 | [diff] [blame] | 66 | .splice_read = generic_file_splice_read, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | }; |