factor/basis/unix/statfs/linux/32/32.factor

47 lines
1.3 KiB
Factor
Raw Normal View History

! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
2008-10-22 20:54:22 -04:00
USING: alien.c-types combinators kernel unix.stat
2008-10-21 04:11:26 -04:00
math accessors system unix io.backend layouts vocabs.loader
2008-10-22 20:54:22 -04:00
alien.syntax unix.statfs io.files ;
IN: unix.statfs.linux
C-STRUCT: statfs
{ "long" "f_type" }
{ "long" "f_bsize" }
{ "long" "f_blocks" }
{ "long" "f_bfree" }
{ "long" "f_bavail" }
{ "long" "f_files" }
{ "long" "f_ffree" }
{ "fsid_t" "f_fsid" }
{ "long" "f_namelen" } ;
2008-10-21 04:11:26 -04:00
2008-10-21 04:21:17 -04:00
FUNCTION: int statfs ( char* path, statfs* buf ) ;
2008-10-21 04:11:26 -04:00
TUPLE: linux32-file-system-info < file-system-info
2008-10-21 04:11:26 -04:00
type bsize blocks bfree bavail files ffree fsid
namelen frsize spare ;
M: linux >file-system-info ( struct -- statfs )
[ \ linux32-file-system-info new ] dip
2008-10-21 04:11:26 -04:00
{
[
2008-10-21 04:21:17 -04:00
[ statfs-f_bsize ]
[ statfs-f_bavail ] bi * >>free-space
2008-10-21 04:11:26 -04:00
]
[ statfs-f_type >>type ]
[ statfs-f_bsize >>bsize ]
[ statfs-f_blocks >>blocks ]
[ statfs-f_bfree >>bfree ]
[ statfs-f_bavail >>bavail ]
[ statfs-f_files >>files ]
[ statfs-f_ffree >>ffree ]
[ statfs-f_fsid >>fsid ]
[ statfs-f_namelen >>namelen ]
} cleave ;
M: linux file-system-info ( path -- byte-array )
normalize-path
"statfs" <c-object> tuck statfs io-error
>file-system-info ;