<commit_before>! Copyright (C) 2008 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.strings alien.syntax
combinators io.backend io.files io.files.info io.files.unix kernel math
sequences system unix unix.getfsstat.openbsd grouping
unix.statfs.openbsd unix.statvfs.openbsd unix.types
arrays io.files.info.unix classes.struct
specialized-arrays io.encodings.utf8 ;
SPECIALIZED-ARRAY: statvfs
IN: io.files.unix.openbsd

TUPLE: openbsd-file-system-info < unix-file-system-info
io-size sync-writes sync-reads async-writes async-reads 
owner ;

M: openbsd new-file-system-info openbsd-file-system-info new ;

M: openbsd file-system-statfs
    \ statfs <struct> [ statfs io-error ] keep ;

M: openbsd statfs>file-system-info ( file-system-info statfs -- file-system-info' )
    {
        [ f_flags>> >>flags ]
        [ f_bsize>> >>block-size ]
        [ f_iosize>> >>io-size ]
        [ f_blocks>> >>blocks ]
        [ f_bfree>> >>blocks-free ]
        [ f_bavail>> >>blocks-available ]
        [ f_files>> >>files ]
        [ f_ffree>> >>files-free ]
        [ f_favail>> >>files-available ]
        [ f_syncwrites>> >>sync-writes ]
        [ f_syncreads>> >>sync-reads ]
        [ f_asyncwrites>> >>async-writes ]
        [ f_asyncreads>> >>async-reads ]
        [ f_fsid>> >>id ]
        [ f_namemax>> >>name-max ]
        [ f_owner>> >>owner ]
        [ f_fstypename>> utf8 alien>string >>type ]
        [ f_mntonname>> utf8 alien>string >>mount-point ]
        [ f_mntfromname>> utf8 alien>string >>device-name ]
    } cleave ;

M: openbsd file-system-statvfs ( normalized-path -- statvfs )
    \ statvfs <struct> [ statvfs io-error ] keep ;

M: openbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info' )
    f_frsize>> >>preferred-block-size ;

M: openbsd file-systems ( -- seq )
    f 0 0 getfsstat dup io-error
    <statvfs-array>
    [ dup byte-length 0 getfsstat io-error ]
    [ [ f_mntonname>> utf8 alien>string file-system-info ] { } map-as ] bi ;<commit_msg>list file-systems with statfs instead of statvfs on openbsd<commit_after>! Copyright (C) 2008 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.strings alien.syntax
combinators io.backend io.files io.files.info io.files.unix kernel math
sequences system unix unix.getfsstat.openbsd grouping
unix.statfs.openbsd unix.statvfs.openbsd unix.types
arrays io.files.info.unix classes.struct
specialized-arrays io.encodings.utf8 ;
SPECIALIZED-ARRAY: statvfs
IN: io.files.unix.openbsd

TUPLE: openbsd-file-system-info < unix-file-system-info
io-size sync-writes sync-reads async-writes async-reads 
owner ;

M: openbsd new-file-system-info openbsd-file-system-info new ;

M: openbsd file-system-statfs
    \ statfs <struct> [ statfs io-error ] keep ;

M: openbsd statfs>file-system-info ( file-system-info statfs -- file-system-info' )
    {
        [ f_flags>> >>flags ]
        [ f_bsize>> >>block-size ]
        [ f_iosize>> >>io-size ]
        [ f_blocks>> >>blocks ]
        [ f_bfree>> >>blocks-free ]
        [ f_bavail>> >>blocks-available ]
        [ f_files>> >>files ]
        [ f_ffree>> >>files-free ]
        [ f_favail>> >>files-available ]
        [ f_syncwrites>> >>sync-writes ]
        [ f_syncreads>> >>sync-reads ]
        [ f_asyncwrites>> >>async-writes ]
        [ f_asyncreads>> >>async-reads ]
        [ f_fsid>> >>id ]
        [ f_namemax>> >>name-max ]
        [ f_owner>> >>owner ]
        [ f_fstypename>> utf8 alien>string >>type ]
        [ f_mntonname>> utf8 alien>string >>mount-point ]
        [ f_mntfromname>> utf8 alien>string >>device-name ]
    } cleave ;

M: openbsd file-system-statvfs ( normalized-path -- statvfs )
    \ statvfs <struct> [ statvfs io-error ] keep ;

M: openbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info' )
    f_frsize>> >>preferred-block-size ;

M: openbsd file-systems ( -- seq )
    f 0 0 getfsstat dup io-error
    <statfs-array>
    [ dup byte-length 0 getfsstat io-error ]
    [ [ f_mntonname>> utf8 alien>string file-system-info ] { } map-as ] bi ;
{'fraction_non_alphanumeric': 0.14009194289862087, 'fraction_numerical': 0.005806919912896201, 'mean_word_length': 2.8853383458646618, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 187, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4618844', 'n_tokens_mistral': 1524, 'n_tokens_neox': 1457, 'n_words': 312}