Start of changefstat64_time64()--Get File Information by Descriptor (large file and time64_t enabled)


  Syntax
 #include <sys/stat.h>

 int fstat64_time64(int fildes, struct stat64_time64 *buf);  
  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

  Threadsafe: Conditional; see Usage Notes.

The fstat64_time64() function gets status information about the file specified by the open file descriptor fildes and stores the information in the area of memory indicated by the buf argument. The status information is returned in a stat64_time64 structure, as defined in the <sys/stat.h> header file.

fstat64_time64() 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:

The elements of the stat64_time64 structure are described in stat64_time64()--Get File Information (large file and time64_t enabled).

For additional information about parameters, authorities required, and error conditions, see fstat()--Get File Information by Descriptor.


Usage Notes

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

  2. While the st_atime, st_mtime, and st_ctime fields are time64_t fields, the API will not return time values beyond what can be contained in a time_t field.

  3. All of the usage notes for fstat() apply to fstat64_time64(). See Usage Notes in the fstat() API.

Example

The following example gets status information.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#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_time64 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_time64(file_descriptor, &info) != 0)
        perror("fstat64_time64() error");
      else {
        puts("fstat64_time64() 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);
  }
}

Output: Note that the output may vary from system to system.

fstat64_time64() returned:
  inode:   3057
 dev id:   1
   mode:   03000080
  links:   1
    uid:   137
    gid:   500
   size:   8589934662

End of change
API introduced: IBM® i 7.2

[ Back to top | UNIX-Type APIs | APIs by category ]