2008-12-01 15:04:55 -05:00
|
|
|
! Copyright (C) 2008 Doug Coleman.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-12-01 21:30:52 -05:00
|
|
|
USING: accessors alien.c-types alien.syntax combinators
|
2008-12-15 03:18:59 -05:00
|
|
|
io.backend io.files io.files.info io.files.unix kernel math system unix
|
2008-12-02 21:16:53 -05:00
|
|
|
unix.statfs.freebsd unix.statvfs.freebsd unix.getfsstat.freebsd
|
2008-12-10 15:28:22 -05:00
|
|
|
sequences grouping alien.strings io.encodings.utf8
|
2008-12-14 21:03:00 -05:00
|
|
|
specialized-arrays.direct.uint arrays io.files.info.unix ;
|
|
|
|
IN: io.files.info.unix.freebsd
|
2008-12-01 15:04:55 -05:00
|
|
|
|
2008-12-02 21:16:53 -05:00
|
|
|
TUPLE: freebsd-file-system-info < unix-file-system-info
|
|
|
|
version io-size owner syncreads syncwrites asyncreads asyncwrites ;
|
|
|
|
|
|
|
|
M: freebsd new-file-system-info freebsd-file-system-info new ;
|
|
|
|
|
|
|
|
M: freebsd file-system-statfs ( path -- byte-array )
|
|
|
|
"statfs" <c-object> tuck statfs io-error ;
|
|
|
|
|
|
|
|
M: freebsd statfs>file-system-info ( file-system-info statvfs -- file-system-info )
|
|
|
|
{
|
|
|
|
[ statfs-f_version >>version ]
|
|
|
|
[ statfs-f_type >>type ]
|
|
|
|
[ statfs-f_flags >>flags ]
|
|
|
|
[ statfs-f_bsize >>block-size ]
|
|
|
|
[ statfs-f_iosize >>io-size ]
|
|
|
|
[ statfs-f_blocks >>blocks ]
|
|
|
|
[ statfs-f_bfree >>blocks-free ]
|
|
|
|
[ statfs-f_bavail >>blocks-available ]
|
|
|
|
[ statfs-f_files >>files ]
|
|
|
|
[ statfs-f_ffree >>files-free ]
|
|
|
|
[ statfs-f_syncwrites >>syncwrites ]
|
|
|
|
[ statfs-f_asyncwrites >>asyncwrites ]
|
|
|
|
[ statfs-f_syncreads >>syncreads ]
|
|
|
|
[ statfs-f_asyncreads >>asyncreads ]
|
|
|
|
[ statfs-f_namemax >>name-max ]
|
|
|
|
[ statfs-f_owner >>owner ]
|
2008-12-10 15:28:22 -05:00
|
|
|
[ statfs-f_fsid 2 <direct-uint-array> >array >>id ]
|
2008-12-02 21:16:53 -05:00
|
|
|
[ statfs-f_fstypename utf8 alien>string >>type ]
|
|
|
|
[ statfs-f_mntfromname utf8 alien>string >>device-name ]
|
|
|
|
[ statfs-f_mntonname utf8 alien>string >>mount-point ]
|
|
|
|
} cleave ;
|
|
|
|
|
2008-12-01 15:04:55 -05:00
|
|
|
M: freebsd file-system-statvfs ( path -- byte-array )
|
|
|
|
"statvfs" <c-object> tuck statvfs io-error ;
|
|
|
|
|
|
|
|
M: freebsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info )
|
|
|
|
{
|
|
|
|
[ statvfs-f_favail >>files-available ]
|
|
|
|
[ statvfs-f_frsize >>preferred-block-size ]
|
|
|
|
} cleave ;
|
2008-12-02 21:16:53 -05:00
|
|
|
|
|
|
|
M: freebsd file-systems ( -- array )
|
|
|
|
f 0 0 getfsstat dup io-error
|
|
|
|
"statfs" <c-array> dup dup length 0 getfsstat io-error
|
|
|
|
"statfs" heap-size group
|
|
|
|
[ statfs-f_mntonname alien>native-string file-system-info ] map ;
|