]> gitweb.factorcode.org Git - factor.git/blob - extra/system-info/linux/linux.factor
Merge branch 'master' into experimental
[factor.git] / extra / system-info / linux / linux.factor
1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: unix alien alien.c-types kernel math sequences strings
4 io.backend.unix splitting ;
5 IN: system-info.linux
6
7 : (uname) ( buf -- int )
8     "int" f "uname" { "char*" } alien-invoke ;
9
10 : uname ( -- seq )
11     65536 "char" <c-array> [ (uname) io-error ] keep
12     "\0" split harvest [ >string ] map
13     6 "" pad-right ;
14
15 : sysname ( -- string ) uname first ;
16 : nodename ( -- string ) uname second ;
17 : release ( -- string ) uname third ;
18 : version ( -- string ) uname fourth ;
19 : machine ( -- string ) uname 4 swap nth ;
20 : domainname ( -- string ) uname 5 swap nth ;
21
22 : kernel-version ( -- seq )
23     release ".-" split harvest 5 "" pad-right ;