ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/fstat64.htm

168 lines
5.2 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>fstat64()--Get File Information by Descriptor (Large File
Enabled)</title>
<!-- Begin Header Records ========================================== -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- file cleaned -->
<!-- Unix2 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
<!-- Change History: -->
<!-- 011022 JTROUS Changes from API Review 1, V5R2 -->
<!-- This file has undergone html cleanup on 05/14/02 by JET -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!--End Header Records --><!-- Java sync-link -->
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
</script>
<a name="Top_Of_Page"></a>
<h2>fstat64()--Get File Information by Descriptor (Large File Enabled)</h2>
<div class="box" style="width: 70%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;sys/stat.h&gt;
int fstat64(int <em>fildes</em>, struct stat64 <em>*buf</em>);
</pre>
&nbsp;&nbsp;Service Program Name: QP0LLIB1<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Conditional; see <a href="#USAGE_NOTES">Usage Notes</a>.<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>fstat64()</strong> function gets status information about the
file specified by the open file descriptor <em>file_descriptor</em> and stores
the information in the area of memory indicated by the <em>buf</em> argument.
The status information is returned in a <samp>stat64</samp> structure, as
defined in the <strong>&lt;sys/stat.h&gt;</strong> header file.</p>
<p><strong>fstat64()</strong> is enabled for large files. It is capable of
operating on files larger than 2GB minus 1 byte as long as the file has been
opened by either of the following:</p>
<ul compact>
<li>Using the <strong>open64()</strong> function (see <a href="open64.htm">
open64()--Open File (Large File Enabled)</a>).</li>
<li>Using the <strong>open()</strong> function (see <a href="open.htm">
open()--Open File</a>) with O_LARGEFILE set in the oflag parameter.</li>
</ul>
<p>The elements of the <samp>stat64</samp> structure are described in <a href=
"stat64.htm">stat64()--Get File Information (Large File Enabled)</a>.</p>
<p>For additional information about parameters, authorities required, and error
conditions, see <a href="fstat.htm">fstat()--Get File Information by
Descriptor</a>.</p>
<br>
<h3><a name="usage_notes">Usage Notes</a></h3>
<ol type="1">
<li>When you develop in C-based languages, the prototypes for the 64-bit APIs
are normally hidden. To use the <strong>fstat64()</strong> API and the <samp>
struct stat64</samp> data type, you must compile the source with the
_LARGE_FILE_API macro defined.<br>
</li>
<li>All of the usage notes for <strong>fstat()</strong> apply to <strong>
fstat64()</strong>. See <a href="fstat.htm#HDRFSTAUSG">Usage Notes</a> in the
<strong>fstat()</strong> API.</li>
</ol>
<br>
<h3>Example</h3>
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
for information pertaining to code examples.</p>
<p>The following example gets status information:</p>
<pre>
#define _LARGE_FILE_API
#include &lt;sys/types.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;fcntl.h&gt;
#include &lt;stdio.h&gt;
#include &lt;time.h&gt;
main() {
char fn[]="temp.file";
struct stat64 info;
int file_descriptor;
if ((file_descriptor = creat64(fn, S_IWUSR)) &lt; 0)
perror("creat64() error");
else {
if (ftruncate64(file_descriptor, 8589934662) != 0)
perror("ftruncate64() error");
else {
if (fstat64(file_descriptor, &amp;info) != 0)
perror("fstat64() error");
else {
puts("fstat64() returned:");
printf(" inode: %d\n", (int) info.st_ino);
printf(" dev id: %d\n", (int) info.st_dev);
printf(" mode: %08x\n", info.st_mode);
printf(" links: %d\n", info.st_nlink);
printf(" uid: %d\n", (int) info.st_uid);
printf(" gid: %d\n", (int) info.st_gid);
printf(" size: %lld\n", (long long) info.st_size);
}
}
close(file_descriptor);
unlink(fn);
}
}
</pre>
<p><strong>Output:</strong> Note that the output may vary from system to
system.</p>
<pre>
fstat64() returned:
inode: 3057
dev id: 1
mode: 03000080
links: 1
uid: 137
gid: 500
size: 8589934662
</pre>
<br>
<hr>
API introduced: V4R4
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
</tr>
</table>
</center>
</body>
</html>