elf: implement tls for shared objects

Unlike tls for the main module, which simply offsets fs:0, shared object
use an indirection scheme since each module gets its own tls base address,
which needs to be found (and initialized) via __get_tls_addr()

Implement __get_tls_addr() and the associated relocation and storage
management.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: build core/run.cc

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
run: add helper for running with a vector<string> argv

Much easier than constructing a traditional argc/argv.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Fix build with GNU Make < 3.82

The 'define' form with '=' was introduced in GNU Make 3.82
and has the same meaning as without.

The default 'make' in Ubuntu 13.04 is stil on 3.81. Let's
drop '=' for better compatibility.

Symptoms:
 make[1]: Entering directory `~/src/osv/build/release'
      CC bsd/cddl/contrib/opensolaris/cmd/zpool/zpool_iter.o
    ../../bsd/cddl/contrib/opensolaris/cmd/zpool/zpool_iter.c:28:21:\
 fatal error: solaris.h: No such file or     directory
     #include <solaris.h>
                         ^
    compilation terminated.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
run: save optind across invocations

optind is a global variable that is expected to be zero-initialized by
getopt().  Running one object after another violates this, if both use
getopt().

Fix by saving the value of optind across calls.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Merge branch 'run-fixes'

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc: implement sync()

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc: define mbstate_t as __mbstate_t

std::streambuf<char> is defined as an "extern template", which means it is
instantiated in the library, not at the point-of-use, in order to reduce
object size and compilation time.

One of its member functions, std::basic_streambuf::seekpos(...) has a
parameter whose type depends on mbstate_t; this embeds the type name into
the mangled function name.

On Linux, mbstate_t is a typedef for __mbstate_t, so the latter type name
is embedded into the mangled function name.  On osv, there is no such typedef,
so mbstate_t is embedded.  This causes lookup to fail when loading a shared
object that uses streambufs.

Fix by defining mbstate_t in the same way as glibc.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc: stub eventfd()

Needed by boost.asio.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc: implement epoll_create1()

It's a superset of epoll_create(), so implement the latter in terms of the
former.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
run: switch to cache=none

More realistic.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
run: allow forwarding tcp ports in run.py

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
imgedit: fix large partition chs

Large partitions set head=254, not 255.  Also be more accurate calculating
the exact point of overflow.
build: package zfs.so (the zfs utility) in bootfs

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mkfs: Add stub mkfs()

For the moment, it only creates a zpool, not a filesystem.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
paths.h: fix _PATH_MNTTAB

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc: stub epoll EPOLLET treatment

Ignoring EPOLLET will generate more wakeups, but should work with most
applications.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
zfs: wire up some exporting functionality
mkfs: create /etc/mnttab

zfs utilities want /etc/mnttab, let them have it.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mkfs: create a filesystem

Create a file system on top of the pool.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>