]> gitweb.factorcode.org Git - factor.git/blob - basis/io/files/info/unix/openbsd/openbsd.factor
try to fix file-systems on a few platforms
[factor.git] / basis / io / files / info / unix / 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.files.info io.files.unix kernel math
5 sequences system unix unix.getfsstat.openbsd grouping
6 unix.statfs.openbsd unix.statvfs.openbsd unix.types
7 arrays io.files.info.unix classes.struct ;
8 IN: io.files.unix.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 <struct> [ statfs io-error ] keep ;
18
19 M: openbsd statfs>file-system-info ( file-system-info statfs -- file-system-info' )
20     {
21         [ f_flags>> >>flags ]
22         [ f_bsize>> >>block-size ]
23         [ f_iosize>> >>io-size ]
24         [ f_blocks>> >>blocks ]
25         [ f_bfree>> >>blocks-free ]
26         [ f_bavail>> >>blocks-available ]
27         [ f_files>> >>files ]
28         [ f_ffree>> >>files-free ]
29         [ f_favail>> >>files-available ]
30         [ f_syncwrites>> >>sync-writes ]
31         [ f_syncreads>> >>sync-reads ]
32         [ f_asyncwrites>> >>async-writes ]
33         [ f_asyncreads>> >>async-reads ]
34         [ f_fsid>> >>id ]
35         [ f_namemax>> >>name-max ]
36         [ f_owner>> >>owner ]
37         [ f_fstypename>> alien>native-string >>type ]
38         [ f_mntonname>> alien>native-string >>mount-point ]
39         [ f_mntfromname>> alien>native-string >>device-name ]
40     } cleave ;
41
42 M: openbsd file-system-statvfs ( normalized-path -- statvfs )
43     \ statvfs <struct> [ statvfs io-error ] keep ;
44
45 M: openbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info' )
46     f_frsize>> >>preferred-block-size ;
47
48 M: openbsd file-systems ( -- seq )
49     f 0 0 getfsstat dup io-error
50     \ statfs <c-type-array>
51     [ dup length 0 getvfsstat io-error ]
52     [ [ f_mntonname>> utf8 alien>string file-system-info ] map ] bi ;