Fix readlink(2)
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 16 Feb 2011 23:54:55 +0000 (15:54 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 16 Feb 2011 23:54:55 +0000 (15:54 -0800)
commit8b4f9a2d55fc5ee28f69b29f2fece7d8e2cb5c7a
tree861a08730d642af38bbc891003b1fcc430029464
parentb9f6a49025809d658754c758dc7e2a81ee41271b
Fix readlink(2)

This patch addresses three issues related to symlinks.

1) Revert the zfs_follow_link() function to a modified version
of the original zfs_readlink().  The only changes from the
original OpenSolaris version relate to using Linux types.
For the moment this means no vnode's and no zfsvfs_t.  The
caller zpl_follow_link() was also updated accordingly.  This
change was reverted because it was slightly gratuitious.

2) Update zpl_follow_link() to use local variables for the
link buffer.  I'd forgotten that iov.iov_base is updated by
uiomove() so after the call to zfs_readlink() it can not longer
be used.  We need our own private copy of the link pointer.

3) Allocate MAXPATHLEN instead of MAXPATHLEN+1.  By default
MAXPATHLEN is 4096 bytes which is a full page, adding one to
it pushes it slightly over a page.  That means you'll likely
end up allocating 2 pages which is wasteful of memory and
possibly slightly slower.
module/zfs/zfs_vnops.c
module/zfs/zpl_inode.c