# Unpack `st_mode` bits into JSON

The `explain-file-mode` program takes an `st_mode` value (in decimal, octal,
or hex) and teases apart the meaning of each bit. The output is JSON for
easier postprocessing.

The Unix **stat**(2) system call returns a "file mode" (the `st_mode` field in
`struct stat`). This a set of bits that describe the file (really: file system
object), including what kind of file it is. The Unix C library has macros for
interpreting the bits: `S_IFMT`, and others.

## Example

~~~sh
$ explain-file-mode 0o41777
{
  "mode_decimal": 17407,
  "mode_octal": "0o41777",
  "mode_hex": "0x43ff",
  "file_kind_decimal": 16384,
  "file_kind_octal": "0o40000",
  "file_kind_hex": "0x4000",
  "is_regular": false,
  "is_dir": true,
  "is_socket": true,
  "is_symlink": false,
  "is_blk": true,
  "is_chr": false,
  "is_fifo": false,
  "is_setuid": false,
  "is_setgid": false,
  "is_sticky": true,
  "read_owner": true,
  "write_owner": true,
  "exec_owner": true,
  "read_group": true,
  "write_group": true,
  "exec_group": true,
  "read_other": true,
  "write_other": true,
  "exec_other": true
}
~~
