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: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -626,8 +626,8 @@ cifs_hl_exit:
|
||||
return rc;
|
||||
}
|
||||
|
||||
void *
|
||||
cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
|
||||
const char *
|
||||
cifs_follow_link(struct dentry *direntry, void **cookie, struct nameidata *nd)
|
||||
{
|
||||
struct inode *inode = d_inode(direntry);
|
||||
int rc = -ENOMEM;
|
||||
@@ -643,16 +643,18 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
|
||||
|
||||
tlink = cifs_sb_tlink(cifs_sb);
|
||||
if (IS_ERR(tlink)) {
|
||||
rc = PTR_ERR(tlink);
|
||||
tlink = NULL;
|
||||
goto out;
|
||||
free_xid(xid);
|
||||
return ERR_CAST(tlink);
|
||||
}
|
||||
tcon = tlink_tcon(tlink);
|
||||
server = tcon->ses->server;
|
||||
|
||||
full_path = build_path_from_dentry(direntry);
|
||||
if (!full_path)
|
||||
goto out;
|
||||
if (!full_path) {
|
||||
free_xid(xid);
|
||||
cifs_put_tlink(tlink);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
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)
|
||||
&target_path, cifs_sb);
|
||||
|
||||
kfree(full_path);
|
||||
out:
|
||||
free_xid(xid);
|
||||
cifs_put_tlink(tlink);
|
||||
if (rc != 0) {
|
||||
kfree(target_path);
|
||||
target_path = ERR_PTR(rc);
|
||||
return ERR_PTR(rc);
|
||||
}
|
||||
|
||||
free_xid(xid);
|
||||
if (tlink)
|
||||
cifs_put_tlink(tlink);
|
||||
nd_set_link(nd, target_path);
|
||||
return NULL;
|
||||
return *cookie = target_path;
|
||||
}
|
||||
|
||||
int
|
||||
|
Reference in New Issue
Block a user