1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
DESCRIPTION
This is a Ruby extension for file-system information,
using the 'statvfs' and 'getmntent' system calls.
Tested on Linux and Solaris
Version 0.5
MODULE
module 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( optional file name )
FileSystem.mounts( optional file name ) { |mt| optional 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
INSTALL
ruby extconf.rb
make
ruby Test.rb (optional directories)
make install
DOCUMENTATION
The file 'FileSystem.ri' 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 other UNIXen.
ACKNOWLEDGEMENTS
Daniel Berger for testing on Solaris, and motivation.
comp.lang.ruby for suggesting better names.
Dmitry Borodaenko for finding a bug (by testing on IA64 Debian)
AUTHOR
Mike Hall
mghall@enteract.com
www.enteract.com/~mghall
2003-09-04
|