fs: add openat systemcall

openat system call be used to open a file relative to passed directory
fd.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: add dirfd api

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Reviewed-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
test: add openat testcase

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libzfs: define unresolved devid_get function

Reviewed-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libzfs: disable BSD specific geom_gettree call

Reviewed-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
zfs: skip character devices for ZFS pool lookup

ZFS zpool would only be created on block devices passed to OSv instance.
This patch removes all character devices being lookedup for a pool. The
change is essential, since reading from console for example would block
indefinitely.

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
zpool: fix pool import assert when name starts with number

Reviewed-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
zfs: ioctl(TRYIMPORT) must fail if config buf is insufficient

ZFS maintains pool configuration in nvlist inside VDEV label. Block
devices which are part of a pool are called as VDEVs. VDEVs form a
hierarchical tree like structure. A VDEV label contains information
describing this physical VDEV as well as all VDEVs which share common
top level logical VDEV.

When pool is imported, ZFS finds appropriate block device and reads
VDEV label for pool configuration. Since a single VDEV only maintains
information about all VDEVs which share common logical VDEV. It has to
refresh the configuration information to know about other logical VDEVs.

ZFS uses IOCTL(ZFS_IOC_POOL_TRYIMPORT) to try a pool import. The
TRYIMPORT also returns, to caller, complete pool configuration along
with it's health information. However, if the passed buffer from
userland is insufficient to capture all config information, it must
fail with ENOMEM. Instructing the caller, to pass larger buffer. The
expected size of the buffer is also passed to caller. The caller,
refresh_config() then allocates larger buffer and retries ioctl.

Reviewed-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
elf: initial implementation of getauxval

getauxval is a quite arcane function that returns characteristics of the ELF
loader. For the initial support of RPM, only a couple of fields are needed.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>