Commit 0f41086e authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] symlink 7/9: shmfs

shm switched (it almost belongs to SL3, but it does some extra stuff
after the link traversal).
parent 077688a9
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/security.h> #include <linux/security.h>
#include <linux/swapops.h> #include <linux/swapops.h>
#include <linux/mempolicy.h> #include <linux/mempolicy.h>
#include <linux/namei.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/div64.h> #include <asm/div64.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -1676,51 +1677,45 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s ...@@ -1676,51 +1677,45 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
return 0; return 0;
} }
static int shmem_readlink_inline(struct dentry *dentry, char __user *buffer, int buflen)
{
return vfs_readlink(dentry, buffer, buflen, (const char *)SHMEM_I(dentry->d_inode));
}
static int shmem_follow_link_inline(struct dentry *dentry, struct nameidata *nd) static int shmem_follow_link_inline(struct dentry *dentry, struct nameidata *nd)
{ {
return vfs_follow_link(nd, (const char *)SHMEM_I(dentry->d_inode)); nd_set_link(nd, (char *)SHMEM_I(dentry->d_inode));
return 0;
} }
static int shmem_readlink(struct dentry *dentry, char __user *buffer, int buflen) static int shmem_follow_link(struct dentry *dentry, struct nameidata *nd)
{ {
struct page *page = NULL; struct page *page = NULL;
int res = shmem_getpage(dentry->d_inode, 0, &page, SGP_READ, NULL); int res = shmem_getpage(dentry->d_inode, 0, &page, SGP_READ, NULL);
if (res) nd_set_link(nd, res ? ERR_PTR(res) : kmap(page));
return res; return 0;
res = vfs_readlink(dentry, buffer, buflen, kmap(page));
kunmap(page);
mark_page_accessed(page);
page_cache_release(page);
return res;
} }
static int shmem_follow_link(struct dentry *dentry, struct nameidata *nd) static void shmem_put_link(struct dentry *dentry, struct nameidata *nd)
{ {
struct page *page = NULL; if (!IS_ERR(nd_get_link(nd))) {
int res = shmem_getpage(dentry->d_inode, 0, &page, SGP_READ, NULL); struct page *page;
if (res)
return res; page = find_get_page(dentry->d_inode->i_mapping, 0);
res = vfs_follow_link(nd, kmap(page)); if (!page)
kunmap(page); BUG();
mark_page_accessed(page); kunmap(page);
page_cache_release(page); mark_page_accessed(page);
return res; page_cache_release(page);
page_cache_release(page);
}
} }
static struct inode_operations shmem_symlink_inline_operations = { static struct inode_operations shmem_symlink_inline_operations = {
.readlink = shmem_readlink_inline, .readlink = generic_readlink,
.follow_link = shmem_follow_link_inline, .follow_link = shmem_follow_link_inline,
}; };
static struct inode_operations shmem_symlink_inode_operations = { static struct inode_operations shmem_symlink_inode_operations = {
.truncate = shmem_truncate, .truncate = shmem_truncate,
.readlink = shmem_readlink, .readlink = generic_readlink,
.follow_link = shmem_follow_link, .follow_link = shmem_follow_link,
.put_link = shmem_put_link,
}; };
static int shmem_parse_options(char *options, int *mode, uid_t *uid, gid_t *gid, unsigned long *blocks, unsigned long *inodes) static int shmem_parse_options(char *options, int *mode, uid_t *uid, gid_t *gid, unsigned long *blocks, unsigned long *inodes)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment