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

40 lines
1.1 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-10-20 02:55:40 -04:00
USING: alien.c-types combinators kernel io.files 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-10-22 20:54:22 -04:00
M: linux mounted
parse-mtab [
mount-point>>
[ file-system-info ] keep >>name
] map ;