]> gitweb.factorcode.org Git - factor.git/blob - basis/io/files/info/unix/openbsd/openbsd.factor
Merge branch 'master' of git://factorcode.org/git/factor into struct-updates
[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 struct-arrays
8 io.encodings.utf8 ;
9 IN: io.files.unix.openbsd
10
11 TUPLE: freebsd-file-system-info < unix-file-system-info
12 io-size sync-writes sync-reads async-writes async-reads 
13 owner ;
14
15 M: openbsd new-file-system-info freebsd-file-system-info new ;
16
17 M: openbsd file-system-statfs
18     \ statfs <struct> [ statfs io-error ] keep ;
19
20 M: openbsd statfs>file-system-info ( file-system-info statfs -- file-system-info' )
21     {
22         [ f_flags>> >>flags ]
23         [ f_bsize>> >>block-size ]
24         [ f_iosize>> >>io-size ]
25         [ f_blocks>> >>blocks ]
26         [ f_bfree>> >>blocks-free ]
27         [ f_bavail>> >>blocks-available ]
28         [ f_files>> >>files ]
29         [ f_ffree>> >>files-free ]
30         [ f_favail>> >>files-available ]
31         [ f_syncwrites>> >>sync-writes ]
32         [ f_syncreads>> >>sync-reads ]
33         [ f_asyncwrites>> >>async-writes ]
34         [ f_asyncreads>> >>async-reads ]
35         [ f_fsid>> >>id ]
36         [ f_namemax>> >>name-max ]
37         [ f_owner>> >>owner ]
38         [ f_fstypename>> utf8 alien>string >>type ]
39         [ f_mntonname>> utf8 alien>string >>mount-point ]
40         [ f_mntfromname>> utf8 alien>string >>device-name ]
41     } cleave ;
42
43 M: openbsd file-system-statvfs ( normalized-path -- statvfs )
44     \ statvfs <struct> [ statvfs io-error ] keep ;
45
46 M: openbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info' )
47     f_frsize>> >>preferred-block-size ;
48
49 M: openbsd file-systems ( -- seq )
50     f 0 0 getfsstat dup io-error
51     \ statfs <struct-array>
52     [ dup length 0 getfsstat io-error ]
53     [ [ f_mntonname>> utf8 alien>string file-system-info ] map ] bi ;