# hardenedbsd/hardenedbsd-stable architecture

> Architecture diagram of the GitHub repository hardenedbsd/hardenedbsd-stable, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hardenedbsd/hardenedbsd-stable
- Repository: https://github.com/hardenedbsd/hardenedbsd-stable
- Video tour (about a minute): https://gitdiagram.com/hardenedbsd/hardenedbsd-stable/video

## Overview

FreeBSD is an operating system source tree, not a single application. A representative user workflow is to enter a command in the shell, have it parsed and evaluated, execute a system utility, and receive output or system changes. The tree also documents and represents ZFS administration through commands and libraries. The supplied tree is broad but the excerpts are partial and do not include the core kernel implementation; the graph therefore shows only supported, representative runtime paths and leaves uncertain wiring out.

Main entry points: [`bin/sh/exec.c`](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/exec.c) (Command execution), [`bin/sh/eval.c`](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/eval.c) (Command evaluation), [`cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c`](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c) (ZFS management), [`bin/sh/main.c`](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/main.c) (Shell entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["Command shell"]
  node_shell_main["Shell entry<br/>[main.c]"]
  node_shell_parser["Command parser<br/>[parser.c]"]
  node_shell_eval["Command evaluation<br/>[eval.c]"]
  node_shell_exec["Command execution<br/>[exec.c]"]
  node_shell_redir["Redirection<br/>[redir.c]"]
end

subgraph group_commands["System commands"]
  node_filesystem_commands["File commands<br/>[cp.c]"]
  node_file_listing["Directory listing<br/>[ls.c]"]
  node_permissions["Permission commands<br/>[chmod.c]"]
  node_archive["Archive utility<br/>[pax.c]"]
  node_process_view["Process reporting<br/>[ps.c]"]
end

subgraph group_storage["ZFS storage"]
  node_zfs_cli["ZFS commands<br/>[zfs_main.c]"]
  node_zpool_cli["Pool commands<br/>[zpool_main.c]"]
  node_libzfs["ZFS management<br/>[libzfs_dataset.c]"]
  node_libzfs_core["ZFS core interface<br/>[libzfs_core.c]"]
end

subgraph group_services["System services"]
  node_zfs_daemon["ZFS event daemon<br/>[zfsd_main.cc]"]
  node_dtrace_cli["DTrace command<br/>[dtrace.c]"]
  node_libdtrace["DTrace library<br/>[dt_open.c]"]
end

node_user(("User"))
node_system{{"FreeBSD system"}}
node_terminal(("Terminal output"))

node_user -->|"enters commands"| node_shell_main
node_shell_main -->|"reads input"| node_shell_parser
node_shell_parser -->|"produces syntax"| node_shell_eval
node_shell_eval -->|"dispatches commands"| node_shell_exec
node_shell_eval -->|"handles redirection"| node_shell_redir
node_shell_exec -->|"executes utility"| node_filesystem_commands
node_shell_exec -->|"executes utility"| node_file_listing
node_shell_exec -->|"executes utility"| node_permissions
node_shell_exec -->|"executes utility"| node_archive
node_shell_exec -->|"executes utility"| node_process_view
node_filesystem_commands -->|"accesses files"| node_system
node_file_listing -->|"reads directories"| node_system
node_permissions -->|"changes permissions"| node_system
node_archive -->|"reads and writes"| node_system
node_process_view -->|"queries processes"| node_system
node_zfs_cli -->|"calls management API"| node_libzfs
node_zpool_cli -->|"calls management API"| node_libzfs
node_libzfs -->|"uses core interface"| node_libzfs_core
node_libzfs_core -->|"requests ZFS operations"| node_system
node_dtrace_cli -->|"uses tracing API"| node_libdtrace
node_libdtrace -->|"controls tracing"| node_system
node_shell_exec -->|"displays results"| node_terminal
node_system -->|"provides output"| node_terminal

click node_shell_main "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/main.c"
click node_shell_parser "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/parser.c"
click node_shell_eval "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/eval.c"
click node_shell_exec "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/exec.c"
click node_shell_redir "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/redir.c"
click node_filesystem_commands "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/cp/cp.c"
click node_file_listing "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/ls/ls.c"
click node_permissions "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/chmod/chmod.c"
click node_archive "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/pax/pax.c"
click node_process_view "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/ps/ps.c"
click node_zfs_cli "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c"
click node_zpool_cli "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c"
click node_libzfs "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c"
click node_libzfs_core "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c"
click node_zfs_daemon "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/usr.sbin/zfsd/zfsd_main.cc"
click node_dtrace_cli "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c"
click node_libdtrace "https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_shell_main,node_shell_parser,node_shell_eval,node_shell_exec,node_shell_redir,node_user toneBlue
class node_filesystem_commands,node_file_listing,node_permissions,node_archive,node_process_view toneAmber
class node_zfs_cli,node_zpool_cli,node_libzfs,node_libzfs_core toneMint
class node_zfs_daemon,node_dtrace_cli,node_libdtrace toneRose
class node_system,node_terminal toneIndigo
```

## Components

### Command shell

- [Shell entry](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/main.c): `bin/sh/main.c`
- [Command parser](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/parser.c): `bin/sh/parser.c`
- [Command evaluation](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/eval.c): `bin/sh/eval.c`
- [Command execution](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/exec.c): `bin/sh/exec.c`
- [Redirection](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/sh/redir.c): `bin/sh/redir.c`

### System commands

- [File commands](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/cp/cp.c): `bin/cp/cp.c`
- [Directory listing](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/ls/ls.c): `bin/ls/ls.c`
- [Permission commands](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/chmod/chmod.c): `bin/chmod/chmod.c`
- [Archive utility](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/pax/pax.c): `bin/pax/pax.c`
- [Process reporting](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/bin/ps/ps.c): `bin/ps/ps.c`

### ZFS storage

- [ZFS commands](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c): `cddl/contrib/opensolaris/cmd/zfs/zfs_main.c`
- [Pool commands](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c): `cddl/contrib/opensolaris/cmd/zpool/zpool_main.c`
- [ZFS management](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c): `cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c`
- [ZFS core interface](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c): `cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c`

### System services

- [ZFS event daemon](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/usr.sbin/zfsd/zfsd_main.cc): `cddl/usr.sbin/zfsd/zfsd_main.cc`
- [DTrace command](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c): `cddl/contrib/opensolaris/cmd/dtrace/dtrace.c`
- [DTrace library](https://github.com/hardenedbsd/hardenedbsd-stable/blob/hardened/12-stable/master/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c): `cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c`

### Other components

- **User**
- **FreeBSD system**
- **Terminal output**

## Connections

- User → Shell entry: enters commands
- Shell entry → Command parser: reads input
- Command parser → Command evaluation: produces syntax
- Command evaluation → Command execution: dispatches commands
- Command evaluation → Redirection: handles redirection
- Command execution → File commands: executes utility
- Command execution → Directory listing: executes utility
- Command execution → Permission commands: executes utility
- Command execution → Archive utility: executes utility
- Command execution → Process reporting: executes utility
- File commands → FreeBSD system: accesses files
- Directory listing → FreeBSD system: reads directories
- Permission commands → FreeBSD system: changes permissions
- Archive utility → FreeBSD system: reads and writes
- Process reporting → FreeBSD system: queries processes
- ZFS commands → ZFS management: calls management API
- Pool commands → ZFS management: calls management API
- ZFS management → ZFS core interface: uses core interface
- ZFS core interface → FreeBSD system: requests ZFS operations
- DTrace command → DTrace library: uses tracing API
- DTrace library → FreeBSD system: controls tracing
- Command execution → Terminal output: displays results
- FreeBSD system → Terminal output: provides output
