]> gitweb.factorcode.org Git - factor.git/blob - basis/io/files/info/unix/netbsd/netbsd.factor
Specialized array overhaul
[factor.git] / basis / io / files / info / unix / netbsd / netbsd.factor
1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.syntax kernel unix.stat math unix
4 combinators system io.backend accessors alien.c-types
5 io.encodings.utf8 alien.strings unix.types io.files.unix
6 io.files io.files.info unix.statvfs.netbsd unix.getfsstat.netbsd arrays
7 grouping sequences io.encodings.utf8 classes.struct
8 specialized-arrays io.files.info.unix ;
9 SPECIALIZED-ARRAY: statvfs
10 IN: io.files.info.unix.netbsd
11
12 TUPLE: netbsd-file-system-info < unix-file-system-info
13 blocks-reserved files-reserved
14 owner io-size sync-reads sync-writes async-reads async-writes
15 idx mount-from ;
16
17 M: netbsd new-file-system-info netbsd-file-system-info new ;
18
19 M: netbsd file-system-statvfs
20     \ statvfs <struct> [ statvfs io-error ] keep ;
21
22 M: netbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info' )
23     {
24         [ f_flag>> >>flags ]
25         [ f_bsize>> >>block-size ]
26         [ f_frsize>> >>preferred-block-size ]
27         [ f_iosize>> >>io-size ]
28         [ f_blocks>> >>blocks ]
29         [ f_bfree>> >>blocks-free ]
30         [ f_bavail>> >>blocks-available ]
31         [ f_bresvd>> >>blocks-reserved ]
32         [ f_files>> >>files ]
33         [ f_ffree>> >>files-free ]
34         [ f_favail>> >>files-available ]
35         [ f_fresvd>> >>files-reserved ]
36         [ f_syncreads>> >>sync-reads ]
37         [ f_syncwrites>> >>sync-writes ]
38         [ f_asyncreads>> >>async-reads ]
39         [ f_asyncwrites>> >>async-writes ]
40         [ f_fsidx>> >>idx ]
41         [ f_fsid>> >>id ]
42         [ f_namemax>> >>name-max ]
43         [ f_owner>> >>owner ]
44         [ f_fstypename>> utf8 alien>string >>type ]
45         [ f_mntonname>> utf8 alien>string >>mount-point ]
46         [ f_mntfromname>> utf8 alien>string >>device-name ]
47     } cleave ;
48
49 M: netbsd file-systems ( -- array )
50     f 0 0 getvfsstat dup io-error
51     <statvfs-array>
52     [ dup byte-length 0 getvfsstat io-error ]
53     [ [ f_mntonname>> utf8 alien>string file-system-info ] { } map-as ] bi ;