file.c 1.1 KB

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