vfs: change vfs_lookup to CPP code

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: delete dentry of removed directory in sys_rmdir

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: add support to follow symlink in namei

namei functions resolves path and returns it's directory entry. namei
processes each component of the path separately. To ensure correct
processing of the path, namei should follow any symbolic link it may
encounter. Symbolic link is a pointer to another directory entry. It
contains path to which it points. To follow a symbolic link, the path
to which it points must be read first. A standard system call to read
path to which symbolic link points is readlink.

A readlink reads value of symbolic link and copies it in return buffer.
However, for readlink to work, last component of given path must not
be followed.

In summary, this patch
1. Modifies namei to follow symbolic link
2. Adds a new API namei_last_nofollow() which works like namei, except
if last component of the path is symbolic link it won't follow it.
3. Adds readlink functionality

V1:
- changed return prototype of sys_readlink
- added lock in read_link before reading link value
- changed plan char * to std::unique_ptr
- refactored namei() code and removed a goto

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: open with O_NOFOLLOW must fail when path is symlink

open fucntion must return ELOOP when given path is symbolic link. The
patch adds corresponding check for open flag.

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: modify rename to work with symlink

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: unlink change to work with symlink

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: add lstat support

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc: stub getgroups and setgroups

Roman says:

  getgroups(2) needs to be stubbed This is required by
  jre/lib/amd64/libjaas_unix.so and should be pretty easy to do.

Fixes #349.

Reported-by: Roman Shaposhnik <roman@shaposhnik.org>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: add symlink support

V1:
- refactored code to remove gotos
- replaced char * with std::unique_ptr
- removed a directory entry is check race

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
tests: add symlink test

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: remove checks on symlink target

It is perfectly legal to create a dangling symlink; from symlink(2):

  "NOTES
       No checking of oldpath is done."

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
cpiod: don't ignore symlinks

Java wants symlinks, allow them.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
modules: allow symbolic links

Don't complain about broken links (they can be unbroken after the entire fs
image is assembled).

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: teach upload_manifest about symlinks

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
java: fix RPATH trouble

Newer openjdk has RPATH in some shared objects containing the full package
path (/usr/lib/jvm/java-1.7.0-openjdk-$release.x864_64), and tries to load
packages from that path.

While we should evnetually place the files there, that's too large a change.
Instead, keep the jdk in /usr/lib/jvm/java and create a symbolic link
/usr/lib/jvm/java-1.7.0-openjdk-$release.x864_64 to point to that, so RPATH
can be satisified.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Merge tag 'rpath-5' of https://github.com/avikivity/osv

"A recent JVM change caused Java to fail: openjdk now uses RPATH in its
shared objects, referring to the full path
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.7.4.fc20.x86_64. Since we also
need to support the standard paths /usr/lib/jvm/java and /usr/lib/jvm/jre, we
have to employ symlinks.

This series, including Prasad's symlink series, adds symlink support to osv
and its module system, and changes the Java module to include the extra path.
With it, cassandra now works."

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Merge branch 'master' of https://github.com/cloudius-systems/osv