Merge branch 'master' of git://factorcode.org/git/factor

db4
Slava Pestov 2008-12-02 19:43:11 -06:00
commit 2b23e3c4d8
16 changed files with 56 additions and 37 deletions

View File

@ -2,7 +2,7 @@
! 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.statfs unix.statvfs.freebsd ; unix.statvfs.freebsd ;
IN: io.unix.files.freebsd IN: io.unix.files.freebsd
M: freebsd file-system-statvfs ( path -- byte-array ) M: freebsd file-system-statvfs ( path -- byte-array )

View File

@ -2,17 +2,18 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.strings combinators USING: accessors alien.c-types alien.strings combinators
grouping io.encodings.utf8 io.files kernel math sequences grouping io.encodings.utf8 io.files kernel math sequences
system unix unix.statfs.macosx io.unix.files unix.statvfs.macosx ; system unix io.unix.files
unix.statfs.macosx unix.statvfs.macosx unix.getfsstat.macosx ;
IN: io.unix.files.macosx IN: io.unix.files.macosx
TUPLE: macosx-file-system-info < unix-file-system-info TUPLE: macosx-file-system-info < unix-file-system-info
io-size owner type-id filesystem-subtype ; io-size owner type-id filesystem-subtype ;
M: macosx file-systems ( -- array ) M: macosx file-systems ( -- array )
f <void*> dup 0 getmntinfo64 dup io-error f 0 0 getfsstat64 dup io-error
[ *void* ] dip "statfs" <c-array> dup dup length 0 getfsstat64 io-error
"statfs64" heap-size [ * memory>byte-array ] keep group "statfs" heap-size group
[ [ new-file-system-info ] dip statfs>file-system-info ] map ; [ statfs64-f_mntonname alien>native-string file-system-info ] map ;
M: macosx new-file-system-info macosx-file-system-info new ; M: macosx new-file-system-info macosx-file-system-info new ;
@ -47,4 +48,3 @@ M: macosx statvfs>file-system-info ( file-system-info byte-array -- file-system-
[ statvfs-f_favail >>files-available ] [ statvfs-f_favail >>files-available ]
[ statvfs-f_namemax >>name-max ] [ statvfs-f_namemax >>name-max ]
} cleave ; } cleave ;

View File

@ -2,8 +2,8 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax kernel unix.stat math unix USING: alien.syntax kernel unix.stat math unix
combinators system io.backend accessors alien.c-types combinators system io.backend accessors alien.c-types
io.encodings.utf8 alien.strings unix.types unix.statfs io.encodings.utf8 alien.strings unix.types io.unix.files
io.unix.files io.files unix.statvfs.netbsd ; io.files unix.statvfs.netbsd ;
IN: io.unix.files.netbsd IN: io.unix.files.netbsd
TUPLE: netbsd-file-system-info < unix-file-system-info TUPLE: netbsd-file-system-info < unix-file-system-info

View File

@ -1,16 +1,23 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax accessors combinators kernel USING: accessors alien.c-types alien.strings alien.syntax
unix.types math system io.backend alien.c-types unix combinators io.backend io.files io.unix.files kernel math
io.files io.unix.files unix.statvfs.openbsd ; sequences system unix unix.getfsstat.openbsd grouping
unix.statfs.openbsd unix.statvfs.openbsd unix.types ;
IN: io.unix.files.openbsd IN: io.unix.files.openbsd
TUPLE: freebsd-file-system-info < unix-file-system-info
io-size sync-writes sync-reads async-writes async-reads
owner ;
M: openbsd new-file-system-info freebsd-file-system-info new ;
M: openbsd file-system-statfs M: openbsd file-system-statfs
"statfs" <c-object> tuck statfs io-error ; "statfs" <c-object> tuck statfs io-error ;
M: openbsd statfs>file-system-info ( file-system-info statfs -- file-system-info' ) M: openbsd statfs>file-system-info ( file-system-info statfs -- file-system-info' )
{ {
[ statfs-f_flag >>flags ] [ statfs-f_flags >>flags ]
[ statfs-f_bsize >>block-size ] [ statfs-f_bsize >>block-size ]
[ statfs-f_iosize >>io-size ] [ statfs-f_iosize >>io-size ]
[ statfs-f_blocks >>blocks ] [ statfs-f_blocks >>blocks ]
@ -26,7 +33,7 @@ M: openbsd statfs>file-system-info ( file-system-info statfs -- file-system-info
[ statfs-f_fsid >>id ] [ statfs-f_fsid >>id ]
[ statfs-f_namemax >>name-max ] [ statfs-f_namemax >>name-max ]
[ statfs-f_owner >>owner ] [ statfs-f_owner >>owner ]
[ statfs-f_spare >>spare ] ! [ statfs-f_spare >>spare ]
[ statfs-f_fstypename alien>native-string >>type ] [ statfs-f_fstypename alien>native-string >>type ]
[ statfs-f_mntonname alien>native-string >>mount-point ] [ statfs-f_mntonname alien>native-string >>mount-point ]
[ statfs-f_mntfromname alien>native-string >>device-name ] [ statfs-f_mntfromname alien>native-string >>device-name ]
@ -39,3 +46,9 @@ M: openbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-in
{ {
[ statvfs-f_frsize >>preferred-block-size ] [ statvfs-f_frsize >>preferred-block-size ]
} cleave ; } cleave ;
M: openbsd file-systems ( -- seq )
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,9 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax ;
IN: unix.getfsstat.macosx
: 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
FUNCTION: int getfsstat64 ( statfs* buf, int bufsize, int flags ) ;

View File

@ -0,0 +1 @@
Doug Coleman

View File

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

View File

@ -0,0 +1 @@
unportable

View File

@ -1 +0,0 @@
Doug Coleman

View File

@ -2,8 +2,8 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types io.encodings.utf8 io.encodings.string USING: alien.c-types io.encodings.utf8 io.encodings.string
kernel sequences unix.stat accessors unix combinators math kernel sequences unix.stat accessors unix combinators math
grouping system unix.statfs io.files io.backend alien.strings grouping system io.files io.backend alien.strings math.bitwise
math.bitwise alien.syntax io.unix.files ; alien.syntax io.unix.files ;
IN: unix.statfs.macosx IN: unix.statfs.macosx
: MNT_RDONLY HEX: 00000001 ; inline : MNT_RDONLY HEX: 00000001 ; inline
@ -115,4 +115,3 @@ C-STRUCT: statfs64
{ { "uint32_t" 8 } "f_reserved" } ; { { "uint32_t" 8 } "f_reserved" } ;
FUNCTION: int statfs64 ( char* path, statfs64* buf ) ; FUNCTION: int statfs64 ( char* path, statfs64* buf ) ;
FUNCTION: int getmntinfo64 ( statfs64** mntbufp, int flags ) ;

View File

@ -27,7 +27,7 @@ C-STRUCT: statfs
{ { "u_int32_t" 3 } "f_spare" } { { "u_int32_t" 3 } "f_spare" }
{ { "char" MFSNAMELEN } "f_fstypename" } { { "char" MFSNAMELEN } "f_fstypename" }
{ { "char" MNAMELEN } "f_mntonname" } { { "char" MNAMELEN } "f_mntonname" }
{ { "char" MNAMELEN } "f_mntfromname" } ; { { "char" MNAMELEN } "f_mntfromname" }
! { "mount_info" "mount_info" } ; { { "char" 160 } "mount_info" } ;
FUNCTION: int statfs ( char* path, statvfs* buf ) ; FUNCTION: int statfs ( char* path, statvfs* buf ) ;

View File

@ -1,4 +0,0 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: tools.test unix.statfs ;
IN: unix.statfs.tests

View File

@ -1,13 +0,0 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: sequences system vocabs.loader combinators accessors
kernel math.order sorting ;
IN: unix.statfs
os {
{ linux [ "unix.statfs.linux" require ] }
{ macosx [ "unix.statfs.macosx" require ] }
{ freebsd [ "unix.statfs.freebsd" require ] }
{ openbsd [ "unix.statfs.openbsd" require ] }
{ netbsd [ ] }
} case

View File

@ -283,3 +283,6 @@ USE: debugger.threads
[ "resource:core/bootstrap/stage2.factor" (normalize-path) ] [ "resource:core/bootstrap/stage2.factor" (normalize-path) ]
unit-test unit-test
] with-scope ] with-scope
[ t ] [ "/" file-system-info file-system-info? ] unit-test
[ t ] [ file-systems [ file-system-info? ] all? ] unit-test