* Christoph Hellwig <[email protected]> wrote:
> ->follow_link needs exactly the same locking as ->readlink. The whole
> point of using generic_readlink is to avoid having the filesystem
> reimplement almost the same code twice, once copying to a kernel
> buffer and once to a user buffer.
yeah, you are right, i confused it with ->follow_link() and was wrong
about the locking: generic_readlink() is just a wrapper around
->follow_link() and vfs_readlink().
Still, as far as i can see the gfs2 implementation of readlink is faster
(and hence a valid solution), because it knows the length of the symlink
buffer and hence can avoid the strlen() call in vfs_readlink():
int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
{
int len;
len = PTR_ERR(link);
if (IS_ERR(link))
goto out;
len = strlen(link); <============= [this one]
while gfs2 can do a straight copy to userspace:
error = gfs2_readlinki(ip, &buf, &len);
if (error)
return error;
if (user_size > len - 1)
user_size = len - 1;
if (copy_to_user(user_buf, buf, user_size))
error = -EFAULT;
else
error = user_size;
btw., ocfs2 does not use generic_readlink() either.
> Please read the code before giving such useless comments.
thank you for the encouragement to participate in VFS review activities,
it's really appreciated! It's always a joy taking part in lkml
discussions.
Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]