blob: f755a49858216018e719dc0892536418b2e90bcf [file] [log] [blame]
Masahiro Yamadafa60ce22021-05-06 18:06:44 -07001/*
Mark Fashehccd979b2005-12-15 14:31:24 -08002 * 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>
Joel Beckera731d122009-04-06 16:43:42 -070039#include <linux/namei.h>
Mark Fashehccd979b2005-12-15 14:31:24 -080040
Mark Fashehccd979b2005-12-15 14:31:24 -080041#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"
Tiger Yangcf1d6c72008-08-18 17:11:00 +080050#include "xattr.h"
Mark Fashehccd979b2005-12-15 14:31:24 -080051
52#include "buffer_head_io.h"
53
Mark Fashehccd979b2005-12-15 14:31:24 -080054
Al Viroea022dfb2012-05-03 10:14:29 -040055static int ocfs2_fast_symlink_readpage(struct file *unused, struct page *page)
Mark Fashehccd979b2005-12-15 14:31:24 -080056{
Al Viroea022dfb2012-05-03 10:14:29 -040057 struct inode *inode = page->mapping->host;
Sunil Mushran30b9c9e2012-08-03 17:36:17 +010058 struct buffer_head *bh = NULL;
Al Viroea022dfb2012-05-03 10:14:29 -040059 int status = ocfs2_read_inode_block(inode, &bh);
Mark Fashehccd979b2005-12-15 14:31:24 -080060 struct ocfs2_dinode *fe;
Al Viroea022dfb2012-05-03 10:14:29 -040061 const char *link;
62 void *kaddr;
63 size_t len;
Mark Fashehccd979b2005-12-15 14:31:24 -080064
Mark Fashehccd979b2005-12-15 14:31:24 -080065 if (status < 0) {
66 mlog_errno(status);
Al Viroea022dfb2012-05-03 10:14:29 -040067 return status;
Mark Fashehccd979b2005-12-15 14:31:24 -080068 }
69
Al Viroea022dfb2012-05-03 10:14:29 -040070 fe = (struct ocfs2_dinode *) bh->b_data;
Mark Fashehccd979b2005-12-15 14:31:24 -080071 link = (char *) fe->id2.i_symlink;
Al Viroea022dfb2012-05-03 10:14:29 -040072 /* will be less than a page size */
73 len = strnlen(link, ocfs2_fast_symlink_chars(inode->i_sb));
74 kaddr = kmap_atomic(page);
75 memcpy(kaddr, link, len + 1);
76 kunmap_atomic(kaddr);
77 SetPageUptodate(page);
78 unlock_page(page);
Mark Fashehccd979b2005-12-15 14:31:24 -080079 brelse(bh);
Al Viroea022dfb2012-05-03 10:14:29 -040080 return 0;
Mark Fashehccd979b2005-12-15 14:31:24 -080081}
82
Al Viroea022dfb2012-05-03 10:14:29 -040083const struct address_space_operations ocfs2_fast_symlink_aops = {
84 .readpage = ocfs2_fast_symlink_readpage,
85};
Mark Fashehccd979b2005-12-15 14:31:24 -080086
Arjan van de Ven92e1d5b2007-02-12 00:55:39 -080087const struct inode_operations ocfs2_symlink_inode_operations = {
Al Viro6b255392015-11-17 10:20:54 -050088 .get_link = page_get_link,
Mark Fashehccd979b2005-12-15 14:31:24 -080089 .getattr = ocfs2_getattr,
Sunil Mushranbc535802008-04-18 10:23:53 -070090 .setattr = ocfs2_setattr,
Tiger Yangcf1d6c72008-08-18 17:11:00 +080091 .listxattr = ocfs2_listxattr,
Tristan Ye86239d52009-12-22 09:11:58 +080092 .fiemap = ocfs2_fiemap,
Mark Fashehccd979b2005-12-15 14:31:24 -080093};