Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/sysv/file.c |
| 3 | * |
| 4 | * minix/file.c |
| 5 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 6 | * |
| 7 | * coh/file.c |
| 8 | * Copyright (C) 1993 Pascal Haible, Bruno Haible |
| 9 | * |
| 10 | * sysv/file.c |
| 11 | * Copyright (C) 1993 Bruno Haible |
| 12 | * |
| 13 | * SystemV/Coherent regular file handling primitives |
| 14 | */ |
| 15 | |
| 16 | #include "sysv.h" |
| 17 | |
| 18 | /* |
| 19 | * We have mostly NULLs here: the current defaults are OK for |
| 20 | * the coh filesystem. |
| 21 | */ |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 22 | const struct file_operations sysv_file_operations = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | .llseek = generic_file_llseek, |
Al Viro | aad4f8b | 2014-04-02 14:33:16 -0400 | [diff] [blame] | 24 | .read = new_sync_read, |
| 25 | .read_iter = generic_file_read_iter, |
Al Viro | 8174202 | 2014-04-03 03:17:43 -0400 | [diff] [blame] | 26 | .write = new_sync_write, |
| 27 | .write_iter = generic_file_write_iter, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | .mmap = generic_file_mmap, |
Christoph Hellwig | 1b061d9 | 2010-05-26 17:53:41 +0200 | [diff] [blame] | 29 | .fsync = generic_file_fsync, |
Jens Axboe | 5ffc4ef | 2007-06-01 11:49:19 +0200 | [diff] [blame] | 30 | .splice_read = generic_file_splice_read, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | }; |
| 32 | |
Christoph Hellwig | d39aae9 | 2010-06-04 11:29:59 +0200 | [diff] [blame] | 33 | static int sysv_setattr(struct dentry *dentry, struct iattr *attr) |
| 34 | { |
| 35 | struct inode *inode = dentry->d_inode; |
| 36 | int error; |
| 37 | |
| 38 | error = inode_change_ok(inode, attr); |
| 39 | if (error) |
| 40 | return error; |
Christoph Hellwig | 1025774 | 2010-06-04 11:30:02 +0200 | [diff] [blame] | 41 | |
| 42 | if ((attr->ia_valid & ATTR_SIZE) && |
| 43 | attr->ia_size != i_size_read(inode)) { |
Marco Stornelli | fa4d62a | 2012-12-15 11:45:58 +0100 | [diff] [blame] | 44 | error = inode_newsize_ok(inode, attr->ia_size); |
Christoph Hellwig | 1025774 | 2010-06-04 11:30:02 +0200 | [diff] [blame] | 45 | if (error) |
| 46 | return error; |
Marco Stornelli | fa4d62a | 2012-12-15 11:45:58 +0100 | [diff] [blame] | 47 | truncate_setsize(inode, attr->ia_size); |
| 48 | sysv_truncate(inode); |
Christoph Hellwig | 1025774 | 2010-06-04 11:30:02 +0200 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | setattr_copy(inode, attr); |
| 52 | mark_inode_dirty(inode); |
| 53 | return 0; |
Christoph Hellwig | d39aae9 | 2010-06-04 11:29:59 +0200 | [diff] [blame] | 54 | } |
| 55 | |
Arjan van de Ven | c5ef1c4 | 2007-02-12 00:55:40 -0800 | [diff] [blame] | 56 | const struct inode_operations sysv_file_inode_operations = { |
Christoph Hellwig | d39aae9 | 2010-06-04 11:29:59 +0200 | [diff] [blame] | 57 | .setattr = sysv_setattr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | .getattr = sysv_getattr, |
| 59 | }; |