Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  *  linux/cluster/ssi/cfs/symlink.c
0003  *
0004  *  This program is free software; you can redistribute it and/or
0005  *  modify it under the terms of the GNU General Public License as
0006  *  published by the Free Software Foundation; either version 2 of
0007  *  the License, or (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE
0012  *  or NON INFRINGEMENT.  See the GNU General Public License for more
0013  *  details.
0014  *
0015  *  You should have received a copy of the GNU General Public License
0016  *  along with this program; if not, write to the Free Software
0017  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0018  *
0019  *  Questions/Comments/Bugfixes to ssic-linux-devel@lists.sourceforge.net
0020  *
0021  *  Copyright (C) 1992  Rick Sladkey
0022  *
0023  *  Optimization changes Copyright (C) 1994 Florian La Roche
0024  *
0025  *  Jun 7 1999, cache symlink lookups in the page cache.  -DaveM
0026  *
0027  *  Portions Copyright (C) 2001 Compaq Computer Corporation
0028  *
0029  *  ocfs2 symlink handling code.
0030  *
0031  *  Copyright (C) 2004, 2005 Oracle.
0032  *
0033  */
0034 
0035 #include <linux/fs.h>
0036 #include <linux/types.h>
0037 #include <linux/slab.h>
0038 #include <linux/pagemap.h>
0039 #include <linux/namei.h>
0040 
0041 #include <cluster/masklog.h>
0042 
0043 #include "ocfs2.h"
0044 
0045 #include "alloc.h"
0046 #include "file.h"
0047 #include "inode.h"
0048 #include "journal.h"
0049 #include "symlink.h"
0050 #include "xattr.h"
0051 
0052 #include "buffer_head_io.h"
0053 
0054 
0055 static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio)
0056 {
0057     struct page *page = &folio->page;
0058     struct inode *inode = page->mapping->host;
0059     struct buffer_head *bh = NULL;
0060     int status = ocfs2_read_inode_block(inode, &bh);
0061     struct ocfs2_dinode *fe;
0062     const char *link;
0063     void *kaddr;
0064     size_t len;
0065 
0066     if (status < 0) {
0067         mlog_errno(status);
0068         return status;
0069     }
0070 
0071     fe = (struct ocfs2_dinode *) bh->b_data;
0072     link = (char *) fe->id2.i_symlink;
0073     /* will be less than a page size */
0074     len = strnlen(link, ocfs2_fast_symlink_chars(inode->i_sb));
0075     kaddr = kmap_atomic(page);
0076     memcpy(kaddr, link, len + 1);
0077     kunmap_atomic(kaddr);
0078     SetPageUptodate(page);
0079     unlock_page(page);
0080     brelse(bh);
0081     return 0;
0082 }
0083 
0084 const struct address_space_operations ocfs2_fast_symlink_aops = {
0085     .read_folio     = ocfs2_fast_symlink_read_folio,
0086 };
0087 
0088 const struct inode_operations ocfs2_symlink_inode_operations = {
0089     .get_link   = page_get_link,
0090     .getattr    = ocfs2_getattr,
0091     .setattr    = ocfs2_setattr,
0092     .listxattr  = ocfs2_listxattr,
0093     .fiemap     = ocfs2_fiemap,
0094 };