fix file-systems on freebsd

db4
Doug Coleman 2008-12-02 20:16:53 -06:00
parent 2b23e3c4d8
commit 89a0286c3b
5 changed files with 83 additions and 10 deletions

View File

@ -2,23 +2,53 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.syntax combinators USING: accessors alien.c-types alien.syntax combinators
io.backend io.files io.unix.files kernel math system unix io.backend io.files io.unix.files kernel math system unix
unix.statvfs.freebsd ; unix.statfs.freebsd unix.statvfs.freebsd unix.getfsstat.freebsd
sequences grouping alien.strings io.encodings.utf8 ;
IN: io.unix.files.freebsd IN: io.unix.files.freebsd
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 ]
[ statfs-f_fsid >>id ]
[ statfs-f_fstypename utf8 alien>string >>type ]
[ statfs-f_mntfromname utf8 alien>string >>device-name ]
[ statfs-f_mntonname utf8 alien>string >>mount-point ]
} cleave ;
M: freebsd file-system-statvfs ( path -- byte-array ) M: freebsd file-system-statvfs ( path -- byte-array )
"statvfs" <c-object> tuck statvfs io-error ; "statvfs" <c-object> tuck statvfs io-error ;
M: freebsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info ) M: freebsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info )
{ {
[ statvfs-f_bavail >>blocks-available ]
[ statvfs-f_bfree >>blocks-free ]
[ statvfs-f_blocks >>blocks ]
[ statvfs-f_favail >>files-available ] [ statvfs-f_favail >>files-available ]
[ statvfs-f_ffree >>files-free ]
[ statvfs-f_files >>files ]
[ statvfs-f_bsize >>block-size ]
[ statvfs-f_flag >>flags ]
[ statvfs-f_frsize >>preferred-block-size ] [ statvfs-f_frsize >>preferred-block-size ]
[ statvfs-f_fsid >>id ]
[ statvfs-f_namemax >>name-max ]
} cleave ; } cleave ;
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 ;

View File

@ -0,0 +1 @@
Doug Coleman

View File

@ -0,0 +1,11 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax ;
IN: unix.getfsstat.freebsd
: MNT_WAIT 1 ; inline ! synchronously wait for I/O to complete
: MNT_NOWAIT 2 ; inline ! start all I/O, but do not wait for it
: MNT_LAZY 3 ; inline ! push data not written by filesystem syncer
: MNT_SUSPEND 4 ; inline ! Suspend file system after sync
FUNCTION: int getfsstat ( statfs* buf, int bufsize, int flags ) ;

View File

@ -0,0 +1 @@
unportable

View File

@ -2,3 +2,33 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax ; USING: alien.syntax ;
IN: unix.statfs.freebsd IN: unix.statfs.freebsd
: MFSNAMELEN 16 ; inline ! length of type name including null */
: MNAMELEN 88 ; inline ! size of on/from name bufs
: STATFS_VERSION HEX: 20030518 ; inline ! current version number
C-STRUCT: statfs
{ "uint32_t" "f_version" }
{ "uint32_t" "f_type" }
{ "uint64_t" "f_flags" }
{ "uint64_t" "f_bsize" }
{ "uint64_t" "f_iosize" }
{ "uint64_t" "f_blocks" }
{ "uint64_t" "f_bfree" }
{ "int64_t" "f_bavail" }
{ "uint64_t" "f_files" }
{ "int64_t" "f_ffree" }
{ "uint64_t" "f_syncwrites" }
{ "uint64_t" "f_asyncwrites" }
{ "uint64_t" "f_syncreads" }
{ "uint64_t" "f_asyncreads" }
{ { "uint64_t" 10 } "f_spare" }
{ "uint32_t" "f_namemax" }
{ "uid_t" "f_owner" }
{ "fsid_t" "f_fsid" }
{ { "char" 80 } "f_charspare" }
{ { "char" MFSNAMELEN } "f_fstypename" }
{ { "char" MNAMELEN } "f_mntfromname" }
{ { "char" MNAMELEN } "f_mntonname" } ;
FUNCTION: int statfs ( char* path, statvfs* buf ) ;