LLFIO  v2.00
llfio_v2_xxx::stat_t Struct Reference

Metadata about a directory entry. More...

#include "stat.hpp"

Public Types

enum  bitfield__want : unsigned {
  dev = 1 << 0 , ino = 1 << 1 , type = 1 << 2 , perms = 1 << 3 ,
  nlink = 1 << 4 , uid = 1 << 5 , gid = 1 << 6 , rdev = 1 << 7 ,
  atim = 1 << 8 , mtim = 1 << 9 , ctim = 1 << 10 , size = 1 << 11 ,
  allocated = 1 << 12 , blocks = 1 << 13 , blksize = 1 << 14 , flags = 1 << 15 ,
  gen = 1 << 16 , birthtim = 1 << 17 , sparse = 1 << 24 , compressed = 1 << 25 ,
  reparse_point = 1 << 26 , all = static_cast<unsigned>(-1) , none = 0
}
 Used to indicate what metadata should be filled in.
 

Public Member Functions

 stat_t ()
 Constructs a UNINITIALIZED instance i.e. full of random garbage.
 
constexpr stat_t (std::nullptr_t) noexcept
 Constructs a zeroed instance.
 
bool operator== (const stat_t &o) const noexcept
 Equality comparison.
 
bool operator!= (const stat_t &o) const noexcept
 Inequality comparison.
 
bool operator< (const stat_t &o) const noexcept
 Ordering.
 
result< size_t > fill (const handle &h, want wanted=want::all) noexcept
 
result< want > stamp (handle &h, want wanted=want::all) noexcept
 

Public Attributes

uint64_t st_dev
 
uint64_t st_ino
 
filesystem::file_type st_type
 
stil1z::filesystem::perms st_perms
 
int16_t st_nlink
 
int16_t st_uid
 
int16_t st_gid
 
dev_t st_rdev
 
union {
   std::chrono::system_clock::time_point   st_atim
 
}; 
 
union {
   std::chrono::system_clock::time_point   st_mtim
 
}; 
 
union {
   std::chrono::system_clock::time_point   st_ctim
 
}; 
 
handle::extent_type st_size
 
handle::extent_type st_allocated
 
handle::extent_type st_blocks
 
uint16_t st_blksize
 
uint32_t st_flags
 
uint32_t st_gen
 
union {
   std::chrono::system_clock::time_point   st_birthtim
 
}; 
 
unsigned st_sparse: 1
 
unsigned st_compressed: 1
 
unsigned st_reparse_point: 1
 

Detailed Description

Metadata about a directory entry.

This structure looks somewhat like a struct stat, and indeed it was derived from BSD's struct stat. However there are a number of changes to better interoperate with modern practice, specifically:

  • inode value containers are forced to 64 bits.
  • Timestamps use C++11's std::chrono::system_clock::time_point or Boost equivalent. The resolution of these may or may not equal what a struct timespec can do depending on your STL.
  • The type of a file, which is available on Windows and on POSIX without needing an additional syscall, is provided by st_type which is one of the values from filesystem::file_type.
  • As type is now separate from permissions, there is no longer a st_mode, instead being a st_perms which is solely the permissions bits. If you want to test permission bits in st_perms but don't want to include platform specific headers, note that filesystem::perms contains definitions of the POSIX permissions flags.
  • The st_sparse and st_compressed flags indicate if your file is sparse and/or compressed, or if the directory will compress newly created files by default. Note that on POSIX, a file is sparse if and only if st_allocated < st_size which can include compressed files if that filing system is mounted with compression enabled (e.g. ZFS with ZLE compression which elides runs of zeros).
  • The st_reparse_point is a Windows only flag and is never set on POSIX, even on a NTFS volume.

Member Function Documentation

◆ fill()

result<size_t> llfio_v2_xxx::stat_t::fill ( const handle h,
want  wanted = want::all 
)
inlinenoexcept

Fills the structure with metadata.

Returns
The number of items filled in. You should use a nullptr constructed structure if you wish to detect which items were filled in, and which not (those not may be all bits zero).

◆ stamp()

result<want> llfio_v2_xxx::stat_t::stamp ( handle h,
want  wanted = want::all 
)
inlinenoexcept

Stamps the handle with the metadata in the structure, returning the metadata written.

The following want bits are always ignored, and are cleared in the want bits returned:

  • dev
  • ino
  • type
  • nlink
  • rdev
  • ctim
  • size (use truncate() on the file instead)
  • allocated
  • blocks
  • blksize
  • flags
  • gen
  • sparse
  • compressed
  • reparse_point

The following want bits are supported by these platforms:

  • perms, uid, gid (POSIX only)
  • atim (Windows, POSIX)
  • mtim (Windows, POSIX)
  • birthtim (Windows, POSIX)

Note that on POSIX, setting birth time involves two syscalls, the first of which temporarily sets the modified date to the birth time, which is racy. This is unavoidable given the syscall's design.

Note also that on POSIX one can never make a birth time newer than the current birth time, nor a modified time older than a birth time. You can do these on Windows, however.

Member Data Documentation

◆ st_allocated

handle::extent_type llfio_v2_xxx::stat_t::st_allocated

bytes allocated for file (Windows, POSIX)

◆ st_atim

std::chrono::system_clock::time_point llfio_v2_xxx::stat_t::st_atim

time of last access (Windows, POSIX)

◆ st_birthtim

std::chrono::system_clock::time_point llfio_v2_xxx::stat_t::st_birthtim

time of file creation (Windows, POSIX)

◆ st_blksize

uint16_t llfio_v2_xxx::stat_t::st_blksize

block size used by this device (Windows, POSIX)

◆ st_blocks

handle::extent_type llfio_v2_xxx::stat_t::st_blocks

number of blocks allocated (Windows, POSIX)

◆ st_compressed

unsigned llfio_v2_xxx::stat_t::st_compressed

if this file is compressed, or this directory capable of compressed files (Windows, Linux)

◆ st_ctim

std::chrono::system_clock::time_point llfio_v2_xxx::stat_t::st_ctim

time of last status change (Windows, POSIX)

◆ st_dev

uint64_t llfio_v2_xxx::stat_t::st_dev

inode of device containing file (POSIX only)

◆ st_flags

uint32_t llfio_v2_xxx::stat_t::st_flags

user defined flags for file (FreeBSD, OS X, zero otherwise)

◆ st_gen

uint32_t llfio_v2_xxx::stat_t::st_gen

file generation number (FreeBSD, OS X, zero otherwise)

◆ st_gid

int16_t llfio_v2_xxx::stat_t::st_gid

group ID of the file (POSIX only)

◆ st_ino

uint64_t llfio_v2_xxx::stat_t::st_ino

inode of file (Windows, POSIX)

◆ st_mtim

std::chrono::system_clock::time_point llfio_v2_xxx::stat_t::st_mtim

time of last data modification (Windows, POSIX)

◆ st_nlink

int16_t llfio_v2_xxx::stat_t::st_nlink

number of hard links (Windows, POSIX)

◆ st_perms

stil1z::filesystem::perms llfio_v2_xxx::stat_t::st_perms

uint16_t bitfield perms of file (POSIX only)

◆ st_rdev

dev_t llfio_v2_xxx::stat_t::st_rdev

id of file if special (POSIX only)

◆ st_reparse_point

unsigned llfio_v2_xxx::stat_t::st_reparse_point

if this file or directory is a reparse point (Windows)

◆ st_size

handle::extent_type llfio_v2_xxx::stat_t::st_size

file size, in bytes (Windows, POSIX)

◆ st_sparse

unsigned llfio_v2_xxx::stat_t::st_sparse

if this file is sparse, or this directory capable of sparse files (Windows, POSIX)

◆ st_type

filesystem::file_type llfio_v2_xxx::stat_t::st_type

type of file (Windows, POSIX)

◆ st_uid

int16_t llfio_v2_xxx::stat_t::st_uid

user ID of the file (POSIX only)


The documentation for this struct was generated from the following file: