2008-10-21 01:52:04 -04:00
|
|
|
! 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 ;
|
2008-10-21 01:52:04 -04:00
|
|
|
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
|
|
|
|
2008-10-21 04:16:48 -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 )
|
2008-10-21 04:16:48 -04:00
|
|
|
[ \ 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 ;
|