haiku-website/static/legacy-docs/bebook/TheStorageKit_DefinedTypes....

126 lines
14 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - Classes And Methods - The Storage Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheStorageKit.html" title="The Storage Kit" /><link rel="prev" href="TheStorageKit_MessageConstants.html" title="Message Constants" /><link rel="next" href="TheSupportKit.html" title="The Support Kit" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="TheStorageKit_MessageConstants.html" title="Message Constants"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheStorageKit.html" title="The Storage Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="TheSupportKit.html" title="The Support Kit"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - Classes And Methods - The Storage Kit</div></div><div id="headerB">Prev: <a href="TheStorageKit_MessageConstants.html">Message Constants</a>  Up: <a href="TheStorageKit.html">The Storage Kit</a>  Next: <a href="TheSupportKit.html">The Support Kit</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheStorageKit_DefinedTypes"></a>Defined Types</h2></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="attr_info"></a>attr_info</h3></div></div></div><a id="id1266339" class="indexterm"></a><p>
Defined In: <code class="filename">kernel/fs_attr.h</code>
</p><pre class="programlisting definition c">typedef struct <span class="type">attr_info</span>
<span class="type">uint32</span> <code class="varname">type</code>;
<span class="type">off_t</span> <code class="varname">size</code>;
} <span class="type">attr_info</span>;</pre><p>
The <span class="type">attr_info</span> structure contains the following members
</p><table class="variablelist fields"><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="varname">type</code></span></p></td><td><p>Is a constant (<code class="constant">B_STRING_TYPE</code>,
<code class="constant">B_INT32_TYPE</code>, etc) that describes
the type of data that the attribute holds.</p></td></tr><tr><td><p><span class="term"><code class="varname">size</code></span></p></td><td><p>Is the size of the attribute's data, in bytes.</p></td></tr></tbody></table></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="stat"></a>stat</h3></div></div></div><a id="id1266453" class="indexterm"></a><p>
Declared in: <code class="filename">posix/sys/stat.h</code>
</p><p>
The <span class="type">stat</span> structure looks like this:
</p><pre class="programlisting definition cpp">struct stat {
<span class="type">dev_t</span> <code class="varname">st_dev</code>;
<span class="type">ino_t</span> <code class="varname">st_ino</code>;
<span class="type">mode_t</span> <code class="varname">st_mode</code>;
<span class="type">nlink_t</span> <code class="varname">st_nlink</code>;
<span class="type">uid_t</span> <code class="varname">st_uid</code>;
<span class="type">gid_t</span> <code class="varname">st_gid</code>;
<span class="type">off_t</span> <code class="varname">st_size</code>;
<span class="type">dev_t</span> <code class="varname">st_rdev</code>;
<span class="type">size_t</span> <code class="varname">st_blksize</code>;
<span class="type">time_t</span> <code class="varname">st_atime</code>;
<span class="type">time_t</span> <code class="varname">st_mtime</code>;
<span class="type">time_t</span> <code class="varname">st_ctime</code>;
} <span class="type">stat</span>;</pre><p>
And the fields are…
</p><table class="variablelist fields"><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="varname">st_dev</code></span></p></td><td><p>Identifies the node's device.</p></td></tr><tr><td><p><span class="term"><code class="varname">st_ino</code></span></p></td><td><p>Is the node's "inode" number.</p></td></tr></tbody></table><p>By combining <code class="varname">st_dev</code> and <code class="varname">st_ino</code>
you can roll your own <span class="type">node_ref</span>:</p><pre class="programlisting example cpp"><span class="type">node_ref</span> <code class="varname">nref</code>;
<span class="type">stat</span> <code class="varname">st</code>;
if (<code class="varname">file</code>.<code class="methodname">GetStat</code>(&amp;<code class="varname">st</code>) == <code class="constant">B_OK</code>) {
<code class="varname">nref.dev</code> = <code class="varname">st.st_dev</code>;
<code class="varname">nref.node</code> = <code class="varname">st.st_ino</code>;
}</pre><p>Meanwhile…</p><table class="variablelist fields"><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="varname">st_mode</code></span></p></td><td><p>Describes the node's flavor: plain file, directory or
symbolic link. To test the field, pass it to the
<code class="function">S_ISREG()</code>,
<code class="function">S_ISDIR()</code>,
and <code class="function">S_ISLNK()</code> boolean macros:</p><pre class="programlisting example cpp">if (<code class="function">S_ISREG</code>(<code class="varname">st.st_mode</code>))
<span class="comment">/* it's a "regular" file */</span>
else if (<code class="function">S_ISDIR</code>(<code class="varname">st.st_mode</code>))
<span class="comment">/* it's a directory */</span>
else if (<code class="function">S_ISLNK</code>(<code class="varname">st.st_mode</code>))
<span class="comment">/* it's a symbolic link */</span></pre></td></tr><tr><td><p><span class="term"><code class="varname">st_nlink</code></span></p></td><td><p>Is the number of "hard links" that point to this node.</p></td></tr><tr><td><p><span class="term"><code class="varname">st_uid</code> and <code class="varname">st_gid</code></span></p></td><td><p>Are the user (owner) and group ids that were described in the
<a class="link" href="BStatable.html#BStatable_GetOwner" title="GetOwner(), SetOwner(), GetGroup(), SetGroup(), GetPermissions(), SetPermissions()"><code class="methodname">GetOwner()</code></a>
function.</p></td></tr><tr><td><p><span class="term"><code class="varname">st_rdev</code></span></p></td><td><p>Is, well, no one really knows. It's provided for System V
compatibility (hold your applause), but it's unused.</p></td></tr><tr><td><p><span class="term"><code class="varname">st_blksize</code></span></p></td><td><p>Is the "preferred block size" that's used during copying.
The <span class="application">cp</span> command line program allocates buffers of
this size when it's copying the file's data.</p></td></tr><tr><td><p><span class="term"><code class="varname">st_atime</code>, <code class="varname">st_mtime</code>, and <code class="varname">st_ctime</code></span></p></td><td><p>Are the access, modification, and creation times in seconds since
January 1, 1970. Access time (<code class="varname">st_atime</code>) is currently
unused.</p></td></tr></tbody></table></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="fs_info"></a>fs_info</h3></div></div></div><a id="id1266899" class="indexterm"></a><p>
The <span class="type">fs_info</span> structure is defined as:
</p><pre class="programlisting definition c">typedef struct <span class="type">fs_info</span> {
<span class="type">dev_t</span> <code class="varname">dev</code>;
<span class="type">ino_t</span> <code class="varname">root</code>;
<span class="type">uint32</span> <code class="varname">flags</code>;
<span class="type">off_t</span> <code class="varname">block_size</code>;
<span class="type">off_t</span> <code class="varname">io_size</code>;
<span class="type">off_t</span> <code class="varname">total_blocks</code>;
<span class="type">off_t</span> <code class="varname">free_blocks</code>;
<span class="type">off_t</span> <code class="varname">total_nodes</code>;
<span class="type">off_t</span> <code class="varname">free_nodes</code>;
<span class="type">char</span> <code class="varname">device_name</code>[128];
<span class="type">char</span> <code class="varname">volume_name</code>[<code class="constant">B_FILE_NAME_LENGTH</code>];
<span class="type">char</span> <code class="varname">fsh_name</code>[<code class="constant">B_OS_NAME_LENGTH</code>];
};</pre><p>
The structure's fields are:
</p><ul class="itemizedlist"><li><p>
<code class="varname">dev</code>. The device number of the device.
</p></li><li><p>
<code class="varname">root</code>. The inode of the root of the device.
</p></li><li><p>
<code class="varname">flags</code>. Flags describing the device's capabilities.
</p></li><li><p>
<code class="varname">block_size</code>. The fundamental block size of the device.
</p></li><li><p>
<code class="varname">io_size</code>. Optimal I/O size of the device.
</p></li><li><p>
<code class="varname">total_blocks</code>. The total number of blocks on the device.
</p></li><li><p>
<code class="varname">free_blocks</code>. The number of free (unused) blocks on the device.
</p></li><li><p>
<code class="varname">total_nodes</code>. The total number of nodes on the device.
</p></li><li><p>
<code class="varname">free_nodes</code>. The number of free (unused) nodes on the device.
</p></li><li><p>
<code class="varname">device_name</code>. Name of the device holding the file system.
</p></li><li><p>
<code class="varname">volume_name</code>. Name of the volume contained by the device.
</p></li><li><p>
<code class="varname">fsh_name</code>. Name of the file system handler for the device.
</p></li></ul><p>
The <code class="varname">flags</code> can be any combination of the following values, which specify
the attributes of the file system on the device:
</p><ul class="itemizedlist"><li><p>
<code class="constant">B_FS_IS_READONLY</code>. The file system on the device is read-only.
</p></li><li><p>
<code class="constant">B_FS_IS_REMOVABLE</code>. The device contains removable media.
</p></li><li><p>
<code class="constant">B_FS_IS_PERSISTENT</code>. Data written to the device remains even while the
device is off.
</p></li><li><p>
<code class="constant">B_FS_IS_SHARED</code>. The file system is being shared on a network.
</p></li><li><p>
<code class="constant">B_FS_HAS_MIME</code>. The file system supports the MIME typing system used
by the BeOS.
</p></li><li><p>
<code class="constant">B_FS_HAS_ATTR</code>. The file system supports node attributes.
</p></li><li><p>
<code class="constant">B_FS_HAS_QUERY</code>. The file system supports the BeOS query mechanism.
</p></li></ul><p>
The information in the <span class="type">fs_info</span> structure is guaranteed to be internally
consistent, but the structure as a whole should be considered to be
out-of-date as soon as you receive it. It provides a picture of a device
as it exists just before the info-retrieving function returns. In
particular, the number of free blocks and of free nodes can easily change
immediately after you receive this information.
</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="TheStorageKit_MessageConstants.html">Message Constants</a>  Up: <a href="TheStorageKit.html">The Storage Kit</a>  Next: <a href="TheSupportKit.html">The Support Kit</a> </div><div id="footerB"><div id="footerBL"><a href="TheStorageKit_MessageConstants.html" title="Message Constants"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheStorageKit.html" title="The Storage Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="TheSupportKit.html" title="The Support Kit"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>