From db8609cbab0636ad30f065a2865c6c5d4190eb5c Mon Sep 17 00:00:00 2001 From: Stelian Ionescu Date: Thu, 22 Jan 2009 20:05:14 +0100 Subject: [PATCH] Add %SYS-UNAME. --- syscalls/ffi-functions-unix.lisp | 17 +++++++++++++++++ syscalls/ffi-types-unix.lisp | 12 +++++++++++- syscalls/pkgdcl.lisp | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/syscalls/ffi-functions-unix.lisp b/syscalls/ffi-functions-unix.lisp index 7784947..6b6278e 100644 --- a/syscalls/ffi-functions-unix.lisp +++ b/syscalls/ffi-functions-unix.lisp @@ -606,6 +606,23 @@ (defentrypoint %sys-getdomainname () (with-foreign-pointer-as-string ((cstr size) 256) (%%sys-getdomainname cstr size))) + +(defsyscall ("uname" %%sys-uname) :int + (buf :pointer)) + +(defentrypoint %sys-uname () + "Get name and information about current kernel." + (with-foreign-object (buf 'utsname) + (%sys-bzero buf size-of-utsname) + (%%sys-uname buf) + (macrolet ((utsname-slot (name) + `(foreign-string-to-lisp + (foreign-slot-pointer buf 'utsname ',name)))) + (values (utsname-slot sysname) + (utsname-slot nodename) + (utsname-slot release) + (utsname-slot version) + (utsname-slot machine))))) ;;;------------------------------------------------------------------------- diff --git a/syscalls/ffi-types-unix.lisp b/syscalls/ffi-types-unix.lisp index 32a9795..a623b71 100644 --- a/syscalls/ffi-types-unix.lisp +++ b/syscalls/ffi-types-unix.lisp @@ -17,7 +17,7 @@ (include "stdlib.h" "errno.h" "sys/types.h" "sys/stat.h" "sys/mman.h" "fcntl.h" "signal.h" "unistd.h" "limits.h" "time.h" "sys/select.h" "sys/poll.h" "sys/ioctl.h" "sys/resource.h" "pwd.h" "grp.h" - "dirent.h") + "dirent.h" "sys/utsname.h") (in-package :iolib.syscalls) @@ -410,6 +410,16 @@ (constant (rlimit-sbsize "RLIMIT_SBSIZE")) +;;;; from sys/utsname.h + +(cstruct utsname "struct utsname" + (sysname "sysname" :type :char) + (nodename "nodename" :type :char) + (release "release" :type :char) + (version "version" :type :char) + (machine "machine" :type :char)) + + ;;; from pwd.h (cstruct passwd-entry "struct passwd" diff --git a/syscalls/pkgdcl.lisp b/syscalls/pkgdcl.lisp index 7dff8b7..f776b35 100644 --- a/syscalls/pkgdcl.lisp +++ b/syscalls/pkgdcl.lisp @@ -175,6 +175,7 @@ ;; Local info #:%sys-gethostname #:%sys-getdomainname + #:%sys-uname ;; User info #:%sys-getpwnam -- 2.11.4.GIT