symlink.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * linux/cluster/ssi/cfs/symlink.c
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE
  12. * or NON INFRINGEMENT. See the GNU General Public License for more
  13. * details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. *
  19. * Questions/Comments/Bugfixes to ssic-linux-devel@lists.sourceforge.net
  20. *
  21. * Copyright (C) 1992 Rick Sladkey
  22. *
  23. * Optimization changes Copyright (C) 1994 Florian La Roche
  24. *
  25. * Jun 7 1999, cache symlink lookups in the page cache. -DaveM
  26. *
  27. * Portions Copyright (C) 2001 Compaq Computer Corporation
  28. *
  29. * ocfs2 symlink handling code.
  30. *
  31. * Copyright (C) 2004, 2005 Oracle.
  32. *
  33. */
  34. #include <linux/fs.h>
  35. #include <linux/types.h>
  36. #include <linux/slab.h>
  37. #include <linux/pagemap.h>
  38. #include <linux/namei.h>
  39. #include <cluster/masklog.h>
  40. #include "ocfs2.h"
  41. #include "alloc.h"
  42. #include "file.h"
  43. #include "inode.h"
  44. #include "journal.h"
  45. #include "symlink.h"
  46. #include "xattr.h"
  47. #include "buffer_head_io.h"
  48. static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio)
  49. {
  50. struct page *page = &folio->page;
  51. struct inode *inode = page->mapping->host;
  52. struct buffer_head *bh = NULL;
  53. int status = ocfs2_read_inode_block(inode, &bh);
  54. struct ocfs2_dinode *fe;
  55. const char *link;
  56. void *kaddr;
  57. size_t len;
  58. if (status < 0) {
  59. mlog_errno(status);
  60. goto out;
  61. }
  62. fe = (struct ocfs2_dinode *) bh->b_data;
  63. link = (char *) fe->id2.i_symlink;
  64. /* will be less than a page size */
  65. len = strnlen(link, ocfs2_fast_symlink_chars(inode->i_sb));
  66. kaddr = kmap_atomic(page);
  67. memcpy(kaddr, link, len + 1);
  68. kunmap_atomic(kaddr);
  69. SetPageUptodate(page);
  70. out:
  71. unlock_page(page);
  72. brelse(bh);
  73. return status;
  74. }
  75. const struct address_space_operations ocfs2_fast_symlink_aops = {
  76. .read_folio = ocfs2_fast_symlink_read_folio,
  77. };
  78. const struct inode_operations ocfs2_symlink_inode_operations = {
  79. .get_link = page_get_link,
  80. .getattr = ocfs2_getattr,
  81. .setattr = ocfs2_setattr,
  82. .listxattr = ocfs2_listxattr,
  83. .fiemap = ocfs2_fiemap,
  84. };