diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-11-16 18:26:34 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-12-06 20:43:27 -0500 |
commit | aa80deab33a8fb180e718f5e45514db19aade165 (patch) | |
tree | 93d1bad5c4279a0f6226e67060b76810070a4e37 | |
parent | 9cdce3c074fbd7083923f15225e112a91daff8ed (diff) |
namei: page_getlink() and page_follow_link_light() are the same thing
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/namei.c | 32 |
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) | |||
4518 | EXPORT_SYMBOL(generic_readlink); | 4518 | EXPORT_SYMBOL(generic_readlink); |
4519 | 4519 | ||
4520 | /* get the link contents into pagecache */ | 4520 | /* get the link contents into pagecache */ |
4521 | static char *page_getlink(struct dentry * dentry, struct page **ppage) | 4521 | static 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 | ||
4535 | int 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 | } | ||
4545 | EXPORT_SYMBOL(page_readlink); | ||
4546 | |||
4547 | const char *page_follow_link_light(struct dentry *dentry, void **cookie) | 4535 | const 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 | } |
4555 | EXPORT_SYMBOL(page_follow_link_light); | 4539 | EXPORT_SYMBOL(page_follow_link_light); |
4556 | 4540 | ||
@@ -4562,6 +4546,16 @@ void page_put_link(struct inode *unused, void *cookie) | |||
4562 | } | 4546 | } |
4563 | EXPORT_SYMBOL(page_put_link); | 4547 | EXPORT_SYMBOL(page_put_link); |
4564 | 4548 | ||
4549 | int 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 | } | ||
4557 | EXPORT_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 | */ |