2021-05-07 04:06:44 +03:00
|
|
|
/*
|
2005-12-16 01:31:24 +03:00
|
|
|
* linux/cluster/ssi/cfs/symlink.c
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE
|
|
|
|
* or NON INFRINGEMENT. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
* Questions/Comments/Bugfixes to ssic-linux-devel@lists.sourceforge.net
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992 Rick Sladkey
|
|
|
|
*
|
|
|
|
* Optimization changes Copyright (C) 1994 Florian La Roche
|
|
|
|
*
|
|
|
|
* Jun 7 1999, cache symlink lookups in the page cache. -DaveM
|
|
|
|
*
|
|
|
|
* Portions Copyright (C) 2001 Compaq Computer Corporation
|
|
|
|
*
|
|
|
|
* ocfs2 symlink handling code.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004, 2005 Oracle.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/pagemap.h>
|
2009-04-07 03:43:42 +04:00
|
|
|
#include <linux/namei.h>
|
2005-12-16 01:31:24 +03:00
|
|
|
|
|
|
|
#include <cluster/masklog.h>
|
|
|
|
|
|
|
|
#include "ocfs2.h"
|
|
|
|
|
|
|
|
#include "alloc.h"
|
|
|
|
#include "file.h"
|
|
|
|
#include "inode.h"
|
|
|
|
#include "journal.h"
|
|
|
|
#include "symlink.h"
|
2008-08-18 13:11:00 +04:00
|
|
|
#include "xattr.h"
|
2005-12-16 01:31:24 +03:00
|
|
|
|
|
|
|
#include "buffer_head_io.h"
|
|
|
|
|
|
|
|
|
2022-04-29 18:12:16 +03:00
|
|
|
static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio)
|
2005-12-16 01:31:24 +03:00
|
|
|
{
|
2022-04-29 18:12:16 +03:00
|
|
|
struct page *page = &folio->page;
|
2012-05-03 18:14:29 +04:00
|
|
|
struct inode *inode = page->mapping->host;
|
2012-08-03 20:36:17 +04:00
|
|
|
struct buffer_head *bh = NULL;
|
2012-05-03 18:14:29 +04:00
|
|
|
int status = ocfs2_read_inode_block(inode, &bh);
|
2005-12-16 01:31:24 +03:00
|
|
|
struct ocfs2_dinode *fe;
|
2012-05-03 18:14:29 +04:00
|
|
|
const char *link;
|
|
|
|
void *kaddr;
|
|
|
|
size_t len;
|
2005-12-16 01:31:24 +03:00
|
|
|
|
|
|
|
if (status < 0) {
|
|
|
|
mlog_errno(status);
|
2012-05-03 18:14:29 +04:00
|
|
|
return status;
|
2005-12-16 01:31:24 +03:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:14:29 +04:00
|
|
|
fe = (struct ocfs2_dinode *) bh->b_data;
|
2005-12-16 01:31:24 +03:00
|
|
|
link = (char *) fe->id2.i_symlink;
|
2012-05-03 18:14:29 +04:00
|
|
|
/* will be less than a page size */
|
|
|
|
len = strnlen(link, ocfs2_fast_symlink_chars(inode->i_sb));
|
|
|
|
kaddr = kmap_atomic(page);
|
|
|
|
memcpy(kaddr, link, len + 1);
|
|
|
|
kunmap_atomic(kaddr);
|
|
|
|
SetPageUptodate(page);
|
|
|
|
unlock_page(page);
|
2005-12-16 01:31:24 +03:00
|
|
|
brelse(bh);
|
2012-05-03 18:14:29 +04:00
|
|
|
return 0;
|
2005-12-16 01:31:24 +03:00
|
|
|
}
|
|
|
|
|
2012-05-03 18:14:29 +04:00
|
|
|
const struct address_space_operations ocfs2_fast_symlink_aops = {
|
2022-04-29 18:12:16 +03:00
|
|
|
.read_folio = ocfs2_fast_symlink_read_folio,
|
2012-05-03 18:14:29 +04:00
|
|
|
};
|
2005-12-16 01:31:24 +03:00
|
|
|
|
2007-02-12 11:55:39 +03:00
|
|
|
const struct inode_operations ocfs2_symlink_inode_operations = {
|
2015-11-17 18:20:54 +03:00
|
|
|
.get_link = page_get_link,
|
2005-12-16 01:31:24 +03:00
|
|
|
.getattr = ocfs2_getattr,
|
2008-04-18 21:23:53 +04:00
|
|
|
.setattr = ocfs2_setattr,
|
2008-08-18 13:11:00 +04:00
|
|
|
.listxattr = ocfs2_listxattr,
|
2009-12-22 04:11:58 +03:00
|
|
|
.fiemap = ocfs2_fiemap,
|
2005-12-16 01:31:24 +03:00
|
|
|
};
|