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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.77C-CCK-MCD Caldera Systems OpenLinux [en] (X11; U; Linux 2.4.2 i686) [Netscape]">
</head>
<body>
<b><font face="Arial,Helvetica">DESCRIPTION</font></b>
<blockquote>This is a Ruby extension for file-system information, using
the <tt>statvfs</tt> and <tt>getmntent</tt> system calls. Tested on Linux
and Solaris Version 0.3</blockquote>
<p><br><b><font face="Arial,Helvetica">MODULE</font></b>
<blockquote><tt>require 'filesystem'</tt>
<br><tt>FileSystem.stat( </tt><i>path</i><tt> )</tt></blockquote>
<blockquote><tt>Struct FileSystemStat</tt>
<br>
<table CELLSPACING=0 CELLPADDING=0 NOSAVE >
<tr NOSAVE>
<td><tt><i>s</i>.path</tt></td>
<td>directory path provided</td>
</tr>
<tr NOSAVE>
<td><tt><i>s</i>.block_size</tt></td>
<td>optimal transfer block size</td>
</tr>
<tr NOSAVE>
<td><tt><i>s</i>.blocks</tt></td>
<td>total number of data blocks in file system</td>
</tr>
<tr>
<td><tt><i>s</i>.blocks_free</tt></td>
<td>number of free blocks in file system</td>
</tr>
<tr>
<td><tt><i>s</i>.blocks_avail</tt></td>
<td>number of free blocks available to non-super-user</td>
</tr>
<tr>
<td><tt><i>s</i>.files</tt></td>
<td>total number of file nodes in file system</td>
</tr>
<tr>
<td><tt><i>s</i>.files_free</tt></td>
<td>number of free file nodes in file system</td>
</tr>
<tr>
<td><tt><i>s</i>.files_avail</tt></td>
<td>number of free file nodes available to non-super-user</td>
</tr>
<tr>
<td><tt><i>s</i>.flags</tt></td>
<td>file system flags</td>
</tr>
<tr>
<td><tt><i>s</i>.maxnamelen</tt></td>
<td>maximum file name length</td>
</tr>
</table>
<p><tt>FileSystem.mounts( </tt><i>file</i><tt> )</tt>
<br><tt>FileSystem.mounts( </tt><i>file</i><tt> ) { |</tt><i>mt</i><tt>|
</tt><i>block</i><tt>
}</tt>
<p>The default mount-table filename is <tt>/etc/mtab</tt> on Linux, and
<tt>/etc/mnttab</tt>
on Solaris. On Linux, this can be used to scan <tt>/etc/fstab</tt> also.
<p><tt>Struct FileSystemMount</tt>
<br>
<table CELLSPACING=0 CELLPADDING=0 NOSAVE >
<tr NOSAVE>
<td><tt><i>m</i>.device</tt></td>
<td>file system (i.e. partition device) name</td>
</tr>
<tr>
<td><tt><i>m</i>.mount</tt></td>
<td>mount point directory</td>
</tr>
<tr>
<td><tt><i>m</i>.fstype</tt></td>
<td>file system type m.options mount options</td>
</tr>
<tr>
<td><tt><i>m</i>.time</tt></td>
<td>time the filesystem was mounted (Solaris)</td>
</tr>
<tr>
<td><tt><i>m</i>.dump_interval</tt></td>
<td>dump frequency in days (Linux/BSD)</td>
</tr>
<tr>
<td><tt><i>m</i>.check_pass</tt></td>
<td>pass number of file system check (Linux/BSD)</td>
</tr>
</table>
<p>Constants for <tt>FileSystem.stat.flags</tt>
<ul>
<li>
Solaris: <tt>RDONLY NOSUID NOTRUNC</tt></li>
<li>
Linux: <tt>RDONLY NOSUID</tt></li>
<li>
GNU: <tt>RDONLY NOSUID NODEV NOEXE SYNC MANDLOCK WRITE APPEND IMMUTABLE
NOATIME NODIRATIME</tt></li>
</ul>
</blockquote>
<p><br><b><font face="Arial,Helvetica">EXAMPLES</font></b>
<blockquote><tt>require 'filesystem'</tt>
<br><tt>s = FileSystem.stat '/tmp'</tt>
<br><tt>puts "#{s.path} #{s.blocks_avail}"</tt>
<p><tt>puts "Mounted FileSystems:"</tt>
<br><tt>FileSystem.mounts.each do |m|</tt>
<br><tt> puts "#{m.device} #{m.mount} #{m.fstype}"</tt>
<br><tt>end</tt></blockquote>
<p><br><b><font face="Arial,Helvetica">INSTALL</font></b>
<blockquote><tt>ruby extconf.rb</tt>
<br><tt>make</tt>
<br><tt>ruby Test.rb <i>(optional directories)</i></tt>
<br><tt>make install</tt></blockquote>
<p><br><b><tt><font face="Arial,Helvetica">DOCUMENTATION</font></tt></b>
<blockquote>The<tt> FileSystem.ri </tt>file is a source description
file for the <tt>ri </tt>command. Copy it to your <tt>ri/srcdesc</tt> source
directory as <tt>FileSystem.rb</tt>, and regenerate the binary description
files that <tt>ri</tt> uses. See the <tt>ri README</tt> for details.</blockquote>
<p><br><b><font face="Arial,Helvetica">TODO</font></b>
<blockquote>
<ul>
<li>Move this "documentation" into the source.</li>
<li>Convert st.flags from a number to an array of strings.</li>
<li>Solicit patches for all other UNIXes.</li>
</ul>
</blockquote>
<p><br><b><font face="Arial,Helvetica">ACKNOWLEDGEMENTS</font></b>
<blockquote>
Daniel Berger for testing on Solaris, and motivation.
<br>
comp.lang.ruby for suggesting better names.
</blockquote>
<p><br><b><font face="Arial,Helvetica">AUTHOR</font></b>
<blockquote>Mike Hall
<br>mghall@enteract.com
<br>www.enteract.com/~mghall
<br>2002-05-02</blockquote>
</body>
</html>
|