file.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 = generic_file_splice_read,
  21. };
  22. static int minix_setattr(struct dentry *dentry, struct iattr *attr)
  23. {
  24. struct inode *inode = d_inode(dentry);
  25. int error;
  26. error = setattr_prepare(dentry, attr);
  27. if (error)
  28. return error;
  29. if ((attr->ia_valid & ATTR_SIZE) &&
  30. attr->ia_size != i_size_read(inode)) {
  31. error = inode_newsize_ok(inode, attr->ia_size);
  32. if (error)
  33. return error;
  34. truncate_setsize(inode, attr->ia_size);
  35. minix_truncate(inode);
  36. }
  37. setattr_copy(inode, attr);
  38. mark_inode_dirty(inode);
  39. return 0;
  40. }
  41. const struct inode_operations minix_file_inode_operations = {
  42. .setattr = minix_setattr,
  43. .getattr = minix_getattr,
  44. };