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

40 lines
1.2 KiB
Factor
Raw Normal View History

2008-10-20 01:47:51 -04:00
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
2008-10-20 02:55:40 -04:00
USING: alien.c-types combinators kernel io.files unix.stat
2008-10-21 00:43:36 -04:00
math accessors system unix io.backend layouts vocabs.loader ;
2008-10-20 01:47:51 -04:00
IN: unix.statfs.linux
2008-10-21 00:43:36 -04:00
<< cell-bits {
{ 32 [ "unix.statfs.linux.32" require ] }
{ 64 [ "unix.statfs.linux.64" require ] }
} case >>
2008-10-20 01:47:51 -04:00
TUPLE: linux-file-system-info < file-system-info
type bsize blocks bfree bavail files ffree fsid
namelen frsize spare ;
2008-10-20 02:55:40 -04:00
: statfs>file-system-info ( struct -- statfs )
[ \ linux-file-system-info new ] dip
2008-10-20 01:47:51 -04:00
{
2008-10-20 02:55:40 -04:00
[
[ statfs64-f_bsize ]
[ statfs64-f_bavail ] bi * >>free-space
]
2008-10-20 01:47:51 -04:00
[ statfs64-f_type >>type ]
[ statfs64-f_bsize >>bsize ]
[ statfs64-f_blocks >>blocks ]
[ statfs64-f_bfree >>bfree ]
[ statfs64-f_bavail >>bavail ]
[ statfs64-f_files >>files ]
[ statfs64-f_ffree >>ffree ]
[ statfs64-f_fsid >>fsid ]
[ statfs64-f_namelen >>namelen ]
[ statfs64-f_frsize >>frsize ]
[ statfs64-f_spare >>spare ]
} cleave ;
2008-10-20 02:55:40 -04:00
M: linux file-system-info ( path -- byte-array )
normalize-path
"statfs64" <c-object> tuck statfs64 io-error
statfs>file-system-info ;