| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *  linux/fs/minix/file.c | 
|  | 3 | * | 
|  | 4 | *  Copyright (C) 1991, 1992 Linus Torvalds | 
|  | 5 | * | 
|  | 6 | *  minix regular file handling primitives | 
|  | 7 | */ | 
|  | 8 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include "minix.h" | 
|  | 10 |  | 
|  | 11 | /* | 
|  | 12 | * We have mostly NULLs here: the current defaults are OK for | 
|  | 13 | * the minix filesystem. | 
|  | 14 | */ | 
| Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 15 | const struct file_operations minix_file_operations = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | .llseek		= generic_file_llseek, | 
| Badari Pulavarty | 543ade1 | 2006-09-30 23:28:48 -0700 | [diff] [blame] | 17 | .read		= do_sync_read, | 
|  | 18 | .aio_read	= generic_file_aio_read, | 
|  | 19 | .write		= do_sync_write, | 
|  | 20 | .aio_write	= generic_file_aio_write, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | .mmap		= generic_file_mmap, | 
| Christoph Hellwig | 1b061d9 | 2010-05-26 17:53:41 +0200 | [diff] [blame] | 22 | .fsync		= generic_file_fsync, | 
| Jens Axboe | 5ffc4ef | 2007-06-01 11:49:19 +0200 | [diff] [blame] | 23 | .splice_read	= generic_file_splice_read, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | }; | 
|  | 25 |  | 
| Christoph Hellwig | d39aae9 | 2010-06-04 11:29:59 +0200 | [diff] [blame] | 26 | static int minix_setattr(struct dentry *dentry, struct iattr *attr) | 
|  | 27 | { | 
|  | 28 | struct inode *inode = dentry->d_inode; | 
|  | 29 | int error; | 
|  | 30 |  | 
|  | 31 | error = inode_change_ok(inode, attr); | 
|  | 32 | if (error) | 
|  | 33 | return error; | 
| Christoph Hellwig | 1025774 | 2010-06-04 11:30:02 +0200 | [diff] [blame] | 34 |  | 
|  | 35 | if ((attr->ia_valid & ATTR_SIZE) && | 
|  | 36 | attr->ia_size != i_size_read(inode)) { | 
|  | 37 | error = vmtruncate(inode, attr->ia_size); | 
|  | 38 | if (error) | 
|  | 39 | return error; | 
|  | 40 | } | 
|  | 41 |  | 
|  | 42 | setattr_copy(inode, attr); | 
|  | 43 | mark_inode_dirty(inode); | 
|  | 44 | return 0; | 
| Christoph Hellwig | d39aae9 | 2010-06-04 11:29:59 +0200 | [diff] [blame] | 45 | } | 
|  | 46 |  | 
| Arjan van de Ven | 92e1d5b | 2007-02-12 00:55:39 -0800 | [diff] [blame] | 47 | const struct inode_operations minix_file_inode_operations = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | .truncate	= minix_truncate, | 
| Christoph Hellwig | d39aae9 | 2010-06-04 11:29:59 +0200 | [diff] [blame] | 49 | .setattr	= minix_setattr, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | .getattr	= minix_getattr, | 
|  | 51 | }; |