factor/basis/unix/statfs/linux/linux.factor

44 lines
1.2 KiB
Factor
Raw Normal View History

2008-10-20 01:47:51 -04:00
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
2008-11-11 16:37:32 -05:00
USING: alien.c-types combinators kernel unix.stat
2008-10-22 20:54:22 -04:00
math accessors system unix io.backend layouts vocabs.loader
sequences csv io.streams.string io.encodings.utf8 namespaces
unix.statfs io.files ;
2008-10-20 01:47:51 -04:00
IN: unix.statfs.linux
2008-10-21 04:11:26 -04:00
cell-bits {
2008-10-21 00:43:36 -04:00
{ 32 [ "unix.statfs.linux.32" require ] }
{ 64 [ "unix.statfs.linux.64" require ] }
2008-10-21 04:11:26 -04:00
} case
2008-10-22 20:01:45 -04:00
TUPLE: mtab-entry file-system-name mount-point type options
frequency pass-number ;
: mtab-csv>mtab-entry ( csv -- mtab-entry )
[ mtab-entry new ] dip
{
[ first >>file-system-name ]
[ second >>mount-point ]
[ third >>type ]
[ fourth <string-reader> csv first >>options ]
[ 4 swap nth >>frequency ]
[ 5 swap nth >>pass-number ]
} cleave ;
: parse-mtab ( -- array )
[
"/etc/mtab" utf8 <file-reader>
CHAR: \s delimiter set csv
] with-scope
[ mtab-csv>mtab-entry ] map ;
2008-11-11 14:30:12 -05:00
M: linux file-systems
parse-mtab [
[ mount-point>> file-system-info ] keep
{
[ file-system-name>> >>device-name ]
2008-10-23 14:18:00 -04:00
[ mount-point>> >>mount-point ]
[ type>> >>type ]
} cleave
] map ;