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:
@@ -41,7 +41,6 @@
|
||||
|
||||
#include <linux/capability.h>
|
||||
#include <linux/xattr.h>
|
||||
#include <linux/namei.h>
|
||||
#include <linux/posix_acl.h>
|
||||
#include <linux/security.h>
|
||||
#include <linux/fiemap.h>
|
||||
@@ -414,9 +413,10 @@ xfs_vn_rename(
|
||||
* we need to be very careful about how much stack we use.
|
||||
* uio is kmalloced for this reason...
|
||||
*/
|
||||
STATIC void *
|
||||
STATIC const char *
|
||||
xfs_vn_follow_link(
|
||||
struct dentry *dentry,
|
||||
void **cookie,
|
||||
struct nameidata *nd)
|
||||
{
|
||||
char *link;
|
||||
@@ -430,14 +430,12 @@ xfs_vn_follow_link(
|
||||
if (unlikely(error))
|
||||
goto out_kfree;
|
||||
|
||||
nd_set_link(nd, link);
|
||||
return NULL;
|
||||
return *cookie = link;
|
||||
|
||||
out_kfree:
|
||||
kfree(link);
|
||||
out_err:
|
||||
nd_set_link(nd, ERR_PTR(error));
|
||||
return NULL;
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
|
||||
STATIC int
|
||||
|
Reference in New Issue
Block a user