| 1 | |
| 2 | |
| 3 | * linux/fs/minix/file.c
|
| 4 | *
|
| 5 | * Copyright (C) 1991, 1992 Linus Torvalds
|
| 6 | *
|
| 7 | * minix regular file handling primitives
|
| 8 |
|
| 9 |
|
| 10 | #include <linux/buffer_head.h>
|
| 11 | #include "minix.h"
|
| 12 |
|
| 13 | |
| 14 | * We have mostly NULLs here: the current defaults are OK for
|
| 15 | * the minix filesystem.
|
| 16 |
|
| 17 | const struct file_operations minix_file_operations = {
|
| 18 | .llseek = generic_file_llseek,
|
| 19 | .read_iter = generic_file_read_iter,
|
| 20 | .write_iter = generic_file_write_iter,
|
| 21 | .mmap_prepare = generic_file_mmap_prepare,
|
| 22 | .fsync = simple_fsync,
|
| 23 | .splice_read = filemap_splice_read,
|
| 24 | };
|
| 25 |
|
| 26 | static int minix_setattr(const struct mnt_idmap *idmap,
|
| 27 | struct dentry *dentry, struct iattr *attr)
|
| 28 | {
|
| 29 | struct inode *inode = d_inode(dentry);
|
| 30 | int error;
|
| 31 |
|
| 32 | error = setattr_prepare(&nop_mnt_idmap, dentry, attr);
|
| 33 | if (error)
|
| 34 | return error;
|
| 35 |
|
| 36 | if ((attr->ia_valid & ATTR_SIZE) &&
|
| 37 | attr->ia_size != i_size_read(inode)) {
|
| 38 | error = inode_newsize_ok(inode, attr->ia_size);
|
| 39 | if (error)
|
| 40 | return error;
|
| 41 |
|
| 42 | truncate_setsize(inode, attr->ia_size);
|
| 43 | minix_truncate(inode);
|
| 44 | }
|
| 45 |
|
| 46 | setattr_copy(&nop_mnt_idmap, inode, attr);
|
| 47 | mark_inode_dirty(inode);
|
| 48 | return 0;
|
| 49 | }
|
| 50 |
|
| 51 | const struct inode_operations minix_file_inode_operations = {
|
| 52 | .setattr = minix_setattr,
|
| 53 | .getattr = minix_getattr,
|
| 54 | };
|