168 lines
5.2 KiB
HTML
168 lines
5.2 KiB
HTML
|
<!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>
|
||
|
Syntax<br>
|
||
|
|
||
|
|
||
|
<pre>
|
||
|
#include <sys/stat.h>
|
||
|
|
||
|
int fstat64(int <em>fildes</em>, struct stat64 <em>*buf</em>);
|
||
|
</pre>
|
||
|
|
||
|
Service Program Name: QP0LLIB1<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Default Public Authority: *USE<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
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><sys/stat.h></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 <sys/types.h>
|
||
|
#include <sys/stat.h>
|
||
|
#include <fcntl.h>
|
||
|
#include <stdio.h>
|
||
|
#include <time.h>
|
||
|
|
||
|
main() {
|
||
|
char fn[]="temp.file";
|
||
|
struct stat64 info;
|
||
|
int file_descriptor;
|
||
|
|
||
|
if ((file_descriptor = creat64(fn, S_IWUSR)) < 0)
|
||
|
perror("creat64() error");
|
||
|
else {
|
||
|
if (ftruncate64(file_descriptor, 8589934662) != 0)
|
||
|
perror("ftruncate64() error");
|
||
|
else {
|
||
|
if (fstat64(file_descriptor, &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>
|
||
|
|