symlink.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * linux/fs/ext4/symlink.c
  3. *
  4. * Only fast symlinks left here - the rest is done by generic code. AV, 1999
  5. *
  6. * Copyright (C) 1992, 1993, 1994, 1995
  7. * Remy Card ([email protected])
  8. * Laboratoire MASI - Institut Blaise Pascal
  9. * Universite Pierre et Marie Curie (Paris VI)
  10. *
  11. * from
  12. *
  13. * linux/fs/minix/symlink.c
  14. *
  15. * Copyright (C) 1991, 1992 Linus Torvalds
  16. *
  17. * ext4 symlink handling code
  18. */
  19. #include <linux/fs.h>
  20. #include <linux/namei.h>
  21. #include "ext4.h"
  22. #include "xattr.h"
  23. static const char *ext4_encrypted_get_link(struct dentry *dentry,
  24. struct inode *inode,
  25. struct delayed_call *done)
  26. {
  27. struct page *cpage = NULL;
  28. const void *caddr;
  29. unsigned int max_size;
  30. const char *paddr;
  31. if (!dentry)
  32. return ERR_PTR(-ECHILD);
  33. if (ext4_inode_is_fast_symlink(inode)) {
  34. caddr = EXT4_I(inode)->i_data;
  35. max_size = sizeof(EXT4_I(inode)->i_data);
  36. } else {
  37. cpage = read_mapping_page(inode->i_mapping, 0, NULL);
  38. if (IS_ERR(cpage))
  39. return ERR_CAST(cpage);
  40. caddr = page_address(cpage);
  41. max_size = inode->i_sb->s_blocksize;
  42. }
  43. paddr = fscrypt_get_symlink(inode, caddr, max_size, done);
  44. if (cpage)
  45. put_page(cpage);
  46. return paddr;
  47. }
  48. const struct inode_operations ext4_encrypted_symlink_inode_operations = {
  49. .readlink = generic_readlink,
  50. .get_link = ext4_encrypted_get_link,
  51. .setattr = ext4_setattr,
  52. .listxattr = ext4_listxattr,
  53. };
  54. const struct inode_operations ext4_symlink_inode_operations = {
  55. .readlink = generic_readlink,
  56. .get_link = page_get_link,
  57. .setattr = ext4_setattr,
  58. .listxattr = ext4_listxattr,
  59. };
  60. const struct inode_operations ext4_fast_symlink_inode_operations = {
  61. .readlink = generic_readlink,
  62. .get_link = simple_get_link,
  63. .setattr = ext4_setattr,
  64. .listxattr = ext4_listxattr,
  65. };