]> gitweb.factorcode.org Git - factor.git/blob - basis/io/unix/files/openbsd/openbsd.factor
Merge branch 'master' into experimental (untested!)
[factor.git] / basis / io / unix / files / openbsd / openbsd.factor
1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.c-types alien.strings alien.syntax
4 combinators io.backend io.files io.unix.files kernel math
5 sequences system unix unix.getfsstat.openbsd grouping
6 unix.statfs.openbsd unix.statvfs.openbsd unix.types
7 specialized-arrays.direct.uint arrays ;
8 IN: io.unix.files.openbsd
9
10 TUPLE: freebsd-file-system-info < unix-file-system-info
11 io-size sync-writes sync-reads async-writes async-reads 
12 owner ;
13
14 M: openbsd new-file-system-info freebsd-file-system-info new ;
15
16 M: openbsd file-system-statfs
17     "statfs" <c-object> tuck statfs io-error ;
18
19 M: openbsd statfs>file-system-info ( file-system-info statfs -- file-system-info' )
20     {
21         [ statfs-f_flags >>flags ]
22         [ statfs-f_bsize >>block-size ]
23         [ statfs-f_iosize >>io-size ]
24         [ statfs-f_blocks >>blocks ]
25         [ statfs-f_bfree >>blocks-free ]
26         [ statfs-f_bavail >>blocks-available ]
27         [ statfs-f_files >>files ]
28         [ statfs-f_ffree >>files-free ]
29         [ statfs-f_favail >>files-available ]
30         [ statfs-f_syncwrites >>sync-writes ]
31         [ statfs-f_syncreads >>sync-reads ]
32         [ statfs-f_asyncwrites >>async-writes ]
33         [ statfs-f_asyncreads >>async-reads ]
34         [ statfs-f_fsid 2 <direct-uint-array> >array >>id ]
35         [ statfs-f_namemax >>name-max ]
36         [ statfs-f_owner >>owner ]
37         ! [ statfs-f_spare >>spare ]
38         [ statfs-f_fstypename alien>native-string >>type ]
39         [ statfs-f_mntonname alien>native-string >>mount-point ]
40         [ statfs-f_mntfromname alien>native-string >>device-name ]
41     } cleave ;
42
43 M: openbsd file-system-statvfs ( normalized-path -- statvfs )
44     "statvfs" <c-object> tuck statvfs io-error ;
45
46 M: openbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info' )
47     {
48         [ statvfs-f_frsize >>preferred-block-size ]
49     } cleave ;
50
51 M: openbsd file-systems ( -- seq )
52     f 0 0 getfsstat dup io-error
53     "statfs" <c-array> dup dup length 0 getfsstat io-error 
54     "statfs" heap-size group 
55     [ statfs-f_mntonname alien>native-string file-system-info ] map ;