more ffi work

Doug Coleman 2008-10-21 01:17:49 -05:00
parent 34fa12a737
commit b9d23a2ce7
5 changed files with 41 additions and 35 deletions

View File

@ -1,6 +1,7 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax kernel ;
USING: alien.syntax kernel unix io.files math accessors
combinators system io.backend alien.c-types ;
IN: unix.statfs.freebsd
: ST_RDONLY 1 ; inline
@ -19,6 +20,7 @@ C-STRUCT: statvfs
{ "ulong" "f_fsid" }
{ "ulong" "f_namemax" } ;
FUNCTION: int statvfs ( char* path, statvfs* buf ) ;
TUPLE: freebsd-file-system-info < file-system-info
bavail bfree blocks favail ffree ffiles
@ -28,20 +30,20 @@ bsize flag frsize fsid namemax ;
[ \ freebsd-file-system-info new ] dip
{
[
[ statfs64-f_bsize ]
[ statfs64-f_bavail ] bi * >>free-space
[ statvfs-f_bsize ]
[ statvfs-f_bavail ] bi * >>free-space
]
[ statfs64-f_bavail >>bavail ]
[ statfs64-f_bfree >>bfree ]
[ statfs64-f_blocks >>blocks ]
[ statfs64-f_favail >>favail ]
[ statfs64-f_ffree >>ffree ]
[ statfs64-f_files >>files ]
[ statfs64-f_bsize >>bsize ]
[ statfs64-f_flag >>flag ]
[ statfs64-f_frsize >>frsize ]
[ statfs64-f_fsid >>fsid ]
[ statfs64-f_namelen >>namelen ]
[ statvfs-f_bavail >>bavail ]
[ statvfs-f_bfree >>bfree ]
[ statvfs-f_blocks >>blocks ]
[ statvfs-f_favail >>favail ]
[ statvfs-f_ffree >>ffree ]
[ statvfs-f_files >>files ]
[ statvfs-f_bsize >>bsize ]
[ statvfs-f_flag >>flag ]
[ statvfs-f_frsize >>frsize ]
[ statvfs-f_fsid >>fsid ]
[ statvfs-f_namemax >>namemax ]
} cleave ;
M: freebsd file-system-info ( path -- byte-array )

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax kernel io.files unix.stat math unix
combinators system io.backend accessors alien.c-types
io.encodings.utf8 alien.strings ;
io.encodings.utf8 alien.strings unix.types ;
IN: unix.statfs.netbsd
: _VFS_NAMELEN 32 ; inline
@ -34,6 +34,8 @@ C-STRUCT: statvfs
{ { "char" _VFS_NAMELEN } "f_mntonname" }
{ { "char" _VFS_NAMELEN } "f_mntfromname" } ;
FUNCTION: int statvfs ( char* path, statvfs *buf ) ;
TUPLE: netbsd-file-system-info < file-system-info
flag bsize frsize io-size
blocks blocks-free blocks-available blocks-reserved

View File

@ -1,6 +1,7 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax accessors combinators kernel io.files ;
USING: alien.syntax accessors combinators kernel io.files
unix.types math system io.backend alien.c-types unix ;
IN: unix.statfs.openbsd
C-STRUCT: statvfs
@ -19,6 +20,8 @@ C-STRUCT: statvfs
: ST_RDONLY 1 ; inline
: ST_NOSUID 2 ; inline
FUNCTION: int statvfs ( char* path, statvfs* buf ) ;
TUPLE: openbsd-file-system-info < file-system-info
bsize frsize blocks bfree bavail files ffree favail
fsid flag namemax ;
@ -27,20 +30,20 @@ fsid flag namemax ;
[ \ openbsd-file-system-info new ] dip
{
[
[ statfs64-f_bsize ]
[ statfs64-f_bavail ] bi * >>free-space
[ statvfs-f_bsize ]
[ statvfs-f_bavail ] bi * >>free-space
]
[ statfs64-f_bsize >>bsize ]
[ statfs64-f_frsize >>frsize ]
[ statfs64-f_blocks >>blocks ]
[ statfs64-f_bfree >>bfree ]
[ statfs64-f_bavail >>bavail ]
[ statfs64-f_files >>files ]
[ statfs64-f_ffree >>ffree ]
[ statfs64-f_favail >>favail ]
[ statfs64-f_fsid >>fsid ]
[ statfs64-f_flag >>flag ]
[ statfs64-f_namelen >>namelen ]
[ statvfs-f_bsize >>bsize ]
[ statvfs-f_frsize >>frsize ]
[ statvfs-f_blocks >>blocks ]
[ statvfs-f_bfree >>bfree ]
[ statvfs-f_bavail >>bavail ]
[ statvfs-f_files >>files ]
[ statvfs-f_ffree >>ffree ]
[ statvfs-f_favail >>favail ]
[ statvfs-f_fsid >>fsid ]
[ statvfs-f_flag >>flag ]
[ statvfs-f_namemax >>namemax ]
} cleave ;
M: openbsd file-system-info ( path -- byte-array )

View File

@ -17,12 +17,6 @@ TYPEDEF: long ssize_t
TYPEDEF: int pid_t
TYPEDEF: int time_t
TYPEDEF: __uint64_t fsblkcnt_t
TYPEDEF: fsblkcnt_t __fsblkcnt_t
TYPEDEF: __uint64_t fsfilcnt_t
TYPEDEF: fsfilcnt_t __fsfilcnt_t
cell-bits {
{ 32 [ "unix.types.netbsd.32" require ] }
{ 64 [ "unix.types.netbsd.64" require ] }

View File

@ -6,6 +6,11 @@ TYPEDEF: void* caddr_t
TYPEDEF: uint in_addr_t
TYPEDEF: uint socklen_t
TYPEDEF: __uint64_t fsblkcnt_t
TYPEDEF: fsblkcnt_t __fsblkcnt_t
TYPEDEF: __uint64_t fsfilcnt_t
TYPEDEF: fsfilcnt_t __fsfilcnt_t
TYPEDEF: char int8_t
TYPEDEF: short int16_t
TYPEDEF: int int32_t