提交 680baacb 编写于 作者: A Al Viro

new ->follow_link() and ->put_link() calling conventions

a) instead of storing the symlink body (via nd_set_link()) and returning
an opaque pointer later passed to ->put_link(), ->follow_link() _stores_
that opaque pointer (into void * passed by address by caller) and returns
the symlink body.  Returning ERR_PTR() on error, NULL on jump (procfs magic
symlinks) and pointer to symlink body for normal symlinks.  Stored pointer
is ignored in all cases except the last one.

Storing NULL for opaque pointer (or not storing it at all) means no call
of ->put_link().

b) the body used to be passed to ->put_link() implicitly (via nameidata).
Now only the opaque pointer is.  In the cases when we used the symlink body
to free stuff, ->follow_link() now should store it as opaque pointer in addition
to returning it.
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 46afd6f6
...@@ -50,8 +50,8 @@ prototypes: ...@@ -50,8 +50,8 @@ prototypes:
int (*rename2) (struct inode *, struct dentry *, int (*rename2) (struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int); struct inode *, struct dentry *, unsigned int);
int (*readlink) (struct dentry *, char __user *,int); int (*readlink) (struct dentry *, char __user *,int);
void * (*follow_link) (struct dentry *, struct nameidata *); const char *(*follow_link) (struct dentry *, void **, struct nameidata *);
void (*put_link) (struct dentry *, struct nameidata *, void *); void (*put_link) (struct dentry *, void *);
void (*truncate) (struct inode *); void (*truncate) (struct inode *);
int (*permission) (struct inode *, int, unsigned int); int (*permission) (struct inode *, int, unsigned int);
int (*get_acl)(struct inode *, int); int (*get_acl)(struct inode *, int);
......
...@@ -350,8 +350,8 @@ struct inode_operations { ...@@ -350,8 +350,8 @@ struct inode_operations {
int (*rename2) (struct inode *, struct dentry *, int (*rename2) (struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int); struct inode *, struct dentry *, unsigned int);
int (*readlink) (struct dentry *, char __user *,int); int (*readlink) (struct dentry *, char __user *,int);
void * (*follow_link) (struct dentry *, struct nameidata *); const char *(*follow_link) (struct dentry *, void **, struct nameidata *);
void (*put_link) (struct dentry *, struct nameidata *, void *); void (*put_link) (struct dentry *, void *);
int (*permission) (struct inode *, int); int (*permission) (struct inode *, int);
int (*get_acl)(struct inode *, int); int (*get_acl)(struct inode *, int);
int (*setattr) (struct dentry *, struct iattr *); int (*setattr) (struct dentry *, struct iattr *);
......
...@@ -118,7 +118,7 @@ static int ll_readlink_internal(struct inode *inode, ...@@ -118,7 +118,7 @@ static int ll_readlink_internal(struct inode *inode,
return rc; return rc;
} }
static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *ll_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct inode *inode = d_inode(dentry); struct inode *inode = d_inode(dentry);
struct ptlrpc_request *request = NULL; struct ptlrpc_request *request = NULL;
...@@ -140,18 +140,17 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -140,18 +140,17 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd)
} }
if (rc) { if (rc) {
ptlrpc_req_finished(request); ptlrpc_req_finished(request);
request = NULL; return ERR_PTR(rc);
symname = ERR_PTR(rc);
} }
nd_set_link(nd, symname);
/* symname may contain a pointer to the request message buffer, /* symname may contain a pointer to the request message buffer,
* we delay request releasing until ll_put_link then. * we delay request releasing until ll_put_link then.
*/ */
return request; *cookie = request;
return symname;
} }
static void ll_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) static void ll_put_link(struct dentry *dentry, void *cookie)
{ {
ptlrpc_req_finished(cookie); ptlrpc_req_finished(cookie);
} }
......
...@@ -1230,11 +1230,12 @@ ino_t v9fs_qid2ino(struct p9_qid *qid) ...@@ -1230,11 +1230,12 @@ ino_t v9fs_qid2ino(struct p9_qid *qid)
* *
*/ */
static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *v9fs_vfs_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct v9fs_session_info *v9ses = v9fs_dentry2v9ses(dentry); struct v9fs_session_info *v9ses = v9fs_dentry2v9ses(dentry);
struct p9_fid *fid = v9fs_fid_lookup(dentry); struct p9_fid *fid = v9fs_fid_lookup(dentry);
struct p9_wstat *st; struct p9_wstat *st;
char *res;
p9_debug(P9_DEBUG_VFS, "%pd\n", dentry); p9_debug(P9_DEBUG_VFS, "%pd\n", dentry);
...@@ -1253,14 +1254,14 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -1253,14 +1254,14 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
kfree(st); kfree(st);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
if (strlen(st->extension) >= PATH_MAX) res = st->extension;
st->extension[PATH_MAX - 1] = '\0';
nd_set_link(nd, st->extension);
st->extension = NULL; st->extension = NULL;
if (strlen(res) >= PATH_MAX)
res[PATH_MAX - 1] = '\0';
p9stat_free(st); p9stat_free(st);
kfree(st); kfree(st);
return NULL; return *cookie = res;
} }
/** /**
......
...@@ -909,8 +909,8 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode, ...@@ -909,8 +909,8 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
* *
*/ */
static void * static const char *
v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd) v9fs_vfs_follow_link_dotl(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct p9_fid *fid = v9fs_fid_lookup(dentry); struct p9_fid *fid = v9fs_fid_lookup(dentry);
char *target; char *target;
...@@ -923,8 +923,7 @@ v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd) ...@@ -923,8 +923,7 @@ v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
retval = p9_client_readlink(fid, &target); retval = p9_client_readlink(fid, &target);
if (retval) if (retval)
return ERR_PTR(retval); return ERR_PTR(retval);
nd_set_link(nd, target); return *cookie = target;
return NULL;
} }
int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode) int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode)
......
...@@ -12,14 +12,13 @@ ...@@ -12,14 +12,13 @@
#include "autofs_i.h" #include "autofs_i.h"
static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *autofs4_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
struct autofs_info *ino = autofs4_dentry_ino(dentry); struct autofs_info *ino = autofs4_dentry_ino(dentry);
if (ino && !autofs4_oz_mode(sbi)) if (ino && !autofs4_oz_mode(sbi))
ino->last_used = jiffies; ino->last_used = jiffies;
nd_set_link(nd, d_inode(dentry)->i_private); return d_inode(dentry)->i_private;
return NULL;
} }
const struct inode_operations autofs4_symlink_inode_operations = { const struct inode_operations autofs4_symlink_inode_operations = {
......
...@@ -42,7 +42,7 @@ static struct inode *befs_iget(struct super_block *, unsigned long); ...@@ -42,7 +42,7 @@ static struct inode *befs_iget(struct super_block *, unsigned long);
static struct inode *befs_alloc_inode(struct super_block *sb); static struct inode *befs_alloc_inode(struct super_block *sb);
static void befs_destroy_inode(struct inode *inode); static void befs_destroy_inode(struct inode *inode);
static void befs_destroy_inodecache(void); static void befs_destroy_inodecache(void);
static void *befs_follow_link(struct dentry *, struct nameidata *); static const char *befs_follow_link(struct dentry *, void **, struct nameidata *nd);
static int befs_utf2nls(struct super_block *sb, const char *in, int in_len, static int befs_utf2nls(struct super_block *sb, const char *in, int in_len,
char **out, int *out_len); char **out, int *out_len);
static int befs_nls2utf(struct super_block *sb, const char *in, int in_len, static int befs_nls2utf(struct super_block *sb, const char *in, int in_len,
...@@ -463,8 +463,8 @@ befs_destroy_inodecache(void) ...@@ -463,8 +463,8 @@ befs_destroy_inodecache(void)
* The data stream become link name. Unless the LONG_SYMLINK * The data stream become link name. Unless the LONG_SYMLINK
* flag is set. * flag is set.
*/ */
static void * static const char *
befs_follow_link(struct dentry *dentry, struct nameidata *nd) befs_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct super_block *sb = dentry->d_sb; struct super_block *sb = dentry->d_sb;
struct befs_inode_info *befs_ino = BEFS_I(d_inode(dentry)); struct befs_inode_info *befs_ino = BEFS_I(d_inode(dentry));
...@@ -474,23 +474,20 @@ befs_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -474,23 +474,20 @@ befs_follow_link(struct dentry *dentry, struct nameidata *nd)
if (len == 0) { if (len == 0) {
befs_error(sb, "Long symlink with illegal length"); befs_error(sb, "Long symlink with illegal length");
link = ERR_PTR(-EIO); return ERR_PTR(-EIO);
} else {
befs_debug(sb, "Follow long symlink");
link = kmalloc(len, GFP_NOFS);
if (!link) {
link = ERR_PTR(-ENOMEM);
} else if (befs_read_lsymlink(sb, data, link, len) != len) {
kfree(link);
befs_error(sb, "Failed to read entire long symlink");
link = ERR_PTR(-EIO);
} else {
link[len - 1] = '\0';
}
} }
nd_set_link(nd, link); befs_debug(sb, "Follow long symlink");
return NULL;
link = kmalloc(len, GFP_NOFS);
if (!link)
return ERR_PTR(-ENOMEM);
if (befs_read_lsymlink(sb, data, link, len) != len) {
kfree(link);
befs_error(sb, "Failed to read entire long symlink");
return ERR_PTR(-EIO);
}
link[len - 1] = '\0';
return *cookie = link;
} }
/* /*
......
...@@ -120,7 +120,7 @@ extern struct vfsmount *cifs_dfs_d_automount(struct path *path); ...@@ -120,7 +120,7 @@ extern struct vfsmount *cifs_dfs_d_automount(struct path *path);
#endif #endif
/* Functions related to symlinks */ /* Functions related to symlinks */
extern void *cifs_follow_link(struct dentry *direntry, struct nameidata *nd); extern const char *cifs_follow_link(struct dentry *direntry, void **cookie, struct nameidata *nd);
extern int cifs_readlink(struct dentry *direntry, char __user *buffer, extern int cifs_readlink(struct dentry *direntry, char __user *buffer,
int buflen); int buflen);
extern int cifs_symlink(struct inode *inode, struct dentry *direntry, extern int cifs_symlink(struct inode *inode, struct dentry *direntry,
......
...@@ -626,8 +626,8 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, ...@@ -626,8 +626,8 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
return rc; return rc;
} }
void * const char *
cifs_follow_link(struct dentry *direntry, struct nameidata *nd) cifs_follow_link(struct dentry *direntry, void **cookie, struct nameidata *nd)
{ {
struct inode *inode = d_inode(direntry); struct inode *inode = d_inode(direntry);
int rc = -ENOMEM; int rc = -ENOMEM;
...@@ -643,16 +643,18 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) ...@@ -643,16 +643,18 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
tlink = cifs_sb_tlink(cifs_sb); tlink = cifs_sb_tlink(cifs_sb);
if (IS_ERR(tlink)) { if (IS_ERR(tlink)) {
rc = PTR_ERR(tlink); free_xid(xid);
tlink = NULL; return ERR_CAST(tlink);
goto out;
} }
tcon = tlink_tcon(tlink); tcon = tlink_tcon(tlink);
server = tcon->ses->server; server = tcon->ses->server;
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
if (!full_path) if (!full_path) {
goto out; free_xid(xid);
cifs_put_tlink(tlink);
return ERR_PTR(-ENOMEM);
}
cifs_dbg(FYI, "Full path: %s inode = 0x%p\n", full_path, inode); cifs_dbg(FYI, "Full path: %s inode = 0x%p\n", full_path, inode);
...@@ -670,17 +672,13 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) ...@@ -670,17 +672,13 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
&target_path, cifs_sb); &target_path, cifs_sb);
kfree(full_path); kfree(full_path);
out: free_xid(xid);
cifs_put_tlink(tlink);
if (rc != 0) { if (rc != 0) {
kfree(target_path); kfree(target_path);
target_path = ERR_PTR(rc); return ERR_PTR(rc);
} }
return *cookie = target_path;
free_xid(xid);
if (tlink)
cifs_put_tlink(tlink);
nd_set_link(nd, target_path);
return NULL;
} }
int int
......
...@@ -279,30 +279,26 @@ static int configfs_getlink(struct dentry *dentry, char * path) ...@@ -279,30 +279,26 @@ static int configfs_getlink(struct dentry *dentry, char * path)
} }
static void *configfs_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *configfs_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
int error = -ENOMEM;
unsigned long page = get_zeroed_page(GFP_KERNEL); unsigned long page = get_zeroed_page(GFP_KERNEL);
int error;
if (page) { if (!page)
error = configfs_getlink(dentry, (char *)page); return ERR_PTR(-ENOMEM);
if (!error) {
nd_set_link(nd, (char *)page); error = configfs_getlink(dentry, (char *)page);
return (void *)page; if (!error) {
} return *cookie = (void *)page;
} }
nd_set_link(nd, ERR_PTR(error)); free_page(page);
return NULL; return ERR_PTR(error);
} }
static void configfs_put_link(struct dentry *dentry, struct nameidata *nd, static void configfs_put_link(struct dentry *dentry, void *cookie)
void *cookie)
{ {
if (cookie) { free_page((unsigned long)cookie);
unsigned long page = (unsigned long)cookie;
free_page(page);
}
} }
const struct inode_operations configfs_symlink_inode_operations = { const struct inode_operations configfs_symlink_inode_operations = {
......
...@@ -675,18 +675,16 @@ static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz) ...@@ -675,18 +675,16 @@ static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
return rc ? ERR_PTR(rc) : buf; return rc ? ERR_PTR(rc) : buf;
} }
static void *ecryptfs_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *ecryptfs_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
size_t len; size_t len;
char *buf = ecryptfs_readlink_lower(dentry, &len); char *buf = ecryptfs_readlink_lower(dentry, &len);
if (IS_ERR(buf)) if (IS_ERR(buf))
goto out; return buf;
fsstack_copy_attr_atime(d_inode(dentry), fsstack_copy_attr_atime(d_inode(dentry),
d_inode(ecryptfs_dentry_to_lower(dentry))); d_inode(ecryptfs_dentry_to_lower(dentry)));
buf[len] = '\0'; buf[len] = '\0';
out: return *cookie = buf;
nd_set_link(nd, buf);
return NULL;
} }
/** /**
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "xattr.h" #include "xattr.h"
#ifdef CONFIG_EXT4_FS_ENCRYPTION #ifdef CONFIG_EXT4_FS_ENCRYPTION
static void *ext4_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *ext4_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct page *cpage = NULL; struct page *cpage = NULL;
char *caddr, *paddr = NULL; char *caddr, *paddr = NULL;
...@@ -37,7 +37,7 @@ static void *ext4_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -37,7 +37,7 @@ static void *ext4_follow_link(struct dentry *dentry, struct nameidata *nd)
ctx = ext4_get_fname_crypto_ctx(inode, inode->i_sb->s_blocksize); ctx = ext4_get_fname_crypto_ctx(inode, inode->i_sb->s_blocksize);
if (IS_ERR(ctx)) if (IS_ERR(ctx))
return ctx; return ERR_CAST(ctx);
if (ext4_inode_is_fast_symlink(inode)) { if (ext4_inode_is_fast_symlink(inode)) {
caddr = (char *) EXT4_I(inode)->i_data; caddr = (char *) EXT4_I(inode)->i_data;
...@@ -46,7 +46,7 @@ static void *ext4_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -46,7 +46,7 @@ static void *ext4_follow_link(struct dentry *dentry, struct nameidata *nd)
cpage = read_mapping_page(inode->i_mapping, 0, NULL); cpage = read_mapping_page(inode->i_mapping, 0, NULL);
if (IS_ERR(cpage)) { if (IS_ERR(cpage)) {
ext4_put_fname_crypto_ctx(&ctx); ext4_put_fname_crypto_ctx(&ctx);
return cpage; return ERR_CAST(cpage);
} }
caddr = kmap(cpage); caddr = kmap(cpage);
caddr[size] = 0; caddr[size] = 0;
...@@ -77,13 +77,12 @@ static void *ext4_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -77,13 +77,12 @@ static void *ext4_follow_link(struct dentry *dentry, struct nameidata *nd)
/* Null-terminate the name */ /* Null-terminate the name */
if (res <= plen) if (res <= plen)
paddr[res] = '\0'; paddr[res] = '\0';
nd_set_link(nd, paddr);
ext4_put_fname_crypto_ctx(&ctx); ext4_put_fname_crypto_ctx(&ctx);
if (cpage) { if (cpage) {
kunmap(cpage); kunmap(cpage);
page_cache_release(cpage); page_cache_release(cpage);
} }
return NULL; return *cookie = paddr;
errout: errout:
ext4_put_fname_crypto_ctx(&ctx); ext4_put_fname_crypto_ctx(&ctx);
if (cpage) { if (cpage) {
......
...@@ -296,19 +296,15 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -296,19 +296,15 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
return err; return err;
} }
static void *f2fs_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *f2fs_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct page *page = page_follow_link_light(dentry, nd); const char *link = page_follow_link_light(dentry, cookie, nd);
if (!IS_ERR(link) && !*link) {
if (IS_ERR_OR_NULL(page)) /* this is broken symlink case */
return page; page_put_link(dentry, *cookie);
link = ERR_PTR(-ENOENT);
/* this is broken symlink case */
if (*nd_get_link(nd) == 0) {
page_put_link(dentry, nd, page);
return ERR_PTR(-ENOENT);
} }
return page; return link;
} }
static int f2fs_symlink(struct inode *dir, struct dentry *dentry, static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
......
...@@ -1365,7 +1365,7 @@ static int fuse_readdir(struct file *file, struct dir_context *ctx) ...@@ -1365,7 +1365,7 @@ static int fuse_readdir(struct file *file, struct dir_context *ctx)
return err; return err;
} }
static char *read_link(struct dentry *dentry) static const char *fuse_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct inode *inode = d_inode(dentry); struct inode *inode = d_inode(dentry);
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
...@@ -1389,26 +1389,15 @@ static char *read_link(struct dentry *dentry) ...@@ -1389,26 +1389,15 @@ static char *read_link(struct dentry *dentry)
link = ERR_PTR(ret); link = ERR_PTR(ret);
} else { } else {
link[ret] = '\0'; link[ret] = '\0';
*cookie = link;
} }
fuse_invalidate_atime(inode); fuse_invalidate_atime(inode);
return link; return link;
} }
static void free_link(char *link) static void fuse_put_link(struct dentry *dentry, void *cookie)
{ {
if (!IS_ERR(link)) free_page((unsigned long) cookie);
free_page((unsigned long) link);
}
static void *fuse_follow_link(struct dentry *dentry, struct nameidata *nd)
{
nd_set_link(nd, read_link(dentry));
return NULL;
}
static void fuse_put_link(struct dentry *dentry, struct nameidata *nd, void *c)
{
free_link(nd_get_link(nd));
} }
static int fuse_dir_open(struct inode *inode, struct file *file) static int fuse_dir_open(struct inode *inode, struct file *file)
......
...@@ -1548,7 +1548,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, ...@@ -1548,7 +1548,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
* Returns: 0 on success or error code * Returns: 0 on success or error code
*/ */
static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *gfs2_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct gfs2_inode *ip = GFS2_I(d_inode(dentry)); struct gfs2_inode *ip = GFS2_I(d_inode(dentry));
struct gfs2_holder i_gh; struct gfs2_holder i_gh;
...@@ -1561,8 +1561,7 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -1561,8 +1561,7 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)
error = gfs2_glock_nq(&i_gh); error = gfs2_glock_nq(&i_gh);
if (error) { if (error) {
gfs2_holder_uninit(&i_gh); gfs2_holder_uninit(&i_gh);
nd_set_link(nd, ERR_PTR(error)); return ERR_PTR(error);
return NULL;
} }
size = (unsigned int)i_size_read(&ip->i_inode); size = (unsigned int)i_size_read(&ip->i_inode);
...@@ -1586,8 +1585,9 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -1586,8 +1585,9 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)
brelse(dibh); brelse(dibh);
out: out:
gfs2_glock_dq_uninit(&i_gh); gfs2_glock_dq_uninit(&i_gh);
nd_set_link(nd, buf); if (!IS_ERR(buf))
return NULL; *cookie = buf;
return buf;
} }
/** /**
......
...@@ -892,7 +892,7 @@ static const struct inode_operations hostfs_dir_iops = { ...@@ -892,7 +892,7 @@ static const struct inode_operations hostfs_dir_iops = {
.setattr = hostfs_setattr, .setattr = hostfs_setattr,
}; };
static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *hostfs_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
char *link = __getname(); char *link = __getname();
if (link) { if (link) {
...@@ -906,21 +906,18 @@ static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -906,21 +906,18 @@ static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd)
} }
if (err < 0) { if (err < 0) {
__putname(link); __putname(link);
link = ERR_PTR(err); return ERR_PTR(err);
} }
} else { } else {
link = ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
nd_set_link(nd, link); return *cookie = link;
return NULL;
} }
static void hostfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) static void hostfs_put_link(struct dentry *dentry, void *cookie)
{ {
char *s = nd_get_link(nd); __putname(cookie);
if (!IS_ERR(s))
__putname(s);
} }
static const struct inode_operations hostfs_link_iops = { static const struct inode_operations hostfs_link_iops = {
......
...@@ -642,20 +642,19 @@ static int hppfs_readlink(struct dentry *dentry, char __user *buffer, ...@@ -642,20 +642,19 @@ static int hppfs_readlink(struct dentry *dentry, char __user *buffer,
buflen); buflen);
} }
static void *hppfs_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *hppfs_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct dentry *proc_dentry = HPPFS_I(d_inode(dentry))->proc_dentry; struct dentry *proc_dentry = HPPFS_I(d_inode(dentry))->proc_dentry;
return d_inode(proc_dentry)->i_op->follow_link(proc_dentry, nd); return d_inode(proc_dentry)->i_op->follow_link(proc_dentry, cookie, nd);
} }
static void hppfs_put_link(struct dentry *dentry, struct nameidata *nd, static void hppfs_put_link(struct dentry *dentry, void *cookie)
void *cookie)
{ {
struct dentry *proc_dentry = HPPFS_I(d_inode(dentry))->proc_dentry; struct dentry *proc_dentry = HPPFS_I(d_inode(dentry))->proc_dentry;
if (d_inode(proc_dentry)->i_op->put_link) if (d_inode(proc_dentry)->i_op->put_link)
d_inode(proc_dentry)->i_op->put_link(proc_dentry, nd, cookie); d_inode(proc_dentry)->i_op->put_link(proc_dentry, cookie);
} }
static const struct inode_operations hppfs_dir_iops = { static const struct inode_operations hppfs_dir_iops = {
......
...@@ -112,25 +112,23 @@ static int kernfs_getlink(struct dentry *dentry, char *path) ...@@ -112,25 +112,23 @@ static int kernfs_getlink(struct dentry *dentry, char *path)
return error; return error;
} }
static void *kernfs_iop_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *kernfs_iop_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
int error = -ENOMEM; int error = -ENOMEM;
unsigned long page = get_zeroed_page(GFP_KERNEL); unsigned long page = get_zeroed_page(GFP_KERNEL);
if (page) { if (!page)
error = kernfs_getlink(dentry, (char *) page); return ERR_PTR(-ENOMEM);
if (error < 0) error = kernfs_getlink(dentry, (char *)page);
free_page((unsigned long)page); if (unlikely(error < 0)) {
free_page((unsigned long)page);
return ERR_PTR(error);
} }
nd_set_link(nd, error ? ERR_PTR(error) : (char *)page); return *cookie = (char *)page;
return NULL;
} }
static void kernfs_iop_put_link(struct dentry *dentry, struct nameidata *nd, static void kernfs_iop_put_link(struct dentry *dentry, void *cookie)
void *cookie)
{ {
char *page = nd_get_link(nd); free_page((unsigned long)cookie);
if (!IS_ERR(page))
free_page((unsigned long)page);
} }
const struct inode_operations kernfs_symlink_iops = { const struct inode_operations kernfs_symlink_iops = {
......
...@@ -1024,12 +1024,9 @@ int noop_fsync(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -1024,12 +1024,9 @@ int noop_fsync(struct file *file, loff_t start, loff_t end, int datasync)
} }
EXPORT_SYMBOL(noop_fsync); EXPORT_SYMBOL(noop_fsync);
void kfree_put_link(struct dentry *dentry, struct nameidata *nd, void kfree_put_link(struct dentry *dentry, void *cookie)
void *cookie)
{ {
char *s = nd_get_link(nd); kfree(cookie);
if (!IS_ERR(s))
kfree(s);
} }
EXPORT_SYMBOL(kfree_put_link); EXPORT_SYMBOL(kfree_put_link);
...@@ -1094,10 +1091,9 @@ simple_nosetlease(struct file *filp, long arg, struct file_lock **flp, ...@@ -1094,10 +1091,9 @@ simple_nosetlease(struct file *filp, long arg, struct file_lock **flp,
} }
EXPORT_SYMBOL(simple_nosetlease); EXPORT_SYMBOL(simple_nosetlease);
void *simple_follow_link(struct dentry *dentry, struct nameidata *nd) const char *simple_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
nd_set_link(nd, d_inode(dentry)->i_link); return d_inode(dentry)->i_link;
return NULL;
} }
EXPORT_SYMBOL(simple_follow_link); EXPORT_SYMBOL(simple_follow_link);
......
...@@ -502,7 +502,6 @@ struct nameidata { ...@@ -502,7 +502,6 @@ struct nameidata {
int last_type; int last_type;
unsigned depth; unsigned depth;
struct file *base; struct file *base;
char *saved_names[MAX_NESTED_LINKS + 1];
}; };
/* /*
...@@ -713,23 +712,11 @@ void nd_jump_link(struct nameidata *nd, struct path *path) ...@@ -713,23 +712,11 @@ void nd_jump_link(struct nameidata *nd, struct path *path)
nd->flags |= LOOKUP_JUMPED; nd->flags |= LOOKUP_JUMPED;
} }
void nd_set_link(struct nameidata *nd, char *path)
{
nd->saved_names[nd->depth] = path;
}
EXPORT_SYMBOL(nd_set_link);
char *nd_get_link(struct nameidata *nd)
{
return nd->saved_names[nd->depth];
}
EXPORT_SYMBOL(nd_get_link);
static inline void put_link(struct nameidata *nd, struct path *link, void *cookie) static inline void put_link(struct nameidata *nd, struct path *link, void *cookie)
{ {
struct inode *inode = link->dentry->d_inode; struct inode *inode = link->dentry->d_inode;
if (inode->i_op->put_link) if (cookie && inode->i_op->put_link)
inode->i_op->put_link(link->dentry, nd, cookie); inode->i_op->put_link(link->dentry, cookie);
path_put(link); path_put(link);
} }
...@@ -854,7 +841,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p) ...@@ -854,7 +841,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
{ {
struct dentry *dentry = link->dentry; struct dentry *dentry = link->dentry;
int error; int error;
char *s; const char *s;
BUG_ON(nd->flags & LOOKUP_RCU); BUG_ON(nd->flags & LOOKUP_RCU);
...@@ -869,26 +856,20 @@ follow_link(struct path *link, struct nameidata *nd, void **p) ...@@ -869,26 +856,20 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
current->total_link_count++; current->total_link_count++;
touch_atime(link); touch_atime(link);
nd_set_link(nd, NULL);
error = security_inode_follow_link(dentry); error = security_inode_follow_link(dentry);
if (error) if (error)
goto out_put_nd_path; goto out_put_nd_path;
nd->last_type = LAST_BIND; nd->last_type = LAST_BIND;
*p = dentry->d_inode->i_op->follow_link(dentry, nd); *p = NULL;
error = PTR_ERR(*p); s = dentry->d_inode->i_op->follow_link(dentry, p, nd);
if (IS_ERR(*p)) error = PTR_ERR(s);
if (IS_ERR(s))
goto out_put_nd_path; goto out_put_nd_path;
error = 0; error = 0;
s = nd_get_link(nd);
if (s) { if (s) {
if (unlikely(IS_ERR(s))) {
path_put(&nd->path);
put_link(nd, link, *p);
return PTR_ERR(s);
}
if (*s == '/') { if (*s == '/') {
if (!nd->root.mnt) if (!nd->root.mnt)
set_root(nd); set_root(nd);
...@@ -906,7 +887,6 @@ follow_link(struct path *link, struct nameidata *nd, void **p) ...@@ -906,7 +887,6 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
return error; return error;
out_put_nd_path: out_put_nd_path:
*p = NULL;
path_put(&nd->path); path_put(&nd->path);
path_put(link); path_put(link);
return error; return error;
...@@ -4430,18 +4410,15 @@ EXPORT_SYMBOL(readlink_copy); ...@@ -4430,18 +4410,15 @@ EXPORT_SYMBOL(readlink_copy);
*/ */
int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen) int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
{ {
struct nameidata nd;
void *cookie; void *cookie;
const char *link = dentry->d_inode->i_op->follow_link(dentry, &cookie, NULL);
int res; int res;
nd.depth = 0; if (IS_ERR(link))
cookie = dentry->d_inode->i_op->follow_link(dentry, &nd); return PTR_ERR(link);
if (IS_ERR(cookie)) res = readlink_copy(buffer, buflen, link);
return PTR_ERR(cookie); if (cookie && dentry->d_inode->i_op->put_link)
dentry->d_inode->i_op->put_link(dentry, cookie);
res = readlink_copy(buffer, buflen, nd_get_link(&nd));
if (dentry->d_inode->i_op->put_link)
dentry->d_inode->i_op->put_link(dentry, &nd, cookie);
return res; return res;
} }
EXPORT_SYMBOL(generic_readlink); EXPORT_SYMBOL(generic_readlink);
...@@ -4473,22 +4450,21 @@ int page_readlink(struct dentry *dentry, char __user *buffer, int buflen) ...@@ -4473,22 +4450,21 @@ int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)
} }
EXPORT_SYMBOL(page_readlink); EXPORT_SYMBOL(page_readlink);
void *page_follow_link_light(struct dentry *dentry, struct nameidata *nd) const char *page_follow_link_light(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct page *page = NULL; struct page *page = NULL;
nd_set_link(nd, page_getlink(dentry, &page)); char *res = page_getlink(dentry, &page);
return page; if (!IS_ERR(res))
*cookie = page;
return res;
} }
EXPORT_SYMBOL(page_follow_link_light); EXPORT_SYMBOL(page_follow_link_light);
void page_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) void page_put_link(struct dentry *dentry, void *cookie)
{ {
struct page *page = cookie; struct page *page = cookie;
kunmap(page);
if (page) { page_cache_release(page);
kunmap(page);
page_cache_release(page);
}
} }
EXPORT_SYMBOL(page_put_link); EXPORT_SYMBOL(page_put_link);
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/namei.h>
/* Symlink caching in the page cache is even more simplistic /* Symlink caching in the page cache is even more simplistic
* and straight-forward than readdir caching. * and straight-forward than readdir caching.
...@@ -43,7 +42,7 @@ static int nfs_symlink_filler(struct inode *inode, struct page *page) ...@@ -43,7 +42,7 @@ static int nfs_symlink_filler(struct inode *inode, struct page *page)
return -EIO; return -EIO;
} }
static void *nfs_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *nfs_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct inode *inode = d_inode(dentry); struct inode *inode = d_inode(dentry);
struct page *page; struct page *page;
...@@ -51,19 +50,13 @@ static void *nfs_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -51,19 +50,13 @@ static void *nfs_follow_link(struct dentry *dentry, struct nameidata *nd)
err = ERR_PTR(nfs_revalidate_mapping(inode, inode->i_mapping)); err = ERR_PTR(nfs_revalidate_mapping(inode, inode->i_mapping));
if (err) if (err)
goto read_failed; return err;
page = read_cache_page(&inode->i_data, 0, page = read_cache_page(&inode->i_data, 0,
(filler_t *)nfs_symlink_filler, inode); (filler_t *)nfs_symlink_filler, inode);
if (IS_ERR(page)) { if (IS_ERR(page))
err = page; return ERR_CAST(page);
goto read_failed; *cookie = page;
} return kmap(page);
nd_set_link(nd, kmap(page));
return page;
read_failed:
nd_set_link(nd, err);
return NULL;
} }
/* /*
......
...@@ -140,12 +140,12 @@ struct ovl_link_data { ...@@ -140,12 +140,12 @@ struct ovl_link_data {
void *cookie; void *cookie;
}; };
static void *ovl_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *ovl_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
void *ret;
struct dentry *realdentry; struct dentry *realdentry;
struct inode *realinode; struct inode *realinode;
struct ovl_link_data *data = NULL; struct ovl_link_data *data = NULL;
const char *ret;
realdentry = ovl_dentry_real(dentry); realdentry = ovl_dentry_real(dentry);
realinode = realdentry->d_inode; realinode = realdentry->d_inode;
...@@ -160,19 +160,21 @@ static void *ovl_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -160,19 +160,21 @@ static void *ovl_follow_link(struct dentry *dentry, struct nameidata *nd)
data->realdentry = realdentry; data->realdentry = realdentry;
} }
ret = realinode->i_op->follow_link(realdentry, nd); ret = realinode->i_op->follow_link(realdentry, cookie, nd);
if (IS_ERR(ret)) { if (IS_ERR_OR_NULL(ret)) {
kfree(data); kfree(data);
return ret; return ret;
} }
if (data) if (data)
data->cookie = ret; data->cookie = *cookie;
return data; *cookie = data;
return ret;
} }
static void ovl_put_link(struct dentry *dentry, struct nameidata *nd, void *c) static void ovl_put_link(struct dentry *dentry, void *c)
{ {
struct inode *realinode; struct inode *realinode;
struct ovl_link_data *data = c; struct ovl_link_data *data = c;
...@@ -181,7 +183,7 @@ static void ovl_put_link(struct dentry *dentry, struct nameidata *nd, void *c) ...@@ -181,7 +183,7 @@ static void ovl_put_link(struct dentry *dentry, struct nameidata *nd, void *c)
return; return;
realinode = data->realdentry->d_inode; realinode = data->realdentry->d_inode;
realinode->i_op->put_link(data->realdentry, nd, data->cookie); realinode->i_op->put_link(data->realdentry, data->cookie);
kfree(data); kfree(data);
} }
......
...@@ -1380,7 +1380,7 @@ static int proc_exe_link(struct dentry *dentry, struct path *exe_path) ...@@ -1380,7 +1380,7 @@ static int proc_exe_link(struct dentry *dentry, struct path *exe_path)
return -ENOENT; return -ENOENT;
} }
static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *proc_pid_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct inode *inode = d_inode(dentry); struct inode *inode = d_inode(dentry);
struct path path; struct path path;
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/magic.h> #include <linux/magic.h>
#include <linux/namei.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -394,16 +393,16 @@ static const struct file_operations proc_reg_file_ops_no_compat = { ...@@ -394,16 +393,16 @@ static const struct file_operations proc_reg_file_ops_no_compat = {
}; };
#endif #endif
static void *proc_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *proc_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct proc_dir_entry *pde = PDE(d_inode(dentry)); struct proc_dir_entry *pde = PDE(d_inode(dentry));
if (unlikely(!use_pde(pde))) if (unlikely(!use_pde(pde)))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
nd_set_link(nd, pde->data); *cookie = pde;
return pde; return pde->data;
} }
static void proc_put_link(struct dentry *dentry, struct nameidata *nd, void *p) static void proc_put_link(struct dentry *dentry, void *p)
{ {
unuse_pde(p); unuse_pde(p);
} }
......
...@@ -30,7 +30,7 @@ static const struct proc_ns_operations *ns_entries[] = { ...@@ -30,7 +30,7 @@ static const struct proc_ns_operations *ns_entries[] = {
&mntns_operations, &mntns_operations,
}; };
static void *proc_ns_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *proc_ns_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct inode *inode = d_inode(dentry); struct inode *inode = d_inode(dentry);
const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops; const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops;
......
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/namei.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pid_namespace.h> #include <linux/pid_namespace.h>
#include "internal.h" #include "internal.h"
...@@ -19,21 +18,20 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer, ...@@ -19,21 +18,20 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
return readlink_copy(buffer, buflen, tmp); return readlink_copy(buffer, buflen, tmp);
} }
static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *proc_self_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct pid_namespace *ns = dentry->d_sb->s_fs_info; struct pid_namespace *ns = dentry->d_sb->s_fs_info;
pid_t tgid = task_tgid_nr_ns(current, ns); pid_t tgid = task_tgid_nr_ns(current, ns);
char *name = ERR_PTR(-ENOENT); char *name;
if (tgid) {
/* 11 for max length of signed int in decimal + NULL term */ if (!tgid)
name = kmalloc(12, GFP_KERNEL); return ERR_PTR(-ENOENT);
if (!name) /* 11 for max length of signed int in decimal + NULL term */
name = ERR_PTR(-ENOMEM); name = kmalloc(12, GFP_KERNEL);
else if (!name)
sprintf(name, "%d", tgid); return ERR_PTR(-ENOMEM);
} sprintf(name, "%d", tgid);
nd_set_link(nd, name); return *cookie = name;
return NULL;
} }
static const struct inode_operations proc_self_inode_operations = { static const struct inode_operations proc_self_inode_operations = {
......
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/namei.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pid_namespace.h> #include <linux/pid_namespace.h>
#include "internal.h" #include "internal.h"
...@@ -20,21 +19,20 @@ static int proc_thread_self_readlink(struct dentry *dentry, char __user *buffer, ...@@ -20,21 +19,20 @@ static int proc_thread_self_readlink(struct dentry *dentry, char __user *buffer,
return readlink_copy(buffer, buflen, tmp); return readlink_copy(buffer, buflen, tmp);
} }
static void *proc_thread_self_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *proc_thread_self_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct pid_namespace *ns = dentry->d_sb->s_fs_info; struct pid_namespace *ns = dentry->d_sb->s_fs_info;
pid_t tgid = task_tgid_nr_ns(current, ns); pid_t tgid = task_tgid_nr_ns(current, ns);
pid_t pid = task_pid_nr_ns(current, ns); pid_t pid = task_pid_nr_ns(current, ns);
char *name = ERR_PTR(-ENOENT); char *name;
if (pid) {
name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, GFP_KERNEL); if (!pid)
if (!name) return ERR_PTR(-ENOENT);
name = ERR_PTR(-ENOMEM); name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, GFP_KERNEL);
else if (!name)
sprintf(name, "%d/task/%d", tgid, pid); return ERR_PTR(-ENOMEM);
} sprintf(name, "%d/task/%d", tgid, pid);
nd_set_link(nd, name); return *cookie = name;
return NULL;
} }
static const struct inode_operations proc_thread_self_inode_operations = { static const struct inode_operations proc_thread_self_inode_operations = {
......
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/xattr.h> #include <linux/xattr.h>
#include <linux/namei.h>
#include <linux/posix_acl.h> #include <linux/posix_acl.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/fiemap.h> #include <linux/fiemap.h>
...@@ -414,9 +413,10 @@ xfs_vn_rename( ...@@ -414,9 +413,10 @@ xfs_vn_rename(
* we need to be very careful about how much stack we use. * we need to be very careful about how much stack we use.
* uio is kmalloced for this reason... * uio is kmalloced for this reason...
*/ */
STATIC void * STATIC const char *
xfs_vn_follow_link( xfs_vn_follow_link(
struct dentry *dentry, struct dentry *dentry,
void **cookie,
struct nameidata *nd) struct nameidata *nd)
{ {
char *link; char *link;
...@@ -430,14 +430,12 @@ xfs_vn_follow_link( ...@@ -430,14 +430,12 @@ xfs_vn_follow_link(
if (unlikely(error)) if (unlikely(error))
goto out_kfree; goto out_kfree;
nd_set_link(nd, link); return *cookie = link;
return NULL;
out_kfree: out_kfree:
kfree(link); kfree(link);
out_err: out_err:
nd_set_link(nd, ERR_PTR(error)); return ERR_PTR(error);
return NULL;
} }
STATIC int STATIC int
......
...@@ -1608,12 +1608,12 @@ struct file_operations { ...@@ -1608,12 +1608,12 @@ struct file_operations {
struct inode_operations { struct inode_operations {
struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
void * (*follow_link) (struct dentry *, struct nameidata *); const char * (*follow_link) (struct dentry *, void **, struct nameidata *);
int (*permission) (struct inode *, int); int (*permission) (struct inode *, int);
struct posix_acl * (*get_acl)(struct inode *, int); struct posix_acl * (*get_acl)(struct inode *, int);
int (*readlink) (struct dentry *, char __user *,int); int (*readlink) (struct dentry *, char __user *,int);
void (*put_link) (struct dentry *, struct nameidata *, void *); void (*put_link) (struct dentry *, void *);
int (*create) (struct inode *,struct dentry *, umode_t, bool); int (*create) (struct inode *,struct dentry *, umode_t, bool);
int (*link) (struct dentry *,struct inode *,struct dentry *); int (*link) (struct dentry *,struct inode *,struct dentry *);
...@@ -2705,13 +2705,13 @@ extern const struct file_operations generic_ro_fops; ...@@ -2705,13 +2705,13 @@ extern const struct file_operations generic_ro_fops;
extern int readlink_copy(char __user *, int, const char *); extern int readlink_copy(char __user *, int, const char *);
extern int page_readlink(struct dentry *, char __user *, int); extern int page_readlink(struct dentry *, char __user *, int);
extern void *page_follow_link_light(struct dentry *, struct nameidata *); extern const char *page_follow_link_light(struct dentry *, void **, struct nameidata *);
extern void page_put_link(struct dentry *, struct nameidata *, void *); extern void page_put_link(struct dentry *, void *);
extern int __page_symlink(struct inode *inode, const char *symname, int len, extern int __page_symlink(struct inode *inode, const char *symname, int len,
int nofs); int nofs);
extern int page_symlink(struct inode *inode, const char *symname, int len); extern int page_symlink(struct inode *inode, const char *symname, int len);
extern const struct inode_operations page_symlink_inode_operations; extern const struct inode_operations page_symlink_inode_operations;
extern void kfree_put_link(struct dentry *, struct nameidata *, void *); extern void kfree_put_link(struct dentry *, void *);
extern int generic_readlink(struct dentry *, char __user *, int); extern int generic_readlink(struct dentry *, char __user *, int);
extern void generic_fillattr(struct inode *, struct kstat *); extern void generic_fillattr(struct inode *, struct kstat *);
int vfs_getattr_nosec(struct path *path, struct kstat *stat); int vfs_getattr_nosec(struct path *path, struct kstat *stat);
...@@ -2722,7 +2722,7 @@ void __inode_sub_bytes(struct inode *inode, loff_t bytes); ...@@ -2722,7 +2722,7 @@ void __inode_sub_bytes(struct inode *inode, loff_t bytes);
void inode_sub_bytes(struct inode *inode, loff_t bytes); void inode_sub_bytes(struct inode *inode, loff_t bytes);
loff_t inode_get_bytes(struct inode *inode); loff_t inode_get_bytes(struct inode *inode);
void inode_set_bytes(struct inode *inode, loff_t bytes); void inode_set_bytes(struct inode *inode, loff_t bytes);
void *simple_follow_link(struct dentry *, struct nameidata *); const char *simple_follow_link(struct dentry *, void **, struct nameidata *);
extern const struct inode_operations simple_symlink_inode_operations; extern const struct inode_operations simple_symlink_inode_operations;
extern int iterate_dir(struct file *, struct dir_context *); extern int iterate_dir(struct file *, struct dir_context *);
......
...@@ -71,8 +71,6 @@ extern struct dentry *lock_rename(struct dentry *, struct dentry *); ...@@ -71,8 +71,6 @@ extern struct dentry *lock_rename(struct dentry *, struct dentry *);
extern void unlock_rename(struct dentry *, struct dentry *); extern void unlock_rename(struct dentry *, struct dentry *);
extern void nd_jump_link(struct nameidata *nd, struct path *path); extern void nd_jump_link(struct nameidata *nd, struct path *path);
extern void nd_set_link(struct nameidata *nd, char *path);
extern char *nd_get_link(struct nameidata *nd);
static inline void nd_terminate_link(void *name, size_t len, size_t maxlen) static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
{ {
......
...@@ -2475,24 +2475,23 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s ...@@ -2475,24 +2475,23 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
return 0; return 0;
} }
static void *shmem_follow_link(struct dentry *dentry, struct nameidata *nd) static const char *shmem_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd)
{ {
struct page *page = NULL; struct page *page = NULL;
int error = shmem_getpage(d_inode(dentry), 0, &page, SGP_READ, NULL); int error = shmem_getpage(d_inode(dentry), 0, &page, SGP_READ, NULL);
nd_set_link(nd, error ? ERR_PTR(error) : kmap(page)); if (error)
if (page) return ERR_PTR(error);
unlock_page(page); unlock_page(page);
return page; *cookie = page;
return kmap(page);
} }
static void shmem_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) static void shmem_put_link(struct dentry *dentry, void *cookie)
{ {
if (!IS_ERR(nd_get_link(nd))) { struct page *page = cookie;
struct page *page = cookie; kunmap(page);
kunmap(page); mark_page_accessed(page);
mark_page_accessed(page); page_cache_release(page);
page_cache_release(page);
}
} }
#ifdef CONFIG_TMPFS_XATTR #ifdef CONFIG_TMPFS_XATTR
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册