Krikri::PluginHelpers::StatFields
StatFields - pure logic for turning a raw POSIX stat/lstat result
into the stat-shaped JSON hash both the stat and find plugins
return (find's per-match dicts are documented as "see stat module
for full output of each dictionary", verified against real
ansible-playbook). No I/O here - the plugin itself calls
LibC.stat/LibC.lstat, resolves pw_name/gr_name via
System::User/System::Group, and merges in readable/writeable/
executable/checksum/lnk_* (each needs its own syscall/read the
plugin makes itself).
Class methods
mode here is the raw st_mode (type bits + permission bits, e.g.
0o100644 for a 644 regular file) - the same value LibC::Stat#st_mode
returns, not the type-stripped octal stat -c %a used to produce.
atime/mtime/ctime are float seconds (tv_sec + tv_nsec / 1e9), matching Python's own os.stat_result st_atime/st_mtime/st_ctime float attributes that real Ansible's stat/find results carry through verbatim.
block_size/blocks/device_type are the raw st_blksize/st_blocks/ st_rdev passthroughs from the same stat() struct; disk_usage_bytes is NOT a syscall passthrough but real Ansible's own computed field
- stat.py sets
output['disk_usage_bytes'] = st.st_blocks * 512(number of 512-byte blocks actually allocated) - replicated here from blocks rather than read from the kernel. All four are emitted unconditionally (real Ansible only gates them on the platform exposing st_blksize/st_blocks/st_rdev, which Linux always does).
Matches GNU stat -c '%a': the type bits are stripped and the
special (setuid/setgid/sticky) digit is only included when
non-zero (e.g. 0o100644 -> "644", 0o104755 -> "4755"). Also used
by file.cr to compare a freshly-lstat'd mode against a
requested numeric mode: parameter without shelling to stat.