libc: add special file class to implement *mnt* functions

Few well known files like /etc/mtab, /etc/mnttab, or /proc/mounts gives
us view of mounted file systems. The APIs like getmntent, setmntent
etc are simple interfaces to work with these files. However, OSv does
not manage any of these well know files. Therefore, in order for these
functions to work, the mounted file system information is generated
from memory.

This patch implements a new class, call mtab_file, inherited from
special_file class. It allows us to implement all the standard file
operations.

This patch is essential for ZFS mount, unmount, and export to work
correctly. ZFS has its own mechanism to mount or unmount a ZFS file
system. For example: zfs mount command mounts a ZFS file system and
zfs unmount command unmounts a ZFS file system. zfs export command,
exports an earlier imported pool. When a pool is exported all the file
systems created and mounted must be unmounted before a pool can be
exported. Therefore, ZFS needs to have an exact view of currently
mounted file systems. ZFS uses getmntent function to read currently
mouted file systems.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
procfs: add mounts file

File /proc/mounts - maintains a list of all the filesystems currently
mounted. The format of data is similar to standard fstab format.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
zfs: fix umount and export functionality

zfs mount/umount - allows user to mount/unmount the given dataset.
zpool export - allows user to export already imported ZFS pool. The
export functionality has to ensure that no dataset (file system)
belonging to exported pool is mounted.

Both zfs unmount/mount/export rely on common functionality implemented
in libzfs to give correct list of mounted file systems. libzfs reads
the mount information from /etc/mnttab. With this patch /etc/mnttab is
a symlink to /proc/mounts.

ZFS code uses BSD specific mechanism to find list of mount entries.
Specifically, BSD uses different structure called mnttab as opposed to
mntent used on Linux. The API getmntent() on BSD and Linux assumes
different prototype. This patch introduces new BSD porting functions
to map to Linux equivalent.

Reviewed-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
modules/lua: fix build failure

Building cli image fails with following error -

$ make -j 6 mode=release image=cli

make[2]: Entering directory `.../osv/modules/lua'
cd src && make
cd build/luarocks-2.1.2 && \
    ./configure --prefix=.../osv/modules/lua/out --force-config \
    --with-lua-include=.../osv/modules/lua/src --lua-version=5.2
make[3]: Entering directory `/.../osv/modules/lua/src'
gcc -O2 -Wall -fPIC -DLUA_COMPAT_ALL -DLUA_USE_LINUX -shared -o \
   liblua.so  lapi.o ...........
gcc -o lua  lua.o liblua.a -lm -ldl -ledit
make[3]: Leaving directory `.../osv/modules/lua/src'
cp src/lua out/bin/lua
lua not found in $PATH.
You may want to use the flags --with-lua and/or --lua-suffix.
See --help.

configure failed.

make[2]: *** [build/luarocks-2.1.2/Makefile] Error 1
make[2]: Leaving directory `.../osv/modules/lua'

The patch fixes build for me.

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http Server: Add test for thread CPU

To test that the cpu parameter correct, the test check that the cpu of
idle1 (the idle thread of cpu1) is equal to 1.

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