From da3936a162b7f99a51799ed3ec5ef516fcb342a4 Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Sun, 30 Nov 2008 17:32:55 -0600
Subject: [PATCH 1/9] fix netbsd file-system-info

---
 basis/io/unix/files/netbsd/netbsd.factor | 43 +++++++++++++++++++++---
 basis/unix/statvfs/netbsd/netbsd.factor  |  2 +-
 2 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/basis/io/unix/files/netbsd/netbsd.factor b/basis/io/unix/files/netbsd/netbsd.factor
index 429833a444..1bd8ba4f67 100644
--- a/basis/io/unix/files/netbsd/netbsd.factor
+++ b/basis/io/unix/files/netbsd/netbsd.factor
@@ -2,13 +2,48 @@
 ! 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.files ;
+io.encodings.utf8 alien.strings unix.types unix.statfs 
+io.unix.files io.files unix.statvfs.netbsd ;
 IN: io.unix.files.netbsd
 
 TUPLE: netbsd-file-system-info < unix-file-system-info
-owner io-size blocks-reserved
-sync-reads sync-writes async-reads async-writes
-fsidx fstype mnotonname mntfromname mount-from spare ;
+blocks-reserved files-reserved
+owner io-size
+sync-reads sync-writes
+async-reads async-writes
+idx mount-from spare ;
+
+M: netbsd new-file-system-info netbsd-file-system-info new ;
 
 M: netbsd file-system-statvfs
     "statvfs" <c-object> tuck statvfs io-error ;
+
+M: netbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info' )
+    {
+        [ statvfs-f_flag >>flags ]
+        [ statvfs-f_bsize >>block-size ]
+        [ statvfs-f_frsize >>preferred-block-size ]
+        [ statvfs-f_iosize >>io-size ]
+        [ statvfs-f_blocks >>blocks ]
+        [ statvfs-f_bfree >>blocks-free ]
+        [ statvfs-f_bavail >>blocks-available ]
+        [ statvfs-f_bresvd >>blocks-reserved ]
+        [ statvfs-f_files >>files ]
+        [ statvfs-f_ffree >>files-free ]
+        [ statvfs-f_favail >>files-available ]
+        [ statvfs-f_fresvd >>files-reserved ]
+        [ statvfs-f_syncreads >>sync-reads ]
+        [ statvfs-f_syncwrites >>sync-writes ]
+        [ statvfs-f_asyncreads >>async-reads ]
+        [ statvfs-f_asyncwrites >>async-writes ]
+        [ statvfs-f_fsidx >>idx ]
+        [ statvfs-f_fsid >>id ]
+        [ statvfs-f_namemax >>name-max ]
+        [ statvfs-f_owner >>owner ]
+        [ statvfs-f_spare >>spare ]
+        [ statvfs-f_fstypename alien>native-string >>type ]
+        [ statvfs-f_mntonname alien>native-string >>mount-point ]
+        [ statvfs-f_mntfromname alien>native-string >>device-name ]
+    } cleave ;
+
+FUNCTION: int statvfs ( char* path, statvfs* buf ) ;
diff --git a/basis/unix/statvfs/netbsd/netbsd.factor b/basis/unix/statvfs/netbsd/netbsd.factor
index e67a74de63..cf575c74b1 100644
--- a/basis/unix/statvfs/netbsd/netbsd.factor
+++ b/basis/unix/statvfs/netbsd/netbsd.factor
@@ -32,4 +32,4 @@ C-STRUCT: statvfs
     { { "char" _VFS_MNAMELEN } "f_mntonname" }
     { { "char" _VFS_MNAMELEN } "f_mntfromname" } ;
 
-FUNCTION: int statvfs ( char* path, statvfs *buf ) ;
+FUNCTION: int statvfs ( char* path, statvfs* buf ) ;

From 1f7b5ef6d0eab5deb76d4a351c5692c76b11cc47 Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Mon, 1 Dec 2008 14:04:31 -0600
Subject: [PATCH 2/9] redo most of statfs and statvfs

---
 basis/unix/statfs/freebsd/freebsd.factor      | 29 --------
 basis/unix/statfs/linux/32/32.factor          | 46 ------------
 basis/unix/statfs/linux/32/authors.txt        |  1 -
 basis/unix/statfs/linux/64/64.factor          | 50 -------------
 basis/unix/statfs/linux/64/authors.txt        |  1 -
 basis/unix/statfs/linux/linux.factor          | 47 ++++---------
 basis/unix/statfs/macosx/macosx.factor        | 49 +------------
 basis/unix/statfs/netbsd/netbsd.factor        | 70 -------------------
 basis/unix/statfs/openbsd/32/32.factor        | 26 -------
 basis/unix/statfs/openbsd/32/authors.txt      |  1 -
 basis/unix/statfs/openbsd/64/64.factor        | 32 ---------
 basis/unix/statfs/openbsd/64/authors.txt      |  1 -
 basis/unix/statfs/openbsd/authors.txt         |  1 -
 basis/unix/statfs/openbsd/openbsd.factor      | 53 --------------
 basis/unix/statfs/statfs.factor               |  2 -
 basis/unix/statvfs/authors.txt                |  1 +
 basis/unix/statvfs/freebsd/authors.txt        |  1 +
 basis/unix/statvfs/freebsd/freebsd.factor     | 23 ++++++
 basis/unix/statvfs/linux/authors.txt          |  1 +
 basis/unix/statvfs/linux/linux.factor         | 31 ++++++++
 .../linux/32 => statvfs/linux}/tags.txt       |  0
 basis/unix/statvfs/macosx/authors.txt         |  1 +
 basis/unix/statvfs/macosx/macosx.factor       | 23 ++++++
 .../linux/64 => statvfs/macosx}/tags.txt      |  0
 basis/unix/statvfs/netbsd/authors.txt         |  1 +
 basis/unix/statvfs/netbsd/netbsd.factor       | 35 ++++++++++
 .../openbsd/32 => statvfs/netbsd}/tags.txt    |  0
 basis/unix/statvfs/openbsd/authors.txt        |  1 +
 basis/unix/statvfs/openbsd/openbsd.factor     | 22 ++++++
 .../openbsd/64 => statvfs/openbsd}/tags.txt   |  0
 basis/unix/statvfs/statvfs.factor             | 12 ++++
 .../unix/{statfs/openbsd => statvfs}/tags.txt |  0
 32 files changed, 166 insertions(+), 395 deletions(-)
 delete mode 100644 basis/unix/statfs/linux/32/32.factor
 delete mode 100644 basis/unix/statfs/linux/32/authors.txt
 delete mode 100644 basis/unix/statfs/linux/64/64.factor
 delete mode 100644 basis/unix/statfs/linux/64/authors.txt
 delete mode 100644 basis/unix/statfs/openbsd/32/32.factor
 delete mode 100644 basis/unix/statfs/openbsd/32/authors.txt
 delete mode 100644 basis/unix/statfs/openbsd/64/64.factor
 delete mode 100644 basis/unix/statfs/openbsd/64/authors.txt
 delete mode 100644 basis/unix/statfs/openbsd/authors.txt
 delete mode 100644 basis/unix/statfs/openbsd/openbsd.factor
 create mode 100644 basis/unix/statvfs/authors.txt
 create mode 100644 basis/unix/statvfs/freebsd/authors.txt
 create mode 100644 basis/unix/statvfs/freebsd/freebsd.factor
 create mode 100644 basis/unix/statvfs/linux/authors.txt
 create mode 100644 basis/unix/statvfs/linux/linux.factor
 rename basis/unix/{statfs/linux/32 => statvfs/linux}/tags.txt (100%)
 create mode 100644 basis/unix/statvfs/macosx/authors.txt
 create mode 100644 basis/unix/statvfs/macosx/macosx.factor
 rename basis/unix/{statfs/linux/64 => statvfs/macosx}/tags.txt (100%)
 create mode 100644 basis/unix/statvfs/netbsd/authors.txt
 create mode 100644 basis/unix/statvfs/netbsd/netbsd.factor
 rename basis/unix/{statfs/openbsd/32 => statvfs/netbsd}/tags.txt (100%)
 create mode 100644 basis/unix/statvfs/openbsd/authors.txt
 create mode 100644 basis/unix/statvfs/openbsd/openbsd.factor
 rename basis/unix/{statfs/openbsd/64 => statvfs/openbsd}/tags.txt (100%)
 create mode 100644 basis/unix/statvfs/statvfs.factor
 rename basis/unix/{statfs/openbsd => statvfs}/tags.txt (100%)

diff --git a/basis/unix/statfs/freebsd/freebsd.factor b/basis/unix/statfs/freebsd/freebsd.factor
index b6179a4ad7..5496bbe1ba 100644
--- a/basis/unix/statfs/freebsd/freebsd.factor
+++ b/basis/unix/statfs/freebsd/freebsd.factor
@@ -22,32 +22,3 @@ C-STRUCT: statvfs
     { "ulong" "f_namemax" } ;
 
 FUNCTION: int statvfs ( char* path, statvfs* buf ) ;
-
-TUPLE: freebsd-file-system-info < file-system-info
-bavail bfree blocks favail ffree files
-bsize flag frsize fsid namemax ;
-
-M: freebsd >file-system-info ( struct -- statfs )
-    [ \ freebsd-file-system-info new ] dip
-    {
-        [
-            [ statvfs-f_bsize ]
-            [ statvfs-f_bavail ] bi * >>free-space
-        ]
-        [ statvfs-f_bavail >>bavail ]
-        [ statvfs-f_bfree >>bfree ]
-        [ statvfs-f_blocks >>blocks ]
-        [ statvfs-f_favail >>favail ]
-        [ statvfs-f_ffree >>ffree ]
-        [ statvfs-f_files >>files ]
-        [ statvfs-f_bsize >>bsize ]
-        [ statvfs-f_flag >>flag ]
-        [ statvfs-f_frsize >>frsize ]
-        [ statvfs-f_fsid >>fsid ]
-        [ statvfs-f_namemax >>namemax ]
-    } cleave ;
-
-M: freebsd file-system-info ( path -- byte-array )
-    normalize-path
-    "statvfs" <c-object> tuck statvfs io-error
-    >file-system-info ;
diff --git a/basis/unix/statfs/linux/32/32.factor b/basis/unix/statfs/linux/32/32.factor
deleted file mode 100644
index fb8c6b5035..0000000000
--- a/basis/unix/statfs/linux/32/32.factor
+++ /dev/null
@@ -1,46 +0,0 @@
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types combinators kernel unix.stat
-math accessors system unix io.backend layouts vocabs.loader
-alien.syntax unix.statfs io.files ;
-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" } ;
-
-FUNCTION: int statfs ( char* path, statfs* buf ) ;
-
-TUPLE: linux32-file-system-info < file-system-info
-bsize blocks bfree bavail files ffree fsid namelen
-frsize spare ;
-
-M: linux >file-system-info ( struct -- statfs )
-    [ \ linux32-file-system-info new ] dip
-    {
-        [
-            [ statfs-f_bsize ]
-            [ statfs-f_bavail ] bi * >>free-space
-        ]
-        [ statfs-f_type >>type ]
-        [ statfs-f_bsize >>bsize ]
-        [ statfs-f_blocks >>blocks ]
-        [ statfs-f_bfree >>bfree ]
-        [ statfs-f_bavail >>bavail ]
-        [ statfs-f_files >>files ]
-        [ statfs-f_ffree >>ffree ]
-        [ statfs-f_fsid >>fsid ]
-        [ statfs-f_namelen >>namelen ]
-    } cleave ;
-
-M: linux file-system-info ( path -- byte-array )
-    normalize-path
-    "statfs" <c-object> tuck statfs io-error
-    >file-system-info ;
diff --git a/basis/unix/statfs/linux/32/authors.txt b/basis/unix/statfs/linux/32/authors.txt
deleted file mode 100644
index b4bd0e7b35..0000000000
--- a/basis/unix/statfs/linux/32/authors.txt
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
\ No newline at end of file
diff --git a/basis/unix/statfs/linux/64/64.factor b/basis/unix/statfs/linux/64/64.factor
deleted file mode 100644
index e9cd5576aa..0000000000
--- a/basis/unix/statfs/linux/64/64.factor
+++ /dev/null
@@ -1,50 +0,0 @@
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types combinators kernel unix.stat
-math accessors system unix io.backend layouts vocabs.loader
-alien.syntax unix.statfs io.files ;
-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 ) ;
-
-TUPLE: linux64-file-system-info < file-system-info
-bsize blocks bfree bavail files ffree fsid namelen
-frsize spare ;
-
-M: linux >file-system-info ( struct -- statfs )
-    [ \ linux64-file-system-info new ] dip
-    {
-        [
-            [ statfs64-f_bsize ]
-            [ statfs64-f_bavail ] bi * >>free-space
-        ]
-        [ statfs64-f_type >>type ]
-        [ statfs64-f_bsize >>bsize ]
-        [ statfs64-f_blocks >>blocks ]
-        [ statfs64-f_bfree >>bfree ]
-        [ statfs64-f_bavail >>bavail ]
-        [ statfs64-f_files >>files ]
-        [ statfs64-f_ffree >>ffree ]
-        [ statfs64-f_fsid >>fsid ]
-        [ statfs64-f_namelen >>namelen ]
-        [ statfs64-f_frsize >>frsize ]
-        [ statfs64-f_spare >>spare ]
-    } cleave ;
-
-M: linux file-system-info ( path -- byte-array )
-    normalize-path
-    "statfs64" <c-object> tuck statfs64 io-error
-    >file-system-info ;
diff --git a/basis/unix/statfs/linux/64/authors.txt b/basis/unix/statfs/linux/64/authors.txt
deleted file mode 100644
index b4bd0e7b35..0000000000
--- a/basis/unix/statfs/linux/64/authors.txt
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
\ No newline at end of file
diff --git a/basis/unix/statfs/linux/linux.factor b/basis/unix/statfs/linux/linux.factor
index 43d5a99cd1..eb587e3286 100644
--- a/basis/unix/statfs/linux/linux.factor
+++ b/basis/unix/statfs/linux/linux.factor
@@ -6,38 +6,17 @@ sequences csv io.streams.string io.encodings.utf8 namespaces
 unix.statfs io.files ;
 IN: unix.statfs.linux
 
-cell-bits {
-    { 32 [ "unix.statfs.linux.32" require ] }
-    { 64 [ "unix.statfs.linux.64" require ] }
-} case
+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" } ;
 
-TUPLE: mtab-entry file-system-name mount-point type options
-frequency pass-number ;
-
-: mtab-csv>mtab-entry ( csv -- mtab-entry )
-    [ mtab-entry new ] dip
-    {
-        [ first >>file-system-name ]
-        [ second >>mount-point ]
-        [ third >>type ]
-        [ fourth <string-reader> csv first >>options ]
-        [ 4 swap nth >>frequency ]
-        [ 5 swap nth >>pass-number ]
-    } cleave ;
-
-: parse-mtab ( -- array )
-    [
-        "/etc/mtab" utf8 <file-reader>
-        CHAR: \s delimiter set csv
-    ] with-scope
-    [ mtab-csv>mtab-entry ] map ;
-
-M: linux file-systems
-    parse-mtab [
-        [ mount-point>> file-system-info ] keep
-        {
-            [ file-system-name>> >>device-name ]
-            [ mount-point>> >>mount-point ]
-            [ type>> >>type ]
-        } cleave
-    ] map ;
+FUNCTION: int statfs64 ( char* path, statfs64* buf ) ;
diff --git a/basis/unix/statfs/macosx/macosx.factor b/basis/unix/statfs/macosx/macosx.factor
index 7c30c4b9d4..fcdbb1ee87 100644
--- a/basis/unix/statfs/macosx/macosx.factor
+++ b/basis/unix/statfs/macosx/macosx.factor
@@ -3,7 +3,7 @@
 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 ;
+math.bitwise alien.syntax io.unix.files ;
 IN: unix.statfs.macosx
 
 : MNT_RDONLY  HEX: 00000001 ; inline
@@ -116,50 +116,3 @@ C-STRUCT: statfs64
 
 FUNCTION: int statfs64 ( char* path, statfs64* buf ) ;
 FUNCTION: int getmntinfo64 ( statfs64** mntbufp, int flags ) ;
-
-
-TUPLE: macosx-file-system-info < file-system-info
-block-size io-size blocks blocks-free blocks-available files
-files-free file-system-id owner type-id flags filesystem-subtype ;
-
-M: macosx file-systems ( -- array )
-    f <void*> dup 0 getmntinfo64 dup io-error
-    [ *void* ] dip
-    "statfs64" heap-size [ * memory>byte-array ] keep group
-    [ >file-system-info ] map ;
-
-M: macosx >file-system-info ( byte-array -- file-system-info )
-    [ \ macosx-file-system-info new ] dip
-    {
-        [
-            [ statfs64-f_bavail ] [ statfs64-f_bsize ] bi *
-            >>free-space
-        ]
-        [ statfs64-f_mntonname utf8 alien>string >>mount-point ]
-        [ statfs64-f_bsize >>block-size ]
-
-        [ statfs64-f_iosize >>io-size ]
-        [ statfs64-f_blocks >>blocks ]
-        [ statfs64-f_bfree >>blocks-free ]
-        [ statfs64-f_bavail >>blocks-available ]
-        [ statfs64-f_files >>files ]
-        [ statfs64-f_ffree >>files-free ]
-        [ statfs64-f_fsid >>file-system-id ]
-        [ statfs64-f_owner >>owner ]
-        [ statfs64-f_type >>type-id ]
-        [ statfs64-f_flags >>flags ]
-        [ statfs64-f_fssubtype >>filesystem-subtype ]
-        [
-            statfs64-f_fstypename utf8 alien>string
-            >>type
-        ]
-        [
-            statfs64-f_mntfromname
-            utf8 alien>string >>device-name
-        ]
-    } cleave ;
-
-M: macosx file-system-info ( path -- file-system-info )
-    normalize-path
-    "statfs64" <c-object> tuck statfs64 io-error
-    >file-system-info ;
diff --git a/basis/unix/statfs/netbsd/netbsd.factor b/basis/unix/statfs/netbsd/netbsd.factor
index ad7c161713..30f258ca8d 100644
--- a/basis/unix/statfs/netbsd/netbsd.factor
+++ b/basis/unix/statfs/netbsd/netbsd.factor
@@ -5,74 +5,4 @@ combinators system io.backend accessors alien.c-types
 io.encodings.utf8 alien.strings unix.types unix.statfs io.files ;
 IN: unix.statfs.netbsd
 
-: _VFS_NAMELEN    32   ; inline
-: _VFS_MNAMELEN   1024 ; inline
 
-C-STRUCT: statvfs
-    { "ulong"   "f_flag" }   
-    { "ulong"   "f_bsize" }
-    { "ulong"   "f_frsize" }  
-    { "ulong"   "f_iosize" }  
-    { "fsblkcnt_t" "f_blocks" }       
-    { "fsblkcnt_t" "f_bfree" } 
-    { "fsblkcnt_t" "f_bavail" }       
-    { "fsblkcnt_t" "f_bresvd" }       
-    { "fsfilcnt_t" "f_files" }
-    { "fsfilcnt_t" "f_ffree" }
-    { "fsfilcnt_t" "f_favail" }       
-    { "fsfilcnt_t" "f_fresvd" }       
-    { "uint64_t"   "f_syncreads" }    
-    { "uint64_t"   "f_syncwrites" }   
-    { "uint64_t"   "f_asyncreads" }   
-    { "uint64_t"   "f_asyncwrites" }  
-    { "fsid_t"    "f_fsidx" }
-    { "ulong"   "f_fsid" }
-    { "ulong"   "f_namemax" }      
-    { "uid_t"   "f_owner" }
-    { { "uint32_t" 4 } "f_spare" }     
-    { { "char" _VFS_NAMELEN } "f_fstypename" }
-    { { "char" _VFS_MNAMELEN } "f_mntonname" }
-    { { "char" _VFS_MNAMELEN } "f_mntfromname" } ;
-
-FUNCTION: int statvfs ( char* path, statvfs *buf ) ;
-
-TUPLE: netbsd-file-system-info < file-system-info
-flag bsize frsize io-size
-blocks blocks-free blocks-available blocks-reserved
-files ffree sync-reads sync-writes async-reads async-writes
-fsidx fsid namemax owner spare fstype mnotonname mntfromname
-file-system-type-name mount-from ;
-
-M: netbsd >file-system-info ( byte-array -- netbsd-file-system-info )
-    [ \ netbsd-file-system-info new ] dip
-    {
-        [
-            [ statvfs-f_bsize ]
-            [ statvfs-f_bavail ] bi * >>free-space
-        ]
-        [ statvfs-f_flag >>flag ]
-        [ statvfs-f_bsize >>bsize ]
-        [ statvfs-f_frsize >>frsize ]
-        [ statvfs-f_iosize >>io-size ]
-        [ statvfs-f_blocks >>blocks ]
-        [ statvfs-f_bfree >>blocks-free ]
-        [ statvfs-f_favail >>blocks-available ]
-        [ statvfs-f_fresvd >>blocks-reserved ]
-        [ statvfs-f_files >>files ]
-        [ statvfs-f_ffree >>ffree ]
-        [ statvfs-f_syncreads >>sync-reads ]
-        [ statvfs-f_syncwrites >>sync-writes ]
-        [ statvfs-f_asyncreads >>async-reads ]
-        [ statvfs-f_asyncwrites >>async-writes ]
-        [ statvfs-f_fsidx >>fsidx ]
-        [ statvfs-f_namemax >>namemax ]
-        [ statvfs-f_owner >>owner ]
-        [ statvfs-f_spare >>spare ]
-        [ statvfs-f_fstypename utf8 alien>string >>file-system-type-name ]
-        [ statvfs-f_mntonname utf8 alien>string >>mount-point ]
-        [ statvfs-f_mntfromname utf8 alien>string >>mount-from ]
-    } cleave ;
-
-M: netbsd file-system-info
-    normalize-path "statvfs" <c-object> tuck statvfs io-error 
-    >file-system-info ;
diff --git a/basis/unix/statfs/openbsd/32/32.factor b/basis/unix/statfs/openbsd/32/32.factor
deleted file mode 100644
index aa1e8425dc..0000000000
--- a/basis/unix/statfs/openbsd/32/32.factor
+++ /dev/null
@@ -1,26 +0,0 @@
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax kernel unix ; 
-IN: unix.statfs.openbsd.32
-
-: MFSNAMELEN 16 ; inline
-: MNAMELEN 90 ; inline
-
-C-STRUCT: statfs
-    { "u_int32_t"  "f_flags" }
-    { "int32_t"    "f_bsize" }
-    { "u_int32_t"  "f_iosize" }
-    { "u_int32_t"  "f_blocks" }
-    { "u_int32_t"  "f_bfree" }
-    { "int32_t"    "f_bavail" }
-    { "u_int32_t"  "f_files" }
-    { "u_int32_t"  "f_ffree" }
-    { "fsid_t"     "f_fsid" }
-    { "uid_t"      "f_owner" }
-    { "u_int32_t"  "f_syncwrites" }
-    { "u_int32_t"  "f_asyncwrites" }
-    { "u_int32_t"  "f_ctime" }
-    { { "u_int32_t" 3 }  "f_spare" }
-    { { "char" MFSNAMELEN } "f_fstypename" }
-    { { "char" MNAMELEN }   "f_mntonname" }  
-    { { "char" MNAMELEN }   "f_mntfromname" } ;
diff --git a/basis/unix/statfs/openbsd/32/authors.txt b/basis/unix/statfs/openbsd/32/authors.txt
deleted file mode 100644
index b4bd0e7b35..0000000000
--- a/basis/unix/statfs/openbsd/32/authors.txt
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
\ No newline at end of file
diff --git a/basis/unix/statfs/openbsd/64/64.factor b/basis/unix/statfs/openbsd/64/64.factor
deleted file mode 100644
index fd40fba033..0000000000
--- a/basis/unix/statfs/openbsd/64/64.factor
+++ /dev/null
@@ -1,32 +0,0 @@
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax unix ;
-IN: unix.statfs.openbsd.64
-
-: MFSNAMELEN 16 ; inline
-: MNAMELEN 90 ; inline
-
-C-STRUCT: statfss
-    { "u_int32_t"      "f_flags" }
-    { "u_int32_t"      "f_bsize" }
-    { "u_int32_t"      "f_iosize" }
-    { "u_int64_t"      "f_blocks" }
-    { "u_int64_t"      "f_bfree" }
-    { "int64_t"        "f_bavail" }
-    { "u_int64_t"      "f_files" }
-    { "u_int64_t"      "f_ffree" }
-    { "int64_t"        "f_favail" }
-    { "u_int64_t"      "f_syncwrites" }
-    { "u_int64_t"      "f_syncreads" }
-    { "u_int64_t"      "f_asyncwrites" }
-    { "u_int64_t"      "f_asyncreads" }
-    { "fsid_t"         "f_fsid" }
-    { "u_int32_t"      "f_namemax" }
-    { "uid_t"          "f_owner" }
-    { "u_int32_t"      "f_ctime" }
-    { { "u_int32_t" 3 } " f_spare" }
-    { { "char" MFSNAMELEN } "f_fstypename" }
-    { { "char" MNAMELEN } "f_mntonname" }
-    { { "char" MNAMELEN } "f_mntfromname" }
-    { { "char" 512 } "mount_info" } ;
-    ! { "mount_info" "mount_info" } ;                                        
diff --git a/basis/unix/statfs/openbsd/64/authors.txt b/basis/unix/statfs/openbsd/64/authors.txt
deleted file mode 100644
index b4bd0e7b35..0000000000
--- a/basis/unix/statfs/openbsd/64/authors.txt
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
\ No newline at end of file
diff --git a/basis/unix/statfs/openbsd/authors.txt b/basis/unix/statfs/openbsd/authors.txt
deleted file mode 100644
index b4bd0e7b35..0000000000
--- a/basis/unix/statfs/openbsd/authors.txt
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
\ No newline at end of file
diff --git a/basis/unix/statfs/openbsd/openbsd.factor b/basis/unix/statfs/openbsd/openbsd.factor
deleted file mode 100644
index fa86ef2bc2..0000000000
--- a/basis/unix/statfs/openbsd/openbsd.factor
+++ /dev/null
@@ -1,53 +0,0 @@
-! 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
-unix.statfs 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
-
-FUNCTION: int statvfs ( char* path, statvfs* buf ) ;
-
-TUPLE: openbsd-file-system-info < file-system-info
-bsize frsize blocks bfree bavail files ffree favail
-fsid flag namemax ;
-
-M: openbsd >file-system-info ( struct -- statfs )
-    [ \ openbsd-file-system-info new ] dip
-    {
-        [
-            [ statvfs-f_bsize ]
-            [ statvfs-f_bavail ] bi * >>free-space
-        ]
-        [ statvfs-f_bsize >>bsize ]
-        [ statvfs-f_frsize >>frsize ]
-        [ statvfs-f_blocks >>blocks ]
-        [ statvfs-f_bfree >>bfree ]
-        [ statvfs-f_bavail >>bavail ]
-        [ statvfs-f_files >>files ]
-        [ statvfs-f_ffree >>ffree ]
-        [ statvfs-f_favail >>favail ]
-        [ statvfs-f_fsid >>fsid ]
-        [ statvfs-f_flag >>flag ]
-        [ statvfs-f_namemax >>namemax ]
-    } cleave ;
-
-M: openbsd file-system-info ( path -- byte-array )
-    normalize-path
-    "statvfs" <c-object> tuck statvfs io-error
-    >file-system-info ;
diff --git a/basis/unix/statfs/statfs.factor b/basis/unix/statfs/statfs.factor
index 0397507fce..bc7b199705 100644
--- a/basis/unix/statfs/statfs.factor
+++ b/basis/unix/statfs/statfs.factor
@@ -4,8 +4,6 @@ USING: sequences system vocabs.loader combinators accessors
 kernel math.order sorting ;
 IN: unix.statfs
 
-HOOK: >file-system-info os ( struct -- statfs )
-
 os {
     { linux   [ "unix.statfs.linux"   require ] }
     { macosx  [ "unix.statfs.macosx"  require ] }
diff --git a/basis/unix/statvfs/authors.txt b/basis/unix/statvfs/authors.txt
new file mode 100644
index 0000000000..7c1b2f2279
--- /dev/null
+++ b/basis/unix/statvfs/authors.txt
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/unix/statvfs/freebsd/authors.txt b/basis/unix/statvfs/freebsd/authors.txt
new file mode 100644
index 0000000000..7c1b2f2279
--- /dev/null
+++ b/basis/unix/statvfs/freebsd/authors.txt
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/unix/statvfs/freebsd/freebsd.factor b/basis/unix/statvfs/freebsd/freebsd.factor
new file mode 100644
index 0000000000..7d1a6afb61
--- /dev/null
+++ b/basis/unix/statvfs/freebsd/freebsd.factor
@@ -0,0 +1,23 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.syntax ;
+IN: unix.statvfs.freebsd
+
+C-STRUCT: statvfs
+    { "fsblkcnt_t"  "f_bavail" }
+    { "fsblkcnt_t"  "f_bfree" }
+    { "fsblkcnt_t"  "f_blocks" }
+    { "fsfilcnt_t"  "f_favail" }
+    { "fsfilcnt_t"  "f_ffree" }
+    { "fsfilcnt_t"  "f_files" }
+    { "ulong"   "f_bsize" }
+    { "ulong"   "f_flag" }
+    { "ulong"   "f_frsize" }
+    { "ulong"   "f_fsid" }
+    { "ulong"   "f_namemax" } ;
+
+! Flags
+: ST_RDONLY   HEX: 1 ; inline ! Read-only file system
+: ST_NOSUID   HEX: 2 ; inline ! Does not honor setuid/setgid
+
+FUNCTION: int statvfs ( char* path, statvfs* buf ) ;
diff --git a/basis/unix/statvfs/linux/authors.txt b/basis/unix/statvfs/linux/authors.txt
new file mode 100644
index 0000000000..7c1b2f2279
--- /dev/null
+++ b/basis/unix/statvfs/linux/authors.txt
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/unix/statvfs/linux/linux.factor b/basis/unix/statvfs/linux/linux.factor
new file mode 100644
index 0000000000..008692a501
--- /dev/null
+++ b/basis/unix/statvfs/linux/linux.factor
@@ -0,0 +1,31 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.syntax ;
+IN: unix.statvfs.linux
+
+C-STRUCT: statvfs64
+    { "ulong" "f_bsize" }
+    { "ulong" "f_frsize" }
+    { "__fsblkcnt64_t" "f_blocks" }
+    { "__fsblkcnt64_t" "f_bfree" }
+    { "__fsblkcnt64_t" "f_bavail" }
+    { "__fsfilcnt64_t" "f_files" }
+    { "__fsfilcnt64_t" "f_ffree" }
+    { "__fsfilcnt64_t" "f_favail" }
+    { "ulong" "f_fsid" }
+    { "ulong" "f_flag" }
+    { "ulong" f_namemax" }
+    { { "int" 6 } "__f_spare" } ;
+
+FUNCTION: int statvfs64 ( char* path, statvfs64* buf ) ;
+
+: ST_RDONLY 1 ; inline        ! Mount read-only.
+: ST_NOSUID 2 ; inline        ! Ignore suid and sgid bits.
+: ST_NODEV 4 ; inline         ! Disallow access to device special files.
+: ST_NOEXEC 8 ; inline        ! Disallow program execution.
+: ST_SYNCHRONOUS 16 ; inline  ! Writes are synced at once.
+: ST_MANDLOCK 64 ; inline     ! Allow mandatory locks on an FS.
+: ST_WRITE 128 ; inline       ! Write on file/directory/symlink.
+: ST_APPEND 256 ; inline      ! Append-only file.
+: ST_IMMUTABLE 512 ; inline   ! Immutable file.
+: ST_NOATIME 1024 ; inline    ! Do not update access times.
diff --git a/basis/unix/statfs/linux/32/tags.txt b/basis/unix/statvfs/linux/tags.txt
similarity index 100%
rename from basis/unix/statfs/linux/32/tags.txt
rename to basis/unix/statvfs/linux/tags.txt
diff --git a/basis/unix/statvfs/macosx/authors.txt b/basis/unix/statvfs/macosx/authors.txt
new file mode 100644
index 0000000000..7c1b2f2279
--- /dev/null
+++ b/basis/unix/statvfs/macosx/authors.txt
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/unix/statvfs/macosx/macosx.factor b/basis/unix/statvfs/macosx/macosx.factor
new file mode 100644
index 0000000000..7078ff9f33
--- /dev/null
+++ b/basis/unix/statvfs/macosx/macosx.factor
@@ -0,0 +1,23 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.syntax ;
+IN: unix.statvfs.macosx
+
+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" } ;
+
+! Flags
+: ST_RDONLY   HEX: 1 ; inline ! Read-only file system
+: ST_NOSUID   HEX: 2 ; inline ! Does not honor setuid/setgid
+
+FUNCTION: int statvfs ( char* path, statvfs* buf ) ;
diff --git a/basis/unix/statfs/linux/64/tags.txt b/basis/unix/statvfs/macosx/tags.txt
similarity index 100%
rename from basis/unix/statfs/linux/64/tags.txt
rename to basis/unix/statvfs/macosx/tags.txt
diff --git a/basis/unix/statvfs/netbsd/authors.txt b/basis/unix/statvfs/netbsd/authors.txt
new file mode 100644
index 0000000000..7c1b2f2279
--- /dev/null
+++ b/basis/unix/statvfs/netbsd/authors.txt
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/unix/statvfs/netbsd/netbsd.factor b/basis/unix/statvfs/netbsd/netbsd.factor
new file mode 100644
index 0000000000..e67a74de63
--- /dev/null
+++ b/basis/unix/statvfs/netbsd/netbsd.factor
@@ -0,0 +1,35 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.syntax ;
+IN: unix.statvfs.netbsd
+
+: _VFS_NAMELEN    32   ; inline
+: _VFS_MNAMELEN   1024 ; inline
+
+C-STRUCT: statvfs
+    { "ulong"   "f_flag" }   
+    { "ulong"   "f_bsize" }
+    { "ulong"   "f_frsize" }  
+    { "ulong"   "f_iosize" }  
+    { "fsblkcnt_t" "f_blocks" }       
+    { "fsblkcnt_t" "f_bfree" } 
+    { "fsblkcnt_t" "f_bavail" }       
+    { "fsblkcnt_t" "f_bresvd" }       
+    { "fsfilcnt_t" "f_files" }
+    { "fsfilcnt_t" "f_ffree" }
+    { "fsfilcnt_t" "f_favail" }       
+    { "fsfilcnt_t" "f_fresvd" }       
+    { "uint64_t"   "f_syncreads" }    
+    { "uint64_t"   "f_syncwrites" }   
+    { "uint64_t"   "f_asyncreads" }   
+    { "uint64_t"   "f_asyncwrites" }  
+    { "fsid_t"    "f_fsidx" }
+    { "ulong"   "f_fsid" }
+    { "ulong"   "f_namemax" }      
+    { "uid_t"   "f_owner" }
+    { { "uint32_t" 4 } "f_spare" }     
+    { { "char" _VFS_NAMELEN } "f_fstypename" }
+    { { "char" _VFS_MNAMELEN } "f_mntonname" }
+    { { "char" _VFS_MNAMELEN } "f_mntfromname" } ;
+
+FUNCTION: int statvfs ( char* path, statvfs *buf ) ;
diff --git a/basis/unix/statfs/openbsd/32/tags.txt b/basis/unix/statvfs/netbsd/tags.txt
similarity index 100%
rename from basis/unix/statfs/openbsd/32/tags.txt
rename to basis/unix/statvfs/netbsd/tags.txt
diff --git a/basis/unix/statvfs/openbsd/authors.txt b/basis/unix/statvfs/openbsd/authors.txt
new file mode 100644
index 0000000000..7c1b2f2279
--- /dev/null
+++ b/basis/unix/statvfs/openbsd/authors.txt
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/unix/statvfs/openbsd/openbsd.factor b/basis/unix/statvfs/openbsd/openbsd.factor
new file mode 100644
index 0000000000..3f9353f926
--- /dev/null
+++ b/basis/unix/statvfs/openbsd/openbsd.factor
@@ -0,0 +1,22 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.syntax ;
+IN: unix.statvfs.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
+
+FUNCTION: int statvfs ( char* path, statvfs* buf ) ;
diff --git a/basis/unix/statfs/openbsd/64/tags.txt b/basis/unix/statvfs/openbsd/tags.txt
similarity index 100%
rename from basis/unix/statfs/openbsd/64/tags.txt
rename to basis/unix/statvfs/openbsd/tags.txt
diff --git a/basis/unix/statvfs/statvfs.factor b/basis/unix/statvfs/statvfs.factor
new file mode 100644
index 0000000000..e610140397
--- /dev/null
+++ b/basis/unix/statvfs/statvfs.factor
@@ -0,0 +1,12 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: combinators system vocabs.loader ;
+IN: unix.statvfs
+
+os {
+    { linux   [ "unix.statvfs.linux"   require ] }
+    { macosx  [ "unix.statvfs.macosx"  require ] }
+    { freebsd [ "unix.statvfs.freebsd" require ] }
+    { netbsd  [ "unix.statvfs.netbsd"  require ] }
+    { openbsd [ "unix.statvfs.openbsd" require ] }
+} case
diff --git a/basis/unix/statfs/openbsd/tags.txt b/basis/unix/statvfs/tags.txt
similarity index 100%
rename from basis/unix/statfs/openbsd/tags.txt
rename to basis/unix/statvfs/tags.txt

From 2a34339e6579b2a03ed304e59603d4c8acd0a8e5 Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Mon, 1 Dec 2008 14:04:55 -0600
Subject: [PATCH 3/9] make a generic protocol for filling in the
 file-system-info obj in io.unix.files

---
 basis/io/unix/files/files.factor           | 57 ++++++++++++++++--
 basis/io/unix/files/freebsd/freebsd.factor | 24 ++++++++
 basis/io/unix/files/freebsd/tags.txt       |  1 +
 basis/io/unix/files/linux/linux.factor     | 67 ++++++++++++++++++++++
 basis/io/unix/files/linux/tags.txt         |  1 +
 basis/io/unix/files/macosx/macosx.factor   | 50 ++++++++++++++++
 basis/io/unix/files/macosx/tags.txt        |  1 +
 basis/io/unix/files/netbsd/netbsd.factor   | 14 +++++
 basis/io/unix/files/netbsd/tags.txt        |  1 +
 basis/io/unix/files/openbsd/openbsd.factor | 24 ++++++++
 basis/io/unix/files/openbsd/tags.txt       |  1 +
 11 files changed, 237 insertions(+), 4 deletions(-)
 create mode 100644 basis/io/unix/files/freebsd/freebsd.factor
 create mode 100644 basis/io/unix/files/freebsd/tags.txt
 create mode 100644 basis/io/unix/files/linux/linux.factor
 create mode 100644 basis/io/unix/files/linux/tags.txt
 create mode 100644 basis/io/unix/files/macosx/macosx.factor
 create mode 100644 basis/io/unix/files/macosx/tags.txt
 create mode 100644 basis/io/unix/files/netbsd/netbsd.factor
 create mode 100644 basis/io/unix/files/netbsd/tags.txt
 create mode 100644 basis/io/unix/files/openbsd/openbsd.factor
 create mode 100644 basis/io/unix/files/openbsd/tags.txt

diff --git a/basis/io/unix/files/files.factor b/basis/io/unix/files/files.factor
index 9fa1727e16..d1fb059b77 100644
--- a/basis/io/unix/files/files.factor
+++ b/basis/io/unix/files/files.factor
@@ -6,7 +6,7 @@ math.bitwise byte-arrays alien combinators calendar
 io.encodings.binary accessors sequences strings system
 io.files.private destructors vocabs.loader calendar.unix
 unix.stat alien.c-types arrays unix.users unix.groups
-environment fry io.encodings.utf8 alien.strings unix.statfs
+environment fry io.encodings.utf8 alien.strings
 combinators.short-circuit ;
 IN: io.unix.files
 
@@ -76,15 +76,64 @@ M: unix copy-file ( from to -- )
     [ swap file-info permissions>> chmod io-error ]
     2bi ;
 
-HOOK: stat>file-info os ( stat -- file-info )
+TUPLE: unix-file-system-info < file-system-info
+block-size preferred-block-size
+blocks blocks-free blocks-available
+files files-free files-available
+name-max flags id ;
 
-HOOK: stat>type os ( stat -- file-info )
+HOOK: new-file-system-info os ( --  file-system-info )
 
-HOOK: new-file-info os ( -- class )
+M: unix new-file-system-info ( -- ) unix-file-system-info new ;
+
+HOOK: file-system-statfs os ( path -- statfs )
+
+M: unix file-system-statfs drop f ;
+
+HOOK: file-system-statvfs os ( path -- statvfs )
+
+M: unix file-system-statvfs drop f ;
+
+HOOK: statfs>file-system-info os ( file-system-info statfs -- file-system-info' )
+
+M: unix statfs>file-system-info drop ;
+
+HOOK: statvfs>file-system-info os ( file-system-info statvfs -- file-system-info' )
+
+M: unix statvfs>file-system-info drop ;
+
+: file-system-calculations ( file-system-info -- file-system-info' )
+    {
+        [ dup [ blocks-available>> ] [ block-size>> ] bi * >>free-space drop ]
+        [ dup [ blocks>> ] [ block-size>> ] bi * >>total-space drop ]
+        [ dup [ total-space>> ] [ free-space>> ] bi - >>used-space drop ]
+        [ ]
+    } cleave ;
+
+M: unix file-system-info
+    normalize-path
+    [ new-file-system-info ] dip
+    [ file-system-statfs statfs>file-system-info ]
+    [ file-system-statvfs statvfs>file-system-info ] bi
+    file-system-calculations ;
+
+os {
+    { linux   [ "io.unix.files.linux"   require ] }
+    { macosx  [ "io.unix.files.macosx"  require ] }
+    { freebsd [ "io.unix.files.freebsd" require ] }
+    { netbsd  [ "io.unix.files.netbsd"  require ] }
+    { openbsd [ "io.unix.files.openbsd" require ] }
+} case
 
 TUPLE: unix-file-info < file-info uid gid dev ino
 nlink rdev blocks blocksize ;
 
+HOOK: new-file-info os ( -- file-info )
+
+HOOK: stat>file-info os ( stat -- file-info )
+
+HOOK: stat>type os ( stat -- file-info )
+
 M: unix file-info ( path -- info )
     normalize-path file-status stat>file-info ;
 
diff --git a/basis/io/unix/files/freebsd/freebsd.factor b/basis/io/unix/files/freebsd/freebsd.factor
new file mode 100644
index 0000000000..48dfd37584
--- /dev/null
+++ b/basis/io/unix/files/freebsd/freebsd.factor
@@ -0,0 +1,24 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.syntax kernel unix math accessors
+combinators system io.backend alien.c-types unix.statfs 
+io.files ;
+IN: io.unix.files.freebsd
+
+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_bavail >>blocks-available ]
+        [ statvfs-f_bfree >>blocks-free ]
+        [ statvfs-f_blocks >>blocks ]
+        [ 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_fsid >>id ]
+        [ statvfs-f_namemax >>name-max ]
+    } cleave ;
diff --git a/basis/io/unix/files/freebsd/tags.txt b/basis/io/unix/files/freebsd/tags.txt
new file mode 100644
index 0000000000..6bf68304bb
--- /dev/null
+++ b/basis/io/unix/files/freebsd/tags.txt
@@ -0,0 +1 @@
+unportable
diff --git a/basis/io/unix/files/linux/linux.factor b/basis/io/unix/files/linux/linux.factor
new file mode 100644
index 0000000000..584015711f
--- /dev/null
+++ b/basis/io/unix/files/linux/linux.factor
@@ -0,0 +1,67 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+
+IN: io.unix.files.linux
+
+TUPLE: linux-file-system-info < unix-file-system-info
+namelen spare ;
+
+M: linux new-file-system-info unix-file-system-info new ;
+
+M: linux file-system-statfs ( path -- byte-array )
+    "statfs64" <c-object> tuck statfs64 io-error ;
+
+M: linux statfs>file-system-info ( struct -- statfs )
+    {
+        [ statfs64-f_type >>type ]
+        [ statfs64-f_bsize >>block-size ]
+        [ statfs64-f_blocks >>blocks ]
+        [ statfs64-f_bfree >>blocks-free ]
+        [ statfs64-f_bavail >>blocks-available ]
+        [ statfs64-f_files >>files ]
+        [ statfs64-f_ffree >>files-free ]
+        [ statfs64-f_fsid >>id ]
+        [ statfs64-f_namelen >>namelen ]
+        [ statfs64-f_frsize >>preferred-block-size ]
+        [ statfs64-f_spare >>spare ]
+    } cleave ;
+
+M: linux file-system-statvfs ( path -- byte-array )
+    "statvfs64" <c-object> tuck statvfs64 io-error ;
+
+M: linux statvfs>file-system-info ( struct -- statfs )
+    {
+        [ statvfs64-f_flag >>flags ]
+        [ statvfs64-f_namemax >>name-max ]
+    } cleave ;
+
+M: linux file-systems
+    parse-mtab [
+        [ mount-point>> file-system-info ] keep
+        {
+            [ file-system-name>> >>device-name ]
+            [ mount-point>> >>mount-point ]
+            [ type>> >>type ]
+        } cleave
+    ] map ;
+
+TUPLE: mtab-entry file-system-name mount-point type options
+frequency pass-number ;
+
+: mtab-csv>mtab-entry ( csv -- mtab-entry )
+    [ mtab-entry new ] dip
+    {
+        [ first >>file-system-name ]
+        [ second >>mount-point ]
+        [ third >>type ]
+        [ fourth <string-reader> csv first >>options ]
+        [ 4 swap nth >>frequency ]
+        [ 5 swap nth >>pass-number ]
+    } cleave ;
+
+: parse-mtab ( -- array )
+    [
+        "/etc/mtab" utf8 <file-reader>
+        CHAR: \s delimiter set csv
+    ] with-scope
+    [ mtab-csv>mtab-entry ] map ;
diff --git a/basis/io/unix/files/linux/tags.txt b/basis/io/unix/files/linux/tags.txt
new file mode 100644
index 0000000000..6bf68304bb
--- /dev/null
+++ b/basis/io/unix/files/linux/tags.txt
@@ -0,0 +1 @@
+unportable
diff --git a/basis/io/unix/files/macosx/macosx.factor b/basis/io/unix/files/macosx/macosx.factor
new file mode 100644
index 0000000000..c5d12a012e
--- /dev/null
+++ b/basis/io/unix/files/macosx/macosx.factor
@@ -0,0 +1,50 @@
+! Copyright (C) 2008 Doug Coleman.
+! 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 ;
+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 <void*> 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 ;
+
+M: macosx new-file-system-info macosx-file-system-info new ;
+
+M: macosx file-system-statfs ( normalized-path -- statfs )
+    "statfs64" <c-object> tuck statfs64 io-error ;
+
+M: macosx file-system-statvfs ( normalized-path -- statvfs )
+    "statvfs" <c-object> tuck statvfs io-error ;
+
+M: macosx statfs>file-system-info ( file-system-info byte-array -- file-system-info' )
+    {
+        [ statfs64-f_bsize >>block-size ]
+        [ statfs64-f_iosize >>io-size ]
+        [ statfs64-f_blocks >>blocks ]
+        [ statfs64-f_bfree >>blocks-free ]
+        [ statfs64-f_bavail >>blocks-available ]
+        [ statfs64-f_files >>files ]
+        [ statfs64-f_ffree >>files-free ]
+        [ statfs64-f_fsid >>id ]
+        [ statfs64-f_owner >>owner ]
+        [ statfs64-f_type >>type-id ]
+        [ statfs64-f_flags >>flags ]
+        [ statfs64-f_fssubtype >>filesystem-subtype ]
+        [ statfs64-f_fstypename utf8 alien>string >>type ]
+        [ statfs64-f_mntonname utf8 alien>string >>mount-point ]
+        [ statfs64-f_mntfromname utf8 alien>string >>device-name ]
+    } cleave ;
+
+M: macosx statvfs>file-system-info ( file-system-info byte-array -- file-system-info' )
+    {
+        [ statvfs-f_frsize >>preferred-block-size ]
+        [ statvfs-f_favail >>files-available ]
+        [ statvfs-f_namemax >>name-max ]
+    } cleave ;
+
diff --git a/basis/io/unix/files/macosx/tags.txt b/basis/io/unix/files/macosx/tags.txt
new file mode 100644
index 0000000000..6bf68304bb
--- /dev/null
+++ b/basis/io/unix/files/macosx/tags.txt
@@ -0,0 +1 @@
+unportable
diff --git a/basis/io/unix/files/netbsd/netbsd.factor b/basis/io/unix/files/netbsd/netbsd.factor
new file mode 100644
index 0000000000..429833a444
--- /dev/null
+++ b/basis/io/unix/files/netbsd/netbsd.factor
@@ -0,0 +1,14 @@
+! Copyright (C) 2008 Doug Coleman.
+! 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.files ;
+IN: io.unix.files.netbsd
+
+TUPLE: netbsd-file-system-info < unix-file-system-info
+owner io-size blocks-reserved
+sync-reads sync-writes async-reads async-writes
+fsidx fstype mnotonname mntfromname mount-from spare ;
+
+M: netbsd file-system-statvfs
+    "statvfs" <c-object> tuck statvfs io-error ;
diff --git a/basis/io/unix/files/netbsd/tags.txt b/basis/io/unix/files/netbsd/tags.txt
new file mode 100644
index 0000000000..6bf68304bb
--- /dev/null
+++ b/basis/io/unix/files/netbsd/tags.txt
@@ -0,0 +1 @@
+unportable
diff --git a/basis/io/unix/files/openbsd/openbsd.factor b/basis/io/unix/files/openbsd/openbsd.factor
new file mode 100644
index 0000000000..d348d281fb
--- /dev/null
+++ b/basis/io/unix/files/openbsd/openbsd.factor
@@ -0,0 +1,24 @@
+! 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
+unix.statfs io.files ;
+IN: io.unix.files.openbsd
+
+M: openbsd >file-system-info ( file-system-info statvfs -- file-system-info' )
+    {
+        [ statvfs-f_bsize >>block-size ]
+        [ statvfs-f_frsize >>preferred-block-size ]
+        [ statvfs-f_blocks >>blocks ]
+        [ statvfs-f_bfree >>blocks-free ]
+        [ statvfs-f_bavail >>blocks-avail ]
+        [ statvfs-f_files >>files ]
+        [ statvfs-f_ffree >>files-free ]
+        [ statvfs-f_favail >>files-available ]
+        [ statvfs-f_fsid >>id ]
+        [ statvfs-f_flag >>flags ]
+        [ statvfs-f_namemax >>name-max ]
+    } cleave ;
+
+M: openbsd file-system-statvfs ( normalized-path -- statvfs )
+    "statvfs" <c-object> tuck statvfs io-error ;
diff --git a/basis/io/unix/files/openbsd/tags.txt b/basis/io/unix/files/openbsd/tags.txt
new file mode 100644
index 0000000000..6bf68304bb
--- /dev/null
+++ b/basis/io/unix/files/openbsd/tags.txt
@@ -0,0 +1 @@
+unportable

From 28e6d7d11617945a28bbce2aeffc08251f2ae0ed Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Mon, 1 Dec 2008 14:05:46 -0600
Subject: [PATCH 4/9] add more shared slots fo file-system-info

---
 core/io/files/files.factor | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/io/files/files.factor b/core/io/files/files.factor
index 7c7a2ece31..cd1c5d698c 100644
--- a/core/io/files/files.factor
+++ b/core/io/files/files.factor
@@ -187,7 +187,8 @@ SYMBOL: +unknown+
 
 HOOK: file-systems os ( -- array )
 
-TUPLE: file-system-info device-name mount-point type free-space ;
+TUPLE: file-system-info device-name mount-point type
+free-space used-space total-space ;
 
 HOOK: file-system-info os ( path -- file-system-info )
 

From dfde2dfef36ec1604173ff26fbf18147815966f3 Mon Sep 17 00:00:00 2001
From: erg <erg@ubuntubox.(none)>
Date: Mon, 1 Dec 2008 16:28:22 -0600
Subject: [PATCH 5/9] fix file-system-info on linux

---
 basis/io/unix/files/linux/linux.factor | 27 ++++++++++++++------------
 basis/unix/statfs/linux/linux.factor   |  5 +----
 basis/unix/statvfs/linux/linux.factor  |  2 +-
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/basis/io/unix/files/linux/linux.factor b/basis/io/unix/files/linux/linux.factor
index 584015711f..dd9abcbd1e 100644
--- a/basis/io/unix/files/linux/linux.factor
+++ b/basis/io/unix/files/linux/linux.factor
@@ -1,12 +1,15 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-
+USING: accessors alien.c-types alien.syntax combinators csv
+io.encodings.utf8 io.files io.streams.string io.unix.files
+kernel namespaces sequences system unix unix.statfs.linux
+unix.statvfs.linux ;
 IN: io.unix.files.linux
 
 TUPLE: linux-file-system-info < unix-file-system-info
 namelen spare ;
 
-M: linux new-file-system-info unix-file-system-info new ;
+M: linux new-file-system-info linux-file-system-info new ;
 
 M: linux file-system-statfs ( path -- byte-array )
     "statfs64" <c-object> tuck statfs64 io-error ;
@@ -35,16 +38,6 @@ M: linux statvfs>file-system-info ( struct -- statfs )
         [ statvfs64-f_namemax >>name-max ]
     } cleave ;
 
-M: linux file-systems
-    parse-mtab [
-        [ mount-point>> file-system-info ] keep
-        {
-            [ file-system-name>> >>device-name ]
-            [ mount-point>> >>mount-point ]
-            [ type>> >>type ]
-        } cleave
-    ] map ;
-
 TUPLE: mtab-entry file-system-name mount-point type options
 frequency pass-number ;
 
@@ -65,3 +58,13 @@ frequency pass-number ;
         CHAR: \s delimiter set csv
     ] with-scope
     [ mtab-csv>mtab-entry ] map ;
+
+M: linux file-systems
+    parse-mtab [
+        [ mount-point>> file-system-info ] keep
+        {
+            [ file-system-name>> >>device-name ]
+            [ mount-point>> >>mount-point ]
+            [ type>> >>type ]
+        } cleave
+    ] map ;
diff --git a/basis/unix/statfs/linux/linux.factor b/basis/unix/statfs/linux/linux.factor
index eb587e3286..6550ee572e 100644
--- a/basis/unix/statfs/linux/linux.factor
+++ b/basis/unix/statfs/linux/linux.factor
@@ -1,9 +1,6 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types combinators kernel unix.stat
-math accessors system unix io.backend layouts vocabs.loader
-sequences csv io.streams.string io.encodings.utf8 namespaces
-unix.statfs io.files ;
+USING: alien.syntax ;
 IN: unix.statfs.linux
 
 C-STRUCT: statfs64
diff --git a/basis/unix/statvfs/linux/linux.factor b/basis/unix/statvfs/linux/linux.factor
index 008692a501..3bfbffa197 100644
--- a/basis/unix/statvfs/linux/linux.factor
+++ b/basis/unix/statvfs/linux/linux.factor
@@ -14,7 +14,7 @@ C-STRUCT: statvfs64
     { "__fsfilcnt64_t" "f_favail" }
     { "ulong" "f_fsid" }
     { "ulong" "f_flag" }
-    { "ulong" f_namemax" }
+    { "ulong" "f_namemax" }
     { { "int" 6 } "__f_spare" } ;
 
 FUNCTION: int statvfs64 ( char* path, statvfs64* buf ) ;

From 32dbd07c7781eb824d29a24d7117bf43076df10f Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Mon, 1 Dec 2008 17:51:21 -0600
Subject: [PATCH 6/9] remove empty vocab

---
 extra/line-art/authors.txt | 1 -
 extra/line-art/summary.txt | 1 -
 extra/line-art/tags.txt    | 3 ---
 3 files changed, 5 deletions(-)
 delete mode 100644 extra/line-art/authors.txt
 delete mode 100644 extra/line-art/summary.txt
 delete mode 100644 extra/line-art/tags.txt

diff --git a/extra/line-art/authors.txt b/extra/line-art/authors.txt
deleted file mode 100644
index 6a0dc7293a..0000000000
--- a/extra/line-art/authors.txt
+++ /dev/null
@@ -1 +0,0 @@
-Joe Groff
\ No newline at end of file
diff --git a/extra/line-art/summary.txt b/extra/line-art/summary.txt
deleted file mode 100644
index 06d16da2bf..0000000000
--- a/extra/line-art/summary.txt
+++ /dev/null
@@ -1 +0,0 @@
-Stanford Bunny rendered with cartoon-style lines instead of shading
\ No newline at end of file
diff --git a/extra/line-art/tags.txt b/extra/line-art/tags.txt
deleted file mode 100644
index 0db7e8e629..0000000000
--- a/extra/line-art/tags.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-demos
-opengl
-glsl
\ No newline at end of file

From 439f91bb84dc18b8d64892d210bc93f2c8c53a74 Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Mon, 1 Dec 2008 20:30:52 -0600
Subject: [PATCH 7/9] fix usings

---
 basis/io/unix/files/freebsd/freebsd.factor |  6 +++---
 basis/io/unix/files/openbsd/openbsd.factor | 12 ++++++------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/basis/io/unix/files/freebsd/freebsd.factor b/basis/io/unix/files/freebsd/freebsd.factor
index 48dfd37584..16ef9f61d2 100644
--- a/basis/io/unix/files/freebsd/freebsd.factor
+++ b/basis/io/unix/files/freebsd/freebsd.factor
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax kernel unix math accessors
-combinators system io.backend alien.c-types unix.statfs 
-io.files ;
+USING: accessors alien.c-types alien.syntax combinators
+io.backend io.files io.unix.files kernel math system unix
+unix.statfs unix.statvfs.freebsd ;
 IN: io.unix.files.freebsd
 
 M: freebsd file-system-statvfs ( path -- byte-array )
diff --git a/basis/io/unix/files/openbsd/openbsd.factor b/basis/io/unix/files/openbsd/openbsd.factor
index d348d281fb..bea10de7bb 100644
--- a/basis/io/unix/files/openbsd/openbsd.factor
+++ b/basis/io/unix/files/openbsd/openbsd.factor
@@ -2,16 +2,19 @@
 ! 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
-unix.statfs io.files ;
+unix.statfs io.files io.unix.files unix.statvfs.openbsd ;
 IN: io.unix.files.openbsd
 
-M: openbsd >file-system-info ( file-system-info statvfs -- file-system-info' )
+M: openbsd file-system-statvfs ( normalized-path -- statvfs )
+    "statvfs" <c-object> tuck statvfs io-error ;
+
+M: openbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info' )
     {
         [ statvfs-f_bsize >>block-size ]
         [ statvfs-f_frsize >>preferred-block-size ]
         [ statvfs-f_blocks >>blocks ]
         [ statvfs-f_bfree >>blocks-free ]
-        [ statvfs-f_bavail >>blocks-avail ]
+        [ statvfs-f_bavail >>blocks-available ]
         [ statvfs-f_files >>files ]
         [ statvfs-f_ffree >>files-free ]
         [ statvfs-f_favail >>files-available ]
@@ -19,6 +22,3 @@ M: openbsd >file-system-info ( file-system-info statvfs -- file-system-info' )
         [ statvfs-f_flag >>flags ]
         [ statvfs-f_namemax >>name-max ]
     } cleave ;
-
-M: openbsd file-system-statvfs ( normalized-path -- statvfs )
-    "statvfs" <c-object> tuck statvfs io-error ;

From 7553b816f8f00ba0600d2bcdf901c22660fb495c Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Mon, 1 Dec 2008 21:20:33 -0600
Subject: [PATCH 8/9] add another slot to file-system-info -- available-space,
 which is what the user can actually use, not what's free on disk

---
 basis/io/windows/files/files.factor | 22 +++++++++++++---------
 core/io/files/files.factor          |  2 +-
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/basis/io/windows/files/files.factor b/basis/io/windows/files/files.factor
index 7f84b9d9e5..4c38ee3b12 100755
--- a/basis/io/windows/files/files.factor
+++ b/basis/io/windows/files/files.factor
@@ -257,9 +257,6 @@ M: winnt link-info ( path -- info )
 
 HOOK: root-directory os ( string -- string' )
 
-TUPLE: winnt-file-system-info < file-system-info
-total-bytes total-free-bytes ;
-
 : file-system-type ( normalized-path -- str )
     MAX_PATH 1+ <byte-array>
     MAX_PATH 1+
@@ -269,21 +266,28 @@ total-bytes total-free-bytes ;
     [ GetVolumeInformation win32-error=0/f ] 2keep drop
     utf16n alien>string ;
 
-: file-system-space ( normalized-path -- free-space total-bytes total-free-bytes )
+: file-system-space ( normalized-path -- available-space total-space free-space )
     "ULARGE_INTEGER" <c-object>
     "ULARGE_INTEGER" <c-object>
     "ULARGE_INTEGER" <c-object>
     [ GetDiskFreeSpaceEx win32-error=0/f ] 3keep ;
 
+: calculate-file-system-info ( file-system-info -- file-system-info' )
+    {
+        [ dup [ total-space>> ] [ free-space>> ] bi - >>used-space drop ]
+        [ ]
+    } cleave ;
+
 M: winnt file-system-info ( path -- file-system-info )
     normalize-path root-directory
     dup [ file-system-type ] [ file-system-space ] bi
-    \ winnt-file-system-info new
-        swap *ulonglong >>total-free-bytes
-        swap *ulonglong >>total-bytes
+    \ file-system-info new
         swap *ulonglong >>free-space
+        swap *ulonglong >>total-space
+        swap *ulonglong >>available-space
         swap >>type
-        swap >>mount-point ;
+        swap >>mount-point
+    calculate-file-system-info ;
 
 : volume>paths ( string -- array )
     16384 "ushort" <c-array> tuck dup length
@@ -324,7 +328,7 @@ M: winnt file-systems ( -- array )
     find-volumes [ volume>paths ] map
     concat [
         [ file-system-info ]
-        [ drop winnt-file-system-info new swap >>mount-point ] recover
+        [ drop \ file-system-info new swap >>mount-point ] recover
     ] map ;
 
 : file-times ( path -- timestamp timestamp timestamp )
diff --git a/core/io/files/files.factor b/core/io/files/files.factor
index cd1c5d698c..77b37180c6 100644
--- a/core/io/files/files.factor
+++ b/core/io/files/files.factor
@@ -188,7 +188,7 @@ SYMBOL: +unknown+
 HOOK: file-systems os ( -- array )
 
 TUPLE: file-system-info device-name mount-point type
-free-space used-space total-space ;
+available-space free-space used-space total-space ;
 
 HOOK: file-system-info os ( path -- file-system-info )
 

From c178718bb33f8b3f2e857123504c23c54e8dcbb1 Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Mon, 1 Dec 2008 21:53:30 -0600
Subject: [PATCH 9/9] fix openbsd

---
 basis/io/unix/files/openbsd/openbsd.factor | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/basis/io/unix/files/openbsd/openbsd.factor b/basis/io/unix/files/openbsd/openbsd.factor
index bea10de7bb..68f2e62f40 100644
--- a/basis/io/unix/files/openbsd/openbsd.factor
+++ b/basis/io/unix/files/openbsd/openbsd.factor
@@ -2,7 +2,7 @@
 ! 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
-unix.statfs io.files io.unix.files unix.statvfs.openbsd ;
+io.files io.unix.files unix.statvfs.openbsd ;
 IN: io.unix.files.openbsd
 
 M: openbsd file-system-statvfs ( normalized-path -- statvfs )