Currently there is only uname syscall in it. Signed-off-by: Wei Liu <wei.l...@citrix.com> --- Cc: Ian Jackson <ian.jack...@eu.citrix.com> Cc: d...@recoil.org Cc: christian.lin...@citrix.com Cc: jonathan.lud...@citrix.com Cc: Roger Pau Monné <roger....@citrix.com> --- tools/ocaml/xenstored/Makefile | 9 ++++-- tools/ocaml/xenstored/unix_syscalls.ml | 29 ++++++++++++++++++ tools/ocaml/xenstored/unix_syscalls.mli | 29 ++++++++++++++++++ tools/ocaml/xenstored/unix_syscalls_stubs.c | 46 +++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 tools/ocaml/xenstored/unix_syscalls.ml create mode 100644 tools/ocaml/xenstored/unix_syscalls.mli create mode 100644 tools/ocaml/xenstored/unix_syscalls_stubs.c
diff --git a/tools/ocaml/xenstored/Makefile b/tools/ocaml/xenstored/Makefile index d23883683d..cfd4d81b9e 100644 --- a/tools/ocaml/xenstored/Makefile +++ b/tools/ocaml/xenstored/Makefile @@ -18,12 +18,14 @@ OCAMLINCLUDE += \ -I $(OCAML_TOPLEVEL)/libs/xc \ -I $(OCAML_TOPLEVEL)/libs/eventchn -LIBS = syslog.cma syslog.cmxa select.cma select.cmxa +LIBS = syslog.cma syslog.cmxa select.cma select.cmxa unix_syscalls.cma unix_syscalls.cmxa syslog_OBJS = syslog syslog_C_OBJS = syslog_stubs select_OBJS = select select_C_OBJS = select_stubs -OCAML_LIBRARY = syslog select +unix_syscalls_C_OBJS = unix_syscalls_stubs +unix_syscalls_OBJS = unix_syscalls +OCAML_LIBRARY = syslog select unix_syscalls LIBS += systemd.cma systemd.cmxa systemd_OBJS = systemd @@ -58,13 +60,14 @@ OBJS = paths \ process \ xenstored -INTF = symbol.cmi trie.cmi syslog.cmi systemd.cmi select.cmi +INTF = symbol.cmi trie.cmi syslog.cmi systemd.cmi select.cmi unix_syscalls.cmi XENSTOREDLIBS = \ unix.cmxa \ -ccopt -L -ccopt . syslog.cmxa \ -ccopt -L -ccopt . systemd.cmxa \ -ccopt -L -ccopt . select.cmxa \ + -ccopt -L -ccopt . unix_syscalls.cmxa \ -ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/mmap $(OCAML_TOPLEVEL)/libs/mmap/xenmmap.cmxa \ -ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/xeneventchn.cmxa \ -ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xc $(OCAML_TOPLEVEL)/libs/xc/xenctrl.cmxa \ diff --git a/tools/ocaml/xenstored/unix_syscalls.ml b/tools/ocaml/xenstored/unix_syscalls.ml new file mode 100644 index 0000000000..b52a07967d --- /dev/null +++ b/tools/ocaml/xenstored/unix_syscalls.ml @@ -0,0 +1,29 @@ +(* + * unix_syscalls.ml + * + * Stubs for unix syscalls + * + * Copyright (C) 2017 Wei Liu <wei.l...@citrix.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License, version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + *) + +type utsname = { + sysname: string; + nodename: string; + release: string; + version: string; + machine: string; +} + +external uname : unit -> utsname = "unix_uname" diff --git a/tools/ocaml/xenstored/unix_syscalls.mli b/tools/ocaml/xenstored/unix_syscalls.mli new file mode 100644 index 0000000000..8e9adaf0a4 --- /dev/null +++ b/tools/ocaml/xenstored/unix_syscalls.mli @@ -0,0 +1,29 @@ +(* + * unix_syscalls.mli + * + * Stubs for unix syscalls + * + * Copyright (C) 2017 Wei Liu <wei.l...@citrix.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License, version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + *) + +type utsname = { + sysname: string; + nodename: string; + release: string; + version: string; + machine: string; +} + +external uname : unit -> utsname = "unix_uname" diff --git a/tools/ocaml/xenstored/unix_syscalls_stubs.c b/tools/ocaml/xenstored/unix_syscalls_stubs.c new file mode 100644 index 0000000000..1cd46d0834 --- /dev/null +++ b/tools/ocaml/xenstored/unix_syscalls_stubs.c @@ -0,0 +1,46 @@ +/* + * unix_syscalls_stub.c + * + * Stubs for unix syscalls + * + * Copyright (C) 2017 Wei Liu <wei.l...@citrix.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License, version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + */ + +#include <sys/utsname.h> +#include <caml/mlvalues.h> +#include <caml/memory.h> +#include <caml/fail.h> +#include <caml/alloc.h> +#include <caml/signals.h> +#include <caml/unixsupport.h> + +CAMLprim value unix_uname(value ignored) +{ + CAMLparam1(ignored); + CAMLlocal1(utsname); + struct utsname buf; + + if (uname(&buf)) + uerror("uname", Nothing); + + utsname = caml_alloc(5, 0); + Store_field(utsname, 0, caml_copy_string(buf.sysname)); + Store_field(utsname, 1, caml_copy_string(buf.nodename)); + Store_field(utsname, 2, caml_copy_string(buf.release)); + Store_field(utsname, 3, caml_copy_string(buf.version)); + Store_field(utsname, 4, caml_copy_string(buf.machine)); + + CAMLreturn(utsname); +} -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel