Login
You're viewing the techdon.dev public feed.
  • Sep 22, 2026, 3:09 PM

    Advanced Programming in the #UNIX Environment

    Week 3: stat(2) intro

    In this video lecture, we meet our new best friend, the 'struct stat'. We'll cover the stat(2) system calls and begin discussing each of the fields in the struct, often by example of the ls(1) and stat(1) commands. In this way, we begin learning more about how the Unix File System is implemented.

    (Note that the output of stat(1) on #NetBSD is different from that on #Linux.)

    youtu.be/veFwXrEHPsk

    $ ls -l file
-rw-r--r-- 1 jschauma wheel 1048576 Sep 10 20:04 file

"-rw-r-r-" from st_mode
1 st_nlink
"jschauma" from st_uid
"wheel" from st_gid
1048576 st_size
Sep 10 20:04  from st_mtime
file not from stat at all
    The stat(1) utility displays information about the file pointed to by file.

$ stat -r file
16 3 0100644 1 1000 0 -1 1048576 1599768274 1599768274 1599768274 0 4096 2056 0 file

The default format displays the st_dev, st_ino, st_mode, st_nlink, st_uid,
st_gid, st_rdev, st_size, st_atime, st_mtime, st_ctime, st_birthtime,
st_blksize, st_blocks, and st_flags fields, in that order.
    💬 0🔄 1⭐ 8