lstat64()--Get File or Link Information (Large File Enabled)


  Syntax
 #include <sys/stat.h>

 int lstat64(const char *path, struct stat64 *buf);  
  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

  Threadsafe: Conditional; see Usage Notes for lstat().

The lstat64() function gets status information about a specified file and places it in the area of memory pointed to by buf. If the named file is a symbolic link, lstat64() returns information about the symbolic link itself.

The information is returned in the stat64 structure, referred to by buf. For details on the stat64 structure, see stat64()--Get File Information (Large File Enabled).

If the named file is not a symbolic link, lstat64() updates the time-related fields before putting information in the stat64 structure.

For additional information about parameters, authorities required, and error conditions, see lstat()--Get File or Link Information.

See QlgLstat64()--Get File or Link Information (Large File Enabled) for a description and an example of supplying the path in any CCSID.


Usage Notes

  1. When you develop in C-based languages, the prototypes for the 64-bit APIs are normally hidden. To use the lstat64() API and the struct stat64 data type, you must compile the source with the _LARGE_FILE_API defined.

  2. All of the usage notes for lstat() apply to lstat64(). See Usage Notes in the lstat() API.

Example

See Code disclaimer information for information pertaining to code examples.

The following example provides status information for a file.

#define _LARGE_FILE_API
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>

main() {
  char fn[]="temp.file", ln[]="temp.link";
  struct stat64 info;
  int file_descriptor;

  if ((file_descriptor = creat64(fn, S_IWUSR)) < 0)
    perror("creat64() error");
  else {
    close(file_descriptor);
    if (link(fn, ln) != 0)
      perror("link() error");
    else {
      if (lstat64(ln, &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);
  }
}

Output:

lstat() returned:
  inode:   3022
 dev id:   1
   mode:   00008080
  links:   2
    uid:   137
    gid:   500
   size:   18

API introduced: V4R4
Top | UNIX-Type APIs | APIs by category