file.c 1.2 KB

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