Take fcvt.c from musl instead of our modified copy

The only change in our fcvt.c was to circumvent a conflict with glibc's
headers, but this is irrelevant because we no longer use glibc headers.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Use two libc/time files from musl

Unfortunately, many of the files in libc/time are quite heavily modified
from musl (I am not sure why we did that), but found at least two functions,
strptime() and time(), where our changes from musl were trivial and
unnecessary. So use the musl version for these two files.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Eliminate libc/dirent directory

All of our dirent functions (readdir, opendir, etc.) are our own
implementation, in fs/vfs/main.cc, and not taken from Musl.
Therefore it is silly we only took one small function, fdopendir.c,
from musl, and even there we had to modify that function to fit our code.

So this patch eliminates the libc/dirent directory - fdopendir.c and
dirent.h, and instead puts the tiny fdopendir() implementation with
all its friends, in fs/vfs/main.cc.

This patch also takes include/api/dirent.h unmodified from musl.
We previously had small modifications to that file, and there is
no real justification for that.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cli: Add timezone to os_date api response

Fixes #558

Add timezone info to the Date/Hour API and CLI response

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cli: Fix 'api network route' output

Fixes #535

* Changed op type for 'GET /network/routes' from 'array' to 'Routes'
* Added renderer for 'Routes'

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
add sched_getaffinity stub and implement sysconf(_SC_OPEN_MAX)

they are needed to start Erlang Shell

Signed-off-by: bhuztez <bhuztez@gmail.com>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
include/api: Migrate to upstream musl headers

Replace include/api headers that are identical with our upstream musl
version with symlinks to the musl headers. Once we have migrated all the
headers, we can make include/api a symlink to musl/include.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
apps: update to latest

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sched: kernel threads shouldn't keep reference to any app

It is possible that an application thread causes a creation of a kernel
thread (e.g. some ZFS related ioctls tend to do that). Such threads
shouldn't keep reference to the application of the thread that spawned
them since that may needlesly defer the destructon of such application.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
runtime: Remove duplicate libintl.h include

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
httpserver/osv-gui: update to latest

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
monitoring-agent: Fix Boost ASIO error handling

If OSv image is started under QEMU without networking, it blows up as follows:

  [penberg@nero osv]$ qemu-system-x86_64 -hda build/release/usr.img -nographic
  OSv v0.16-10-g1d18311
  pthread_setcancelstate() stubbed
  /#
  /# Aborted

  [backtrace]
  0x0000000000444251 <osv::generate_signal(siginfo&, exception_frame*)+49>
  0x00000000004442ba <osv::handle_mmap_fault(unsigned long, int, exception_frame*)+26>
  0x000000000032ed13 <mmu::vm_fault(unsigned long, exception_frame*)+147>
  0x0000000000392199 <page_fault+105>
  0x0000000000391086 <???+3739782>
  0x0000100000cf0d83 <boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>::dereference() const+43>
  0x0000100000cedd13 <boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>::operator->() const+23>
  0x000010000587fa8e <monitoring_agent::client::getaddr(std::string const&)+424>
  0x000010000587efc3 <monitoring_agent::client::upload(std::string const&, std::string const&, unsigned int, std::string const&, std::string const&, std::string const&)+101>
  0x0000100005873644 <???+92747332>
  0x000010000586cc50 <???+92720208>
  0x0000000000410d4a <osv::application::run_main(std::string, int, char**)+266>
  0x00000000004124f7 <osv::application::run_main()+567>
  0x000000000020c048 <osv::application::main()+88>
  0x00000000004127c8 <???+4270024>
  0x000000000043f6d5 <???+4454101>
  0x00000000003ed867 <thread_main_c+39>
  0x0000000000392005 <???+3743749>
  QEMU: Terminated

Fix that by checking for all errors, not just 'host_not_found' when
resolving an address.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
RHEL-based distros support

This patch implements initial support of RHEL-based distributions
(RHEL, CentOS, Scientific/NauLinux, Oracle Linux) as a building host.
In setup script added possibility of using of distributions flavors
array, possibility of partial description of distribution name (RHEL
and Oracle specific) and partial version numbering (accordingly new
scheme of CentOS minor version numbering).

Signed-off-by: Oleg Sadov <oleg.sadov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
apps: update to latest

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
apps: update to latest

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
run.py: Support for multiple virtual NICs

This adds a '--nics' command line option to run.py that specifies number
of virtual NICs in the launched VM. For example, to launch QEMU with 4
NICs:

  [penberg@nero osv]$ sudo ./scripts/run.py -n --nics 4
  OSv v0.16-14-g2514672
  eth0: 192.168.122.89
  eth3: 192.168.122.92
  eth2: 192.168.122.91
  eth1: 192.168.122.90

Please note that this only works with DHCP because the command line
interface allows you to only specify MAC address and static IP
configuration for a single NIC.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
console: remove unused header

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Add support for waking up only a given amount of threads

This will enable Erlang to run with options 'threads' and 'smp' on OSv.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Bas Wegh <BasWegh@gmx.de>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http server: load plugin module in global_server.cc