DESCRIPTION

> This is a Ruby extension for file-system information, using the `statvfs` and `getmntent` system calls. Tested on Linux and Solaris Version 0.3

MODULE

> `require 'filesystem'`
> `FileSystem.stat(` path`)`

> `Struct FileSystemStat`

> `s.path` | directory path provided
> `s.block_size` | optimal transfer block size
> `s.blocks` | total number of data blocks in file system
> `s.blocks_free` | number of free blocks in file system
> `s.blocks_avail` | number of free blocks available to non-super-user
> `s.files` | total number of file nodes in file system
> `s.files_free` | number of free file nodes in file system
> `s.files_avail` | number of free file nodes available to non-super-user
> `s.flags` | file system flags
> `s.maxnamelen` | maximum file name length

> `FileSystem.mounts(` file`)`
> `FileSystem.mounts(` file`) { |`mt`|` block`}`

> The default mount-table filename is `/etc/mtab` on Linux, and `/etc/mnttab` on Solaris. On Linux, this can be used to scan `/etc/fstab` also.

> `Struct FileSystemMount`

> `m.device` | file system (i.e. partition device) name
> `m.mount` | mount point directory
> `m.fstype` | file system type m.options mount options
> `m.time` | time the filesystem was mounted (Solaris)
> `m.dump_interval` | dump frequency in days (Linux/BSD)
> `m.check_pass` | pass number of file system check (Linux/BSD)

> Constants for `FileSystem.stat.flags`

> - Solaris: `RDONLY NOSUID NOTRUNC`
> - Linux: `RDONLY NOSUID`
> - GNU: `RDONLY NOSUID NODEV NOEXE SYNC MANDLOCK WRITE APPEND IMMUTABLE NOATIME NODIRATIME`

EXAMPLES

> `require 'filesystem'`
> `s = FileSystem.stat '/tmp'`
> `puts "#{s.path} #{s.blocks_avail}"`

> `puts "Mounted FileSystems:"`
> `FileSystem.mounts.each do |m|`
> `puts "#{m.device} #{m.mount} #{m.fstype}"`
> `end`

INSTALL

> `ruby extconf.rb`
> `make`
> `ruby Test.rb (optional directories)`
> `make install`

`DOCUMENTATION`

> The`FileSystem.ri` file is a source description file for the `ri` command. Copy it to your `ri/srcdesc` source directory as `FileSystem.rb`, and regenerate the binary description files that `ri` uses. See the `ri README` for details.

TODO

> - Move this "documentation" into the source.
> - Convert st.flags from a number to an array of strings.
> - Solicit patches for all other UNIXes.

ACKNOWLEDGEMENTS

> Daniel Berger for testing on Solaris, and motivation.
> comp.lang.ruby for suggesting better names.

AUTHOR

> Mike Hall
> mghall@enteract.com
> www.enteract.com/~mghall
> 2002-05-02