# plugin_disks A zero-dependency **C99** storage inspector for SCORPIOX BOT nodes. One binary, three modes, no runtime dependencies, no outbound network requests. It answers two questions a node owner actually asks: 1. **Which filesystems does this node have, and how full are they?** 2. **What is eating the disk inside `/workspace` or my home directory?** Everything is read from the local kernel interfaces. Nothing is sent anywhere. ## What it reports | Mode | Output | |---|---| | `--meta` | `{"name":"disks","desc":"Local storage"}` - discovery metadata | | `?action=mounts` | Every real mounted filesystem: device, filesystem type, mountpoint, total / used / free / available bytes, utilisation percentage, inode totals and inode pressure | | `?action=dirs&root=workspace` | A bounded one-level size breakdown of `/workspace` | | `?action=dirs&root=home` | The same breakdown for `$HOME` (`%USERPROFILE%` on Windows) | | `?action=info` | Plugin version, platform, pid, capability and limit declaration | | `GET` (no action) | A responsive HTML dashboard | Pseudo filesystems (`proc`, `sysfs`, `cgroup2`, `devpts`, `debugfs`, ...) and the kernel-only mountpoints (`/sys`, `/proc`, `/dev`) are filtered out, and a mountpoint that appears twice in `/proc/mounts` is only counted once - otherwise a container's repeated host bind mounts triple the reported capacity. ## Platform coverage | Platform | Mount source | Directory walk | |---|---|---| | Linux | `/proc/mounts` + `statvfs(3)` | `opendir` / `readdir` / `lstat` | | macOS | `getmntinfo(3)` | `opendir` / `readdir` / `lstat` | | Windows | `GetLogicalDriveStringsA` + `GetDiskFreeSpaceExA` + `GetVolumeInformationA` | `FindFirstFileA` / `FindNextFileA` | ## Directory scanning is deliberately narrow `?action=dirs` accepts **only** `root=workspace` or `root=home`. An arbitrary path is refused with `root_not_allowed`; an allowlisted root that does not exist on the node answers `root_unavailable`. The walk itself is bounded four ways: * depth is capped at 8 levels, * the walk stops after 120000 visited entries, * symbolic links are never followed (a link cannot make the walk unbounded), * at most 512 top-level entries are reported, sorted largest first. The response reports `truncated`, `max_depth`, `max_scan_entries` and `scan_ms` so a caller can see that the numbers were cut short rather than trust them. ## Build ```sh make # native binary -> ./plugin_disks make musl # static musl x86_64 -> ./plugin_disks (universal Linux artifact) make arm64 # static aarch64 -> ./plugin_disks.arm64 (Pi 5 / ARM servers) make win64 # static PE -> ./plugin_disks.exe make macos # Apple clang -> ./plugin_disks (run on macOS) make test # build + offline test suite ``` On Windows, `powershell -ExecutionPolicy Bypass -File build.ps1` produces `plugin_disks.exe` and refuses to succeed unless the first two bytes are `MZ`. No compiler, no problem: the published binaries live at `https://dist.scorpiox.net/bot-plugins/disks/`. ## Install The supported path is one click in SCORPIOX BOT (`Settings -> Menus -> Plugins -> Marketplace`) or, from a shell on the node, drop the binary into the plugin directory: ```sh mkdir -p ~/.scorpiox/plugins cp plugin_disks ~/.scorpiox/plugins/ chmod +x ~/.scorpiox/plugins/plugin_disks ``` `/workspace/.scorpiox/plugins/` is used instead when `/workspace` exists, because it survives BotCloud container restarts. The node API discovers the plugin on the next request - no restart. Prefer to build it yourself? The source is MIT licensed and compiles in one command: ```sh cc -O2 -std=c99 -Wall -Wextra -o plugin_disks src/plugin_disks.c ``` ## API ```sh # mounted filesystems curl -s 'http://127.0.0.1:8150/plugin_disks?action=mounts&pwd=' # top-level sizes inside the home directory curl -s 'http://127.0.0.1:8150/plugin_disks?action=dirs&root=home&pwd=' # an arbitrary path is refused, by design curl -s 'http://127.0.0.1:8150/plugin_disks?action=dirs&root=/etc&pwd=' # {"ok":false,"error":"root_not_allowed","allowed_roots":["workspace","home"],...} ``` `action=mounts` response: ```json { "ok": true, "action": "mounts", "plugin": "plugin_disks", "version": "1.0.0", "platform": "linux", "count": 2, "zero_network": true, "mounts": [ { "device": "/dev/nvme0n1p2", "fstype": "ext4", "mount": "/", "total_bytes": 983167959040, "used_bytes": 930171248640, "free_bytes": 52996710400, "avail_bytes": 42979762176, "pct": 95.6, "inodes_total": 61038592, "inodes_used": 8172848, "inodes_pct": 13.4, "has_inodes": true } ] } ``` ## Security model * Reads only local kernel state; opens no sockets; runs no shell commands (`popen`/`system` are not used anywhere in the source). * Requires the node password on every request except `--meta`. Accepted forms: `X-Bot-Password: `, `Authorization: Bearer `, and `?pwd=`. When `BOT_PASSWORD` is unset the check is a deliberate no-op, which is how the plugin runs from a developer shell. * The directory walk cannot be pointed at an arbitrary path, cannot follow a symlink out of the root, and cannot run unbounded. ## License MIT. Copyright (c) 2026 SCORPIOX INC.