LLFIO v2.00
Loading...
Searching...
No Matches
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. More...
 

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 Enumeration Documentation

◆ bitfield__want

Used to indicate what metadata should be filled in.

120 {dev = 1 << 0,
121 ino = 1 << 1,
122 type = 1 << 2,
123 perms = 1 << 3,
124 nlink = 1 << 4,
125 uid = 1 << 5,
126 gid = 1 << 6,
127 rdev = 1 << 7,
128 atim = 1 << 8,
129 mtim = 1 << 9,
130 ctim = 1 << 10,
131 size = 1 << 11,
132 allocated = 1 << 12,
133 blocks = 1 << 13,
134 blksize = 1 << 14,
135 flags = 1 << 15,
136 gen = 1 << 16,
137 birthtim = 1 << 17,
138 sparse = 1 << 24,
139 compressed = 1 << 25,
140 reparse_point = 1 << 26,
141 all = static_cast<unsigned>(-1),
142 none = 0} QUICKCPPLIB_BITFIELD_END(want)

Constructor & Destructor Documentation

◆ stat_t() [1/2]

llfio_v2_xxx::stat_t::stat_t ( )
inline

Constructs a UNINITIALIZED instance i.e. full of random garbage.

145 {
146 } // NOLINT CANNOT be constexpr because we are INTENTIONALLY not initialising the storage

◆ stat_t() [2/2]

constexpr llfio_v2_xxx::stat_t::stat_t ( std::nullptr_t  )
inlineexplicitconstexprnoexcept

Constructs a zeroed instance.

149 : st_dev(0) // NOLINT
150 , st_ino(0) // NOLINT
151 , st_type(filesystem::file_type::unknown) // NOLINT
152#ifndef _WIN32
153 , st_perms(0) // NOLINT
154#endif
155 , st_nlink(0) // NOLINT
156#ifndef _WIN32
157 , st_uid(0) // NOLINT
158 , st_gid(0) // NOLINT
159 , st_rdev(0) // NOLINT
160#endif
161 , st_atim{} // NOLINT
162 , st_mtim{} // NOLINT
163 , st_ctim{} // NOLINT
164 , st_size(0) // NOLINT
165 , st_allocated(0) // NOLINT
166 , st_blocks(0) // NOLINT
167 , st_blksize(0) // NOLINT
168 , st_flags(0) // NOLINT
169 , st_gen(0) // NOLINT
170 , st_birthtim{} // NOLINT
171 , st_sparse(0) // NOLINT
172 , st_compressed(0) // NOLINT
173 , st_reparse_point(0) // NOLINT
174 {
175 }
dev_t st_rdev
Definition stat.hpp:86
unsigned st_reparse_point
Definition stat.hpp:117
uint32_t st_gen
Definition stat.hpp:106
std::chrono::system_clock::time_point st_atim
Definition stat.hpp:90
filesystem::file_type st_type
Definition stat.hpp:74
unsigned st_sparse
Definition stat.hpp:115
uint32_t st_flags
Definition stat.hpp:104
std::chrono::system_clock::time_point st_ctim
Definition stat.hpp:98
handle::extent_type st_allocated
Definition stat.hpp:101
unsigned st_compressed
Definition stat.hpp:116
uint16_t st_blksize
Definition stat.hpp:103
handle::extent_type st_blocks
Definition stat.hpp:102
std::chrono::system_clock::time_point st_birthtim
Definition stat.hpp:110
int16_t st_gid
Definition stat.hpp:85
stil1z::filesystem::perms st_perms
Definition stat.hpp:79
handle::extent_type st_size
Definition stat.hpp:100
uint64_t st_dev
Definition stat.hpp:72
int16_t st_uid
Definition stat.hpp:84
uint64_t st_ino
Definition stat.hpp:73
int16_t st_nlink
Definition stat.hpp:82
std::chrono::system_clock::time_point st_mtim
Definition stat.hpp:94

Member Function Documentation

◆ fill()

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

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).

◆ operator!=()

bool llfio_v2_xxx::stat_t::operator!= ( const stat_t o) const
inlinenoexcept

Inequality comparison.

205 {
206 return st_dev != o.st_dev || st_ino != o.st_ino || st_type != o.st_type
207#ifndef _WIN32
208 || st_perms != o.st_perms
209#endif
210 || st_nlink != o.st_nlink
211#ifndef _WIN32
212 || st_uid != o.st_uid || st_gid != o.st_gid || st_rdev != o.st_rdev
213#endif
214 || st_atim != o.st_atim || st_mtim != o.st_mtim || st_ctim != o.st_ctim || st_size != o.st_size || st_allocated != o.st_allocated ||
215 st_blocks != o.st_blocks || st_blksize != o.st_blksize || st_flags != o.st_flags || st_gen != o.st_gen || st_birthtim != o.st_birthtim ||
216 st_sparse != o.st_sparse || st_compressed != o.st_compressed || st_reparse_point != o.st_reparse_point;
217 }

◆ operator<()

bool llfio_v2_xxx::stat_t::operator< ( const stat_t o) const
inlinenoexcept

Ordering.

220 {
221 if(st_dev != o.st_dev)
222 {
223 return st_dev < o.st_dev;
224 }
225 if(st_ino != o.st_ino)
226 {
227 return st_ino < o.st_ino;
228 }
229 if(st_type != o.st_type)
230 {
231 return st_type < o.st_type;
232 }
233#ifndef _WIN32
234 if(st_perms != o.st_perms)
235 {
236 return st_perms < o.st_perms;
237 }
238#endif
239 if(st_nlink != o.st_nlink)
240 {
241 return st_nlink < o.st_nlink;
242 }
243#ifndef _WIN32
244 if(st_uid != o.st_uid)
245 {
246 return st_uid < o.st_uid;
247 }
248 if(st_gid != o.st_gid)
249 {
250 return st_gid < o.st_gid;
251 }
252 if(st_rdev != o.st_rdev)
253 {
254 return st_rdev < o.st_rdev;
255 }
256#endif
257 if(st_atim != o.st_atim)
258 {
259 return st_atim < o.st_atim;
260 }
261 if(st_mtim != o.st_mtim)
262 {
263 return st_mtim < o.st_mtim;
264 }
265 if(st_ctim != o.st_ctim)
266 {
267 return st_ctim < o.st_ctim;
268 }
269 if(st_size != o.st_size)
270 {
271 return st_size < o.st_size;
272 }
273 if(st_allocated != o.st_allocated)
274 {
275 return st_allocated < o.st_allocated;
276 }
277 if(st_blocks != o.st_blocks)
278 {
279 return st_blocks < o.st_blocks;
280 }
281 if(st_blksize != o.st_blksize)
282 {
283 return st_blksize < o.st_blksize;
284 }
285 if(st_flags != o.st_flags)
286 {
287 return st_flags < o.st_flags;
288 }
289 if(st_gen != o.st_gen)
290 {
291 return st_gen < o.st_gen;
292 }
293 if(st_birthtim != o.st_birthtim)
294 {
295 return st_birthtim < o.st_birthtim;
296 }
297 if(st_sparse != o.st_sparse)
298 {
299 return st_sparse < o.st_sparse;
300 }
301 if(st_compressed != o.st_compressed)
302 {
303 return st_compressed < o.st_compressed;
304 }
305 if(st_reparse_point != o.st_reparse_point)
306 {
307 return st_reparse_point < o.st_reparse_point;
308 }
309 return false;
310 }

◆ operator==()

bool llfio_v2_xxx::stat_t::operator== ( const stat_t o) const
inlinenoexcept

Equality comparison.

190 {
191 return st_dev == o.st_dev && st_ino == o.st_ino && st_type == o.st_type
192#ifndef _WIN32
193 && st_perms == o.st_perms
194#endif
195 && st_nlink == o.st_nlink
196#ifndef _WIN32
197 && st_uid == o.st_uid && st_gid == o.st_gid && st_rdev == o.st_rdev
198#endif
199 && st_atim == o.st_atim && st_mtim == o.st_mtim && st_ctim == o.st_ctim && st_size == o.st_size && st_allocated == o.st_allocated &&
200 st_blocks == o.st_blocks && st_blksize == o.st_blksize && st_flags == o.st_flags && st_gen == o.st_gen && st_birthtim == o.st_birthtim &&
201 st_sparse == o.st_sparse && st_compressed == o.st_compressed && st_reparse_point == o.st_reparse_point;
202 }

◆ stamp()

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

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: