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

165 lines
5.1 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>lstat64()--Get File or Link Information (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. -->
<!-- Change History: -->
<!-- YYMMDD USERID Change description -->
<!-- file cleaned -->
<!-- Unix2 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
<!-- 011022 JTROUS Changes from API Review 1, V5R2 -->
<!-- This file has undergone html cleanup May 2002 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>lstat64()--Get File or Link Information (Large File Enabled)</h2>
<div class="box" style="width: 70%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;sys/stat.h&gt;
int lstat64(const char <em>*path</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 Usage Notes for <a href="lstat.htm">lstat()</a>.<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>lstat64()</strong> function gets status information about a
specified file and places it in the area of memory pointed to by <em>buf</em>.
If the named file is a symbolic link, <strong>lstat64()</strong> returns
information about the symbolic link itself.</p>
<p>The information is returned in the <samp>stat64</samp> structure, referred
to by <em>buf</em>. For details on the <samp>stat64</samp> structure, see <a
href="stat64.htm">stat64()--Get File Information (Large File Enabled)</a>.</p>
<p>If the named file is not a symbolic link, <strong>lstat64()</strong> updates
the time-related fields before putting information in the <samp>stat64</samp>
structure.</p>
<p>For additional information about parameters, authorities required, and error
conditions, see <a href="lstat.htm">lstat()--Get File or Link
Information</a>.</p>
<p>See <a href="lstat64u.htm">QlgLstat64()--Get File or Link Information (Large
File Enabled)</a> for a description and an example of supplying the <em>
path</em> in any CCSID.</p>
<br>
<h3>Usage Notes</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>lstat64()</strong> API and the <samp>
struct stat64</samp> data type, you must compile the source with the
_LARGE_FILE_API defined.<br>
<br>
</li>
<li>All of the usage notes for <strong>lstat()</strong> apply to <strong>
lstat64()</strong>. See <a href="lstat.htm#HDRLSTAUSG">Usage Notes</a> in the
<strong>lstat()</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 provides status information for a file.</p>
<pre>
#define _LARGE_FILE_API
#include &lt;sys/types.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;stdio.h&gt;
#include &lt;fcntl.h&gt;
#include &lt;unistd.h&gt;
#include &lt;time.h&gt;
#include &lt;stdio.h&gt;
main() {
char fn[]="temp.file", ln[]="temp.link";
struct stat64 info;
int file_descriptor;
if ((file_descriptor = creat64(fn, S_IWUSR)) &lt; 0)
perror("creat64() error");
else {
close(file_descriptor);
if (link(fn, ln) != 0)
perror("link() error");
else {
if (lstat64(ln, &amp;info) != 0)
perror("lstat64() error");
else {
puts("lstat64() 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);
}
unlink(ln);
}
unlink(fn);
}
}
</pre>
<p><strong>Output:</strong></p>
<pre>
lstat() returned:
inode: 3022
dev id: 1
mode: 00008080
links: 2
uid: 137
gid: 500
size: 18
</pre>
<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>