diff --git a/basis/unix/statfs/linux/linux.factor b/basis/unix/statfs/linux/linux.factor index b4413fba15..94ed8cb8cf 100644 --- a/basis/unix/statfs/linux/linux.factor +++ b/basis/unix/statfs/linux/linux.factor @@ -8,3 +8,27 @@ cell-bits { { 32 [ "unix.statfs.linux.32" require ] } { 64 [ "unix.statfs.linux.64" require ] } } case + +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 csv first >>options ] + [ 4 swap nth >>frequency ] + [ 5 swap nth >>pass-number ] + } cleave ; + +: parse-mtab ( -- array ) + [ + "/etc/mtab" utf8 + CHAR: \s delimiter set csv + ] with-scope + [ mtab-csv>mtab-entry ] map ; + +M: linux mounted* + parse-mtab [ mount-point>> >file-system-info ] map ; diff --git a/basis/unix/statfs/macosx/macosx.factor b/basis/unix/statfs/macosx/macosx.factor index 048c292cea..4bd9f55132 100644 --- a/basis/unix/statfs/macosx/macosx.factor +++ b/basis/unix/statfs/macosx/macosx.factor @@ -128,9 +128,6 @@ M: macosx mounted* ( -- array ) [ *void* ] dip "statfs64" heap-size [ * memory>byte-array ] keep group ; -M: macosx >mounted - >file-system-info ; - M: macosx >file-system-info ( byte-array -- file-system-info ) [ \ macosx-file-system-info new ] dip { diff --git a/basis/unix/statfs/statfs.factor b/basis/unix/statfs/statfs.factor index 9aef2246c0..cfa0c159d1 100644 --- a/basis/unix/statfs/statfs.factor +++ b/basis/unix/statfs/statfs.factor @@ -16,7 +16,7 @@ TUPLE: file-system-info root-directory total-free-size total-size ; HOOK: >file-system-info os ( struct -- statfs ) -: mounted ( -- array ) mounted* [ >mounted ] map ; +: mounted ( -- array ) mounted* [ >file-system-info ] map ; : mounted-drive ( path -- mounted/f ) mounted