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