aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/namei.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 0c3974cd3ecd..4bae5cbfaa85 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4518,7 +4518,7 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
4518EXPORT_SYMBOL(generic_readlink); 4518EXPORT_SYMBOL(generic_readlink);
4519 4519
4520/* get the link contents into pagecache */ 4520/* get the link contents into pagecache */
4521static char *page_getlink(struct dentry * dentry, struct page **ppage) 4521static const char *page_getlink(struct dentry * dentry, void **cookie)
4522{ 4522{
4523 char *kaddr; 4523 char *kaddr;
4524 struct page *page; 4524 struct page *page;
@@ -4526,31 +4526,15 @@ static char *page_getlink(struct dentry * dentry, struct page **ppage)
4526 page = read_mapping_page(mapping, 0, NULL); 4526 page = read_mapping_page(mapping, 0, NULL);
4527 if (IS_ERR(page)) 4527 if (IS_ERR(page))
4528 return (char*)page; 4528 return (char*)page;
4529 *ppage = page; 4529 *cookie = page;
4530 kaddr = kmap(page); 4530 kaddr = kmap(page);
4531 nd_terminate_link(kaddr, dentry->d_inode->i_size, PAGE_SIZE - 1); 4531 nd_terminate_link(kaddr, dentry->d_inode->i_size, PAGE_SIZE - 1);
4532 return kaddr; 4532 return kaddr;
4533} 4533}
4534 4534
4535int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)
4536{
4537 struct page *page = NULL;
4538 int res = readlink_copy(buffer, buflen, page_getlink(dentry, &page));
4539 if (page) {
4540 kunmap(page);
4541 page_cache_release(page);
4542 }
4543 return res;
4544}
4545EXPORT_SYMBOL(page_readlink);
4546
4547const char *page_follow_link_light(struct dentry *dentry, void **cookie) 4535const char *page_follow_link_light(struct dentry *dentry, void **cookie)
4548{ 4536{
4549 struct page *page = NULL; 4537 return page_getlink(dentry, cookie);
4550 char *res = page_getlink(dentry, &page);
4551 if (!IS_ERR(res))
4552 *cookie = page;
4553 return res;
4554} 4538}
4555EXPORT_SYMBOL(page_follow_link_light); 4539EXPORT_SYMBOL(page_follow_link_light);
4556 4540
@@ -4562,6 +4546,16 @@ void page_put_link(struct inode *unused, void *cookie)
4562} 4546}
4563EXPORT_SYMBOL(page_put_link); 4547EXPORT_SYMBOL(page_put_link);
4564 4548
4549int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)
4550{
4551 void *cookie = NULL;
4552 int res = readlink_copy(buffer, buflen, page_getlink(dentry, &cookie));
4553 if (cookie)
4554 page_put_link(NULL, cookie);
4555 return res;
4556}
4557EXPORT_SYMBOL(page_readlink);
4558
4565/* 4559/*
4566 * The nofs argument instructs pagecache_write_begin to pass AOP_FLAG_NOFS 4560 * The nofs argument instructs pagecache_write_begin to pass AOP_FLAG_NOFS
4567 */ 4561 */