diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-03-14 13:42:45 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-04-01 23:19:15 -0400 |
commit | 5d826c847b34de6415b4f1becd88a57ff619af50 (patch) | |
tree | 431338c4141bcff1d392f232613841bf1971d99b /fs/namei.c | |
parent | 4efcc9ffcd4fc53f1f7de539842cdffa1f8e5ecc (diff) |
new helper: readlink_copy()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/fs/namei.c b/fs/namei.c index 617de9e9967b..4fb52f0ca5cb 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -4297,11 +4297,9 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna | |||
4297 | return sys_renameat(AT_FDCWD, oldname, AT_FDCWD, newname); | 4297 | return sys_renameat(AT_FDCWD, oldname, AT_FDCWD, newname); |
4298 | } | 4298 | } |
4299 | 4299 | ||
4300 | int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link) | 4300 | int readlink_copy(char __user *buffer, int buflen, const char *link) |
4301 | { | 4301 | { |
4302 | int len; | 4302 | int len = PTR_ERR(link); |
4303 | |||
4304 | len = PTR_ERR(link); | ||
4305 | if (IS_ERR(link)) | 4303 | if (IS_ERR(link)) |
4306 | goto out; | 4304 | goto out; |
4307 | 4305 | ||
@@ -4313,7 +4311,7 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c | |||
4313 | out: | 4311 | out: |
4314 | return len; | 4312 | return len; |
4315 | } | 4313 | } |
4316 | EXPORT_SYMBOL(vfs_readlink); | 4314 | EXPORT_SYMBOL(readlink_copy); |
4317 | 4315 | ||
4318 | /* | 4316 | /* |
4319 | * A helper for ->readlink(). This should be used *ONLY* for symlinks that | 4317 | * A helper for ->readlink(). This should be used *ONLY* for symlinks that |
@@ -4331,7 +4329,7 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen) | |||
4331 | if (IS_ERR(cookie)) | 4329 | if (IS_ERR(cookie)) |
4332 | return PTR_ERR(cookie); | 4330 | return PTR_ERR(cookie); |
4333 | 4331 | ||
4334 | res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd)); | 4332 | res = readlink_copy(buffer, buflen, nd_get_link(&nd)); |
4335 | if (dentry->d_inode->i_op->put_link) | 4333 | if (dentry->d_inode->i_op->put_link) |
4336 | dentry->d_inode->i_op->put_link(dentry, &nd, cookie); | 4334 | dentry->d_inode->i_op->put_link(dentry, &nd, cookie); |
4337 | return res; | 4335 | return res; |
@@ -4356,8 +4354,7 @@ static char *page_getlink(struct dentry * dentry, struct page **ppage) | |||
4356 | int page_readlink(struct dentry *dentry, char __user *buffer, int buflen) | 4354 | int page_readlink(struct dentry *dentry, char __user *buffer, int buflen) |
4357 | { | 4355 | { |
4358 | struct page *page = NULL; | 4356 | struct page *page = NULL; |
4359 | char *s = page_getlink(dentry, &page); | 4357 | int res = readlink_copy(buffer, buflen, page_getlink(dentry, &page)); |
4360 | int res = vfs_readlink(dentry,buffer,buflen,s); | ||
4361 | if (page) { | 4358 | if (page) { |
4362 | kunmap(page); | 4359 | kunmap(page); |
4363 | page_cache_release(page); | 4360 | page_cache_release(page); |