diff --git a/basis/io/unix/files/freebsd/freebsd.factor b/basis/io/unix/files/freebsd/freebsd.factor index 16ef9f61d2..2c8f4bb438 100644 --- a/basis/io/unix/files/freebsd/freebsd.factor +++ b/basis/io/unix/files/freebsd/freebsd.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.syntax combinators io.backend io.files io.unix.files kernel math system unix -unix.statfs unix.statvfs.freebsd ; +unix.statvfs.freebsd ; IN: io.unix.files.freebsd M: freebsd file-system-statvfs ( path -- byte-array ) diff --git a/basis/io/unix/files/macosx/macosx.factor b/basis/io/unix/files/macosx/macosx.factor index c5d12a012e..8a1eb9c89b 100644 --- a/basis/io/unix/files/macosx/macosx.factor +++ b/basis/io/unix/files/macosx/macosx.factor @@ -2,17 +2,18 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.strings combinators 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 TUPLE: macosx-file-system-info < unix-file-system-info io-size owner type-id filesystem-subtype ; M: macosx file-systems ( -- array ) - f dup 0 getmntinfo64 dup io-error - [ *void* ] dip - "statfs64" heap-size [ * memory>byte-array ] keep group - [ [ new-file-system-info ] dip statfs>file-system-info ] map ; + f 0 0 getfsstat64 dup io-error + "statfs" dup dup length 0 getfsstat64 io-error + "statfs" heap-size group + [ statfs64-f_mntonname alien>native-string file-system-info ] map ; 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_namemax >>name-max ] } cleave ; - diff --git a/basis/io/unix/files/netbsd/netbsd.factor b/basis/io/unix/files/netbsd/netbsd.factor index 1bd8ba4f67..7140847f9a 100644 --- a/basis/io/unix/files/netbsd/netbsd.factor +++ b/basis/io/unix/files/netbsd/netbsd.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien.syntax kernel unix.stat math unix combinators system io.backend accessors alien.c-types -io.encodings.utf8 alien.strings unix.types unix.statfs -io.unix.files io.files unix.statvfs.netbsd ; +io.encodings.utf8 alien.strings unix.types io.unix.files +io.files unix.statvfs.netbsd ; IN: io.unix.files.netbsd TUPLE: netbsd-file-system-info < unix-file-system-info diff --git a/basis/io/unix/files/openbsd/openbsd.factor b/basis/io/unix/files/openbsd/openbsd.factor index 463cbde675..8c8f7c154b 100644 --- a/basis/io/unix/files/openbsd/openbsd.factor +++ b/basis/io/unix/files/openbsd/openbsd.factor @@ -1,16 +1,23 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax accessors combinators kernel -unix.types math system io.backend alien.c-types unix -io.files io.unix.files unix.statvfs.openbsd ; +USING: accessors alien.c-types alien.strings alien.syntax +combinators io.backend io.files io.unix.files kernel math +sequences system unix unix.getfsstat.openbsd grouping +unix.statfs.openbsd unix.statvfs.openbsd unix.types ; 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 "statfs" tuck statfs io-error ; 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_iosize >>io-size ] [ 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_namemax >>name-max ] [ statfs-f_owner >>owner ] - [ statfs-f_spare >>spare ] + ! [ statfs-f_spare >>spare ] [ statfs-f_fstypename alien>native-string >>type ] [ statfs-f_mntonname alien>native-string >>mount-point ] [ 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 ] } cleave ; + +M: openbsd file-systems ( -- seq ) + f 0 0 getfsstat dup io-error + "statfs" dup dup length 0 getfsstat io-error + "statfs" heap-size group + [ statfs-f_mntonname alien>native-string file-system-info ] map ; diff --git a/basis/unix/getfsstat/macosx/authors.txt b/basis/unix/getfsstat/macosx/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/basis/unix/getfsstat/macosx/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/basis/unix/getfsstat/macosx/macosx.factor b/basis/unix/getfsstat/macosx/macosx.factor new file mode 100644 index 0000000000..fe39f8556b --- /dev/null +++ b/basis/unix/getfsstat/macosx/macosx.factor @@ -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 ) ; diff --git a/basis/unix/statfs/tags.txt b/basis/unix/getfsstat/macosx/tags.txt similarity index 100% rename from basis/unix/statfs/tags.txt rename to basis/unix/getfsstat/macosx/tags.txt diff --git a/basis/unix/getfsstat/openbsd/authors.txt b/basis/unix/getfsstat/openbsd/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/basis/unix/getfsstat/openbsd/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/basis/unix/getfsstat/openbsd/openbsd.factor b/basis/unix/getfsstat/openbsd/openbsd.factor new file mode 100644 index 0000000000..8bf692bd9c --- /dev/null +++ b/basis/unix/getfsstat/openbsd/openbsd.factor @@ -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 ) ; diff --git a/basis/unix/getfsstat/openbsd/tags.txt b/basis/unix/getfsstat/openbsd/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/unix/getfsstat/openbsd/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/unix/statfs/authors.txt b/basis/unix/statfs/authors.txt deleted file mode 100644 index b4bd0e7b35..0000000000 --- a/basis/unix/statfs/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Doug Coleman \ No newline at end of file diff --git a/basis/unix/statfs/macosx/macosx.factor b/basis/unix/statfs/macosx/macosx.factor index fcdbb1ee87..1faadb2627 100644 --- a/basis/unix/statfs/macosx/macosx.factor +++ b/basis/unix/statfs/macosx/macosx.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien.c-types io.encodings.utf8 io.encodings.string kernel sequences unix.stat accessors unix combinators math -grouping system unix.statfs io.files io.backend alien.strings -math.bitwise alien.syntax io.unix.files ; +grouping system io.files io.backend alien.strings math.bitwise +alien.syntax io.unix.files ; IN: unix.statfs.macosx : MNT_RDONLY HEX: 00000001 ; inline @@ -115,4 +115,3 @@ C-STRUCT: statfs64 { { "uint32_t" 8 } "f_reserved" } ; FUNCTION: int statfs64 ( char* path, statfs64* buf ) ; -FUNCTION: int getmntinfo64 ( statfs64** mntbufp, int flags ) ; diff --git a/basis/unix/statfs/openbsd/openbsd.factor b/basis/unix/statfs/openbsd/openbsd.factor index 98bf140af7..378e335c11 100644 --- a/basis/unix/statfs/openbsd/openbsd.factor +++ b/basis/unix/statfs/openbsd/openbsd.factor @@ -27,7 +27,7 @@ C-STRUCT: statfs { { "u_int32_t" 3 } "f_spare" } { { "char" MFSNAMELEN } "f_fstypename" } { { "char" MNAMELEN } "f_mntonname" } - { { "char" MNAMELEN } "f_mntfromname" } ; - ! { "mount_info" "mount_info" } ; + { { "char" MNAMELEN } "f_mntfromname" } + { { "char" 160 } "mount_info" } ; FUNCTION: int statfs ( char* path, statvfs* buf ) ; diff --git a/basis/unix/statfs/statfs-tests.factor b/basis/unix/statfs/statfs-tests.factor deleted file mode 100644 index 39bc77fc87..0000000000 --- a/basis/unix/statfs/statfs-tests.factor +++ /dev/null @@ -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 diff --git a/basis/unix/statfs/statfs.factor b/basis/unix/statfs/statfs.factor deleted file mode 100644 index 7d1bebc72d..0000000000 --- a/basis/unix/statfs/statfs.factor +++ /dev/null @@ -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 diff --git a/core/io/files/files-tests.factor b/core/io/files/files-tests.factor index 3104fcdb55..4299634642 100644 --- a/core/io/files/files-tests.factor +++ b/core/io/files/files-tests.factor @@ -283,3 +283,6 @@ USE: debugger.threads [ "resource:core/bootstrap/stage2.factor" (normalize-path) ] unit-test ] with-scope + +[ t ] [ "/" file-system-info file-system-info? ] unit-test +[ t ] [ file-systems [ file-system-info? ] all? ] unit-test