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