Commit | Line | Data |
---|---|---|
fa60ce2c | 1 | /* |
ccd979bd MF |
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 | ||
35 | #include <linux/fs.h> | |
36 | #include <linux/types.h> | |
37 | #include <linux/slab.h> | |
38 | #include <linux/pagemap.h> | |
a731d12d | 39 | #include <linux/namei.h> |
ccd979bd | 40 | |
ccd979bd MF |
41 | #include <cluster/masklog.h> |
42 | ||
43 | #include "ocfs2.h" | |
44 | ||
45 | #include "alloc.h" | |
46 | #include "file.h" | |
47 | #include "inode.h" | |
48 | #include "journal.h" | |
49 | #include "symlink.h" | |
cf1d6c76 | 50 | #include "xattr.h" |
ccd979bd MF |
51 | |
52 | #include "buffer_head_io.h" | |
53 | ||
ccd979bd | 54 | |
bb9263fc | 55 | static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio) |
ccd979bd | 56 | { |
bb9263fc | 57 | struct page *page = &folio->page; |
ea022dfb | 58 | struct inode *inode = page->mapping->host; |
30b9c9e6 | 59 | struct buffer_head *bh = NULL; |
ea022dfb | 60 | int status = ocfs2_read_inode_block(inode, &bh); |
ccd979bd | 61 | struct ocfs2_dinode *fe; |
ea022dfb AV |
62 | const char *link; |
63 | void *kaddr; | |
64 | size_t len; | |
ccd979bd | 65 | |
ccd979bd MF |
66 | if (status < 0) { |
67 | mlog_errno(status); | |
ea022dfb | 68 | return status; |
ccd979bd MF |
69 | } |
70 | ||
ea022dfb | 71 | fe = (struct ocfs2_dinode *) bh->b_data; |
ccd979bd | 72 | link = (char *) fe->id2.i_symlink; |
ea022dfb AV |
73 | /* will be less than a page size */ |
74 | len = strnlen(link, ocfs2_fast_symlink_chars(inode->i_sb)); | |
75 | kaddr = kmap_atomic(page); | |
76 | memcpy(kaddr, link, len + 1); | |
77 | kunmap_atomic(kaddr); | |
78 | SetPageUptodate(page); | |
79 | unlock_page(page); | |
ccd979bd | 80 | brelse(bh); |
ea022dfb | 81 | return 0; |
ccd979bd MF |
82 | } |
83 | ||
ea022dfb | 84 | const struct address_space_operations ocfs2_fast_symlink_aops = { |
bb9263fc | 85 | .read_folio = ocfs2_fast_symlink_read_folio, |
ea022dfb | 86 | }; |
ccd979bd | 87 | |
92e1d5be | 88 | const struct inode_operations ocfs2_symlink_inode_operations = { |
6b255391 | 89 | .get_link = page_get_link, |
ccd979bd | 90 | .getattr = ocfs2_getattr, |
bc535809 | 91 | .setattr = ocfs2_setattr, |
cf1d6c76 | 92 | .listxattr = ocfs2_listxattr, |
86239d59 | 93 | .fiemap = ocfs2_fiemap, |
ccd979bd | 94 | }; |