diff --git a/basis/unix/statfs/freebsd/freebsd.factor b/basis/unix/statfs/freebsd/freebsd.factor index f47f71f523..508047ccc5 100644 --- a/basis/unix/statfs/freebsd/freebsd.factor +++ b/basis/unix/statfs/freebsd/freebsd.factor @@ -18,3 +18,33 @@ C-STRUCT: statvfs { "ulong" "f_frsize" } { "ulong" "f_fsid" } { "ulong" "f_namemax" } ; + + +TUPLE: freebsd-file-system-info < file-system-info +bavail bfree blocks favail ffree ffiles +bsize flag frsize fsid namemax ; + +: statfs>file-system-info ( struct -- statfs ) + [ \ freebsd-file-system-info new ] dip + { + [ + [ statfs64-f_bsize ] + [ statfs64-f_bavail ] bi * >>free-space + ] + [ statfs64-f_bavail >>bavail ] + [ statfs64-f_bfree >>bfree ] + [ statfs64-f_blocks >>blocks ] + [ statfs64-f_favail >>favail ] + [ statfs64-f_ffree >>ffree ] + [ statfs64-f_files >>files ] + [ statfs64-f_bsize >>bsize ] + [ statfs64-f_flag >>flag ] + [ statfs64-f_frsize >>frsize ] + [ statfs64-f_fsid >>fsid ] + [ statfs64-f_namelen >>namelen ] + } cleave ; + +M: freebsd file-system-info ( path -- byte-array ) + normalize-path + "statvfs" tuck statvfs io-error + statfs>file-system-info ; diff --git a/basis/unix/statfs/linux/32/32.factor b/basis/unix/statfs/linux/32/32.factor new file mode 100644 index 0000000000..86fb61e83d --- /dev/null +++ b/basis/unix/statfs/linux/32/32.factor @@ -0,0 +1,15 @@ +! Copyright (C) 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: alien.syntax unix.types ; +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" } ; diff --git a/basis/unix/statfs/linux/32/authors.txt b/basis/unix/statfs/linux/32/authors.txt new file mode 100644 index 0000000000..b4bd0e7b35 --- /dev/null +++ b/basis/unix/statfs/linux/32/authors.txt @@ -0,0 +1 @@ +Doug Coleman \ No newline at end of file diff --git a/basis/unix/statfs/linux/32/tags.txt b/basis/unix/statfs/linux/32/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/unix/statfs/linux/32/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/unix/statfs/linux/64/64.factor b/basis/unix/statfs/linux/64/64.factor new file mode 100644 index 0000000000..20688680fb --- /dev/null +++ b/basis/unix/statfs/linux/64/64.factor @@ -0,0 +1,19 @@ +! Copyright (C) 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: alien.syntax unix.types ; +IN: unix.statfs.linux + +C-STRUCT: statfs64 + { "__SWORD_TYPE" "f_type" } + { "__SWORD_TYPE" "f_bsize" } + { "__fsblkcnt64_t" "f_blocks" } + { "__fsblkcnt64_t" "f_bfree" } + { "__fsblkcnt64_t" "f_bavail" } + { "__fsfilcnt64_t" "f_files" } + { "__fsfilcnt64_t" "f_ffree" } + { "__fsid_t" "f_fsid" } + { "__SWORD_TYPE" "f_namelen" } + { "__SWORD_TYPE" "f_frsize" } + { { "__SWORD_TYPE" 5 } "f_spare" } ; + +FUNCTION: int statfs64 ( char* path, statfs64* buf ) ; diff --git a/basis/unix/statfs/linux/64/authors.txt b/basis/unix/statfs/linux/64/authors.txt new file mode 100644 index 0000000000..b4bd0e7b35 --- /dev/null +++ b/basis/unix/statfs/linux/64/authors.txt @@ -0,0 +1 @@ +Doug Coleman \ No newline at end of file diff --git a/basis/unix/statfs/linux/64/tags.txt b/basis/unix/statfs/linux/64/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/unix/statfs/linux/64/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/unix/statfs/linux/linux.factor b/basis/unix/statfs/linux/linux.factor index 367d32d520..b938062e55 100644 --- a/basis/unix/statfs/linux/linux.factor +++ b/basis/unix/statfs/linux/linux.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien.c-types combinators kernel io.files unix.stat -math accessors system unix io.backend layouts vocabs.loader ; +math accessors system unix io.backend layouts vocabs.loader ; IN: unix.statfs.linux << cell-bits { diff --git a/basis/unix/statfs/openbsd/openbsd.factor b/basis/unix/statfs/openbsd/openbsd.factor index 011ccb87d1..d07d159192 100644 --- a/basis/unix/statfs/openbsd/openbsd.factor +++ b/basis/unix/statfs/openbsd/openbsd.factor @@ -1,4 +1,49 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: ; +USING: alien.syntax accessors combinators kernel io.files ; IN: unix.statfs.openbsd + +C-STRUCT: statvfs + { "ulong" "f_bsize" } + { "ulong" "f_frsize" } + { "fsblkcnt_t" "f_blocks" } + { "fsblkcnt_t" "f_bfree" } + { "fsblkcnt_t" "f_bavail" } + { "fsfilcnt_t" "f_files" } + { "fsfilcnt_t" "f_ffree" } + { "fsfilcnt_t" "f_favail" } + { "ulong" "f_fsid" } + { "ulong" "f_flag" } + { "ulong" "f_namemax" } ; + +: ST_RDONLY 1 ; inline +: ST_NOSUID 2 ; inline + +TUPLE: openbsd-file-system-info < file-system-info +bsize frsize blocks bfree bavail files ffree favail +fsid flag namemax ; + +: statfs>file-system-info ( struct -- statfs ) + [ \ openbsd-file-system-info new ] dip + { + [ + [ statfs64-f_bsize ] + [ statfs64-f_bavail ] bi * >>free-space + ] + [ statfs64-f_bsize >>bsize ] + [ statfs64-f_frsize >>frsize ] + [ statfs64-f_blocks >>blocks ] + [ statfs64-f_bfree >>bfree ] + [ statfs64-f_bavail >>bavail ] + [ statfs64-f_files >>files ] + [ statfs64-f_ffree >>ffree ] + [ statfs64-f_favail >>favail ] + [ statfs64-f_fsid >>fsid ] + [ statfs64-f_flag >>flag ] + [ statfs64-f_namelen >>namelen ] + } cleave ; + +M: openbsd file-system-info ( path -- byte-array ) + normalize-path + "statvfs" tuck statvfs io-error + statfs>file-system-info ; diff --git a/basis/unix/statfs/statfs.factor b/basis/unix/statfs/statfs.factor index 0d99b57faf..8ac5a46883 100644 --- a/basis/unix/statfs/statfs.factor +++ b/basis/unix/statfs/statfs.factor @@ -25,7 +25,7 @@ TUPLE: file-system-info root-directory total-free-size total-size ; os { { linux [ "unix.statfs.linux" require ] } { macosx [ "unix.statfs.macosx" require ] } - ! { freebsd [ "unix.statfs.freebsd" require ] } - ! { netbsd [ "unix.statfs.netbsd" require ] } - ! { openbsd [ "unix.statfs.openbsd" require ] } + { freebsd [ "unix.statfs.freebsd" require ] } + { netbsd [ "unix.statfs.netbsd" require ] } + { openbsd [ "unix.statfs.openbsd" require ] } } case