vfs: Add VOP_LINK to VFS interface

Add VOP_LINK to the VFS interface in preparation for sys_link().

Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com>
[ penberg: split to separate commit ]
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
devfs: Wire up VOP_LINK

Wire up the VOP_LINK vnode operation for devfs in preparation for
sys_link().

Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com>
[ penberg: split to separate commit ]
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
ramfs: Wire up VOP_LINK

Wire up the VOP_LINK vnode operation for ramfs in preparation for
sys_link().

Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com>
[ penberg: split to separate commit ]
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
zfs: Wire up VOP_LINK

Wire up the VOP_LINK vnode operation for ZFS in preparation for
sys_link().

Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com>
[ penberg: drop FIGNORE, cleanup, split ]
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
zfs: Update ->va_nlink in zfs_getattr()

Update ->va_nlink() in zfs_getattr() in preparation for sys_link().

Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: Add link() system call

This patch adds the link() system call.

The system call uses the filesystem specific VOP_LINK vnode operation to
do the actual work.  ZFS is currently the only available file system
that supports hard links and the other filesystems return EPERM.

Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: Return inode number and link count in vn_stat()

Make vn_stat() return inode number and link count in st_ino and
st_nlink, respectively.

Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tst-fs-link.so: link() test

Add a basic test case for filesystem hard link support. You can run it as
follows:

  ./scripts/run.py -e "tests/tst-fs-link.so"

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tst-fs-link: Add extra checks

Add a new test to see if the content from one link would be the same in
another.

Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: Drop ->vop_link NULL check from sys_link()

Filesystems are expected to wire up ->vop_link so it can never be NULL.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: Call parent directory dentry 'newdirdp' in sys_link()

Call the dentry that refers to the newpath parent directory "newdirdp"
to make the code more explicit.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: Simplify sys_link() unwinding

We can safely use the same function exit points for both successful and
error cases.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tst-fs-link.so: Make paths configurable

Make the link source and target paths configurable so the test can be
run on Linux:

  $ g++ -std=c++11 tst-fs-link.cc && ./a.out foo foo2

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tst-fs-link.so: Test case for link if source does not exist

Check that link returns ENOENT if source does not exist.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tst-fs-link.so: Add test case for link if destination exists

Check that link returns EEXIST if destination exists.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>