Old mobile/**/AGENTS.md texts, verbatim, as they stood on 2026-11-13 before
the refactor (HEAD 1d7cc7e07).  History, not rules.
Each section: the path, the date of its last commit, then the text.


################################################################
## mobile/AGENTS.md  (last commit 2026-11-11)
################################################################
# AGENTS.md -- how work happens in mobile/

Makronix Mobile Edition.  Read `GOAL.md` first.  The rules of `../AGENTS.md`
apply here wherever they make sense for Linux: measurements beat claims, docs
before code, changes to imported sources only as patches.

## One tree

`mobile/` is a subtree of the `makronix` repository.  Userland sources
(pkgsrc, the `makronix` set, patches, `PINS`) are shared with the desktop and
live once, at the root; `mobile/` does not copy or fork them.  Where the
phone differs from the PC, the difference is a variable or an entry in
`soc.conf` / `device.conf`, never a second copy of a file.  If `mobile/` needs
a change in shared code, make it in the shared place and let the PC build prove
it still works.

## Userland: the same pkgsrc

The userland of the phone comes from **the pkgsrc tree of the repository
root** (`../pkgsrc`, pinned in `../PINS`), built for aarch64.  There are no
second packages and no second distfiles cache: the one `build/distfiles`
(`../tools/makronix-distfiles.sh`) serves the desktop and the phone, and the
source set carries the archives of every platform.

- The package list is `../packages.list` plus `../packages.$PKG_ARCH.list`
  (`PKG_ARCH=aarch64`, from `soc.conf`), and likewise for
  `packages.binary*.list`.  A package only the phone needs goes into
  `packages.aarch64.list`, which the desktop's aarch64 builds share; there is
  no `mobile/packages.list`.
- What is specific to a platform is a pkgsrc option or a `device.conf`
  variable (`PKG_OPTIONS`), read by the tool that writes `mk.conf`.  A patch
  to a package is a patch in `../patches`, for both.
- The target OS of the phone is Linux, so pkgsrc's `OPSYS` is not NetBSD there:
  that is a bootstrap setting (a second mk fragment next to
  `../tools/pkgsrc-cross.mk.conf`), not a second tree.  Where a package
  does not build on Linux, the fix goes to the shared place so the PC build
  stays the proof.

## Makronix on a Linux kernel

Since 2026-11-11 the phone is to run as much of our `src/` as possible on top
of the Linux kernel: NetBSD init and rc instead of runit, NetBSD's userland
instead of Void's, no xbps on the phone, the desktop's pkgsrc userland in
`/usr/pkg`.  The plan, cut into items several agents can take at once, is
`docs/NETBSD-USERLAND.md`; read its sections 2 and 3 before porting
anything.

## The device is the unit

The phone in your hand decides which tree and which sequence is right.  **Check
`DEVICE_NAME` before you build or flash.**  On 2026-11-07 an image built for the
OnePlus 7T Pro (a different panel, a different init sequence) garbled the
display of a 7T.  hotdogb is the 7T; hotdog is the 7T Pro and is not supported
here.

## Layout

    soc/<soc>/soc.conf        what every phone with this SoC shares
    soc/<soc>/rootfs/         files for its root image, any base (tools/mkrootimg.sh)
    soc/<soc>/rootfs-<base>/  the same, for one base (runit services on void)
    devices/<codename>/       one phone: device.conf, kernel.config, cmdline, dtb
    tools/                    POSIX sh; lib.sh loads soc.conf then device.conf
    userland/                 NetBSD programs of src/ ported to the phone
                              (docs/NETBSD-USERLAND.md, PORTING-USERLAND.md)
    docs/                     PORTING.md (new phone), BOOT.md (boot chain)
    base/ pkgsrc/ patches/    later phases; empty now
    build/                    output, ignored
    ../refs/linux/<version>   the shared Linux source (submodule, read-only)

## Rules

- No tool knows a device by name.  A new phone is a new `devices/<codename>/`
  and, for a new SoC, a `soc/<soc>/soc.conf`.  If you reach for an `if` on a
  device name in a tool, the setting belongs in a `.conf` instead.
- `tools/` is POSIX `sh`.  No Python, no bashisms, no prebuilt binaries that
  need a foreign libc.
- Pins (`INITRAMFS_SHA256_PREFIX`, and `DTB_SHA256_PREFIX` for a binary
  `DTB`) make a build reproducible; `make check` enforces them.  A DTB built
  from the kernel tree (`KERNEL_DTB`) is pinned by `kernel/PIN` and the
  patches.  Change a pin only together with
  the measurement that justifies it.
- Flashing: the test slot first.  The fallback slot holds the last image known
  to boot and is written only with `FORCE_FALLBACK=1`, on purpose.

## Where the kernel lives (today)

The kernel source is **outside `mobile/`**, one shared Linux tree for the
whole repository: `../refs/linux/7.0.14` (kernel.org stable v7.0.14, a
shallow submodule at the commit in `kernel/PIN`).  `mobile/` holds only the
changes: `kernel/patches/` is the series on top, applied in filename order.
0001-0004 are what hotdogb needs from the qualcomm-sm8150 fork (taken
unchanged from its 8e126dbc4), 0005-0025 are ours.  The old base was that
fork itself (`../refs/linux/7.0.0`); it stays as a reference.

`make linux` clones the shared tree locally (hardlinks, no network) into
`build/linux-<device>` (`KERNEL_TREE`), checks it out at the pin and applies
the patches; `make kernel` builds the Image, the modules and the device's DTB
(`KERNEL_DTB` in `device.conf`) there.  The build tree is output: change it
with commits, then export them into `kernel/patches/` (`git format-patch
--start-number N`).  Since 2026-11-08 the DTS of hotdogb is in the series too
(0010 since the move to v7.0.14); there is no binary DTB any more.

The shared tree is never edited.  A pin moves by updating the submodule and
`kernel/PIN` together, with the measurement that justifies it; a drift
between them is an error (`tools/fetch-kernel.sh`).


################################################################
## mobile/base/AGENTS.md  (last commit 2026-11-11)
################################################################
# base/

The system layer under the userland.  **glibc**, since 2026-11-07 (Konrad's
decision; pkgsrc and CDE are best tested on glibc, and Alpine/musl and its
pmOS fork are not the base any more).

- `void/` -- **the default**; `void/rootfs/` holds files for the root of
  every device on Void (copied by `tools/mkrootimg.sh` before the SoC's) (`BASE ?= void` in the Makefile; Konrad prefers
  Void and runit, 2026-11-07).  Void's pinned aarch64 glibc ROOTFS plus
  `void/packages`, built by `tools/mkrootfs-void.sh`; runit services in
  `base.conf`.  The repository rolls: what was installed is written to
  `build/rootfs-void-<device>.lock`.  `void/sysroot-packages` is
  build-only: the -devel packages the NetBSD userland is cross-built against
  (`tools/mksysroot.sh`, `docs/PORTING-USERLAND.md`); never in an image.
- `debian/` -- Debian stable (trixie), systemd, the alternative
  (`BASE=debian`), built by `tools/mkrootfs-debian.sh` with mmdebstrap.
- The kernel is not the distribution's: `kernel/` and `tools/build-kernel.sh`;
  its modules go into the root image (`tools/mkrootimg.sh`).
- The userland is not the distribution's: pkgsrc, in `/usr/pkg`, from the one
  tree of the repository root.  If a package is in `<base>/packages`, the
  phone could not work without it; otherwise it belongs to pkgsrc.

## From rootfs tar to the phone

    make rootfs     BASE=void   build/rootfs-void-<device>.tar
    make rootimg    BASE=void   build/root-void-<device>.img (ext4, ROOT_UUID)
    make bootimg                the boot image; its cmdline names ROOT_UUID
    make flash-root BASE=void   fastboot flash ROOT_PARTITION (userdata)
    make flash                  the boot image to the test slot

`tools/mkrootimg.sh` adds what the image needs on the phone: the kernel's
modules, `/etc/fstab` with the root by UUID, a NetworkManager profile that
keeps 172.16.42.1 on usb0, root's password `ROOT_PASSWORD`
(default `makronix`), valid on the console and over ssh, and
`/usr/libexec/makronix/reboot2`, built from `reboot2.c` with the device's
cross compiler, static: the restart with a reboot mode (fastboot) that no
tool of Void can make (`reboot-mode(1)`, docs/BOOT.md).

## What carries over from pmOS, and what does not

pmOS (Alpine, musl, apk, pmbootstrap, pmaports) is gone from the build:
the vendored-pmaports idea is dropped.  What was valuable in it was device
knowledge, and that is in `devices/` already: kernel config, cmdline, DTB,
firmware needs.  Since 2026-11-08 the boot image carries our initramfs
(below), not pmOS's; what the pmOS one did beyond finding the root --
growing the ext4 root with resize2fs -- the root does itself
(`void/rootfs/etc/runit/core-services/03-grow-root.sh`, online).

## The initramfs

`initramfs/init` (POSIX sh) and a static busybox we build ourselves
(`tools/build-busybox.sh`, source pinned in `initramfs/busybox.conf`, our
changes in `initramfs/busybox.config`), packed by `tools/mkinitramfs.sh`:
`make initramfs`.  Nothing in it comes from Void or Debian: their busyboxes
lack udhcpd, telnetd and mountpoint (Void 1.34.1_12, static and dynamic).
/init brings up the USB gadget -- NCM with 172.16.42.1 and a DHCP lease for
the host, and ACM (ttyGS0, the serial console) in the same configuration,
so the root never rebinds it -- finds the root file system by UUID, sets up
the layout below and switch_roots to /sbin/init; on any failure, or with
`makronix.debug`, it serves `telnet 172.16.42.1` instead of halting.
Reproducible: busybox's banner time is `SOURCE_DATE_EPOCH` of the pinned
source (`tools/build-busybox.sh`), the cpio has fixed mtimes; pinned in
`device.conf` (`INITRAMFS_SHA256_PREFIX`).  Booted on hotdogb 2026-11-08:
`switch_root` at 1.3 s (the pmOS one: about 3.5 s), netconsole from 1.5 s,
the root grown online from 281468 to 25493504 blocks on the first boot.

## The root layout: system and data apart

Since 2026-11-09 the partition (userdata) holds the system and the state in
two places, so that an update of the system does not cost the
configuration (Konrad: "it sucks that with an update we have to configure
everything"; Android's system/data split is the model, docs/NEXT.md §6):

     /system/current/   the system: tools/mkrootimg.sh writes it into the
                        image, tools/update-root.sh puts a new tree beside it
     /data/             the state: home/ root/ var/lib/ etc/upper etc/work

`/init` mounts the partition at `/sysroot.real`, and when
`/system/current` exists:

- `/` is a bind mount of `/system/current`;
- `/home`, `/root` and `/var/lib` are bind mounts of `/data/...`, so the
  user's files, root's keys, the machine id, the bluetooth pairings and
  `makronix/rtc-offset` survive;
- `/etc` is an **overlay** (lower: the system's `/etc`, upper:
  `/data/etc/upper`): a file that was changed stays changed, every file
  that was not changed comes fresh from the new system, so a new service
  or a changed default is not hidden by an old copy;
- `/data` and `/system` are bound in as well.  The partition itself is left
  mounted at `/sysroot.real` and has no path after `switch_root`: every path
  in the new root lies inside it (the bind of `/system/current` makes that
  so), so moving it into the new root is impossible, and detaching it would
  rely on mount propagation that is not ours to choose.  Nothing needs it:
  the overlay holds the upper directory, and the binds hold the file
  system.

`/data` is created on the first boot, together with a one-time copy of the
system's `/var/lib` and `/root`.  An image from before 2026-11-09 has no
`/system/current`: the partition is then mounted at `/` exactly as before
(`layout: whole partition` in the boot log), so old images keep booting.

Void's stage 1 is unchanged: it remounts `/` read-only, runs `fsck -A`,
remounts read-write and mounts the rest of fstab.  Measured on the host
(2026-11-09, 6.12 and 7.x kernels): a remount of the bind flips the whole
file system, so the fsck still checks the whole partition, and
`e2fsck` accepts a file system that is mounted read-only
(`devices/hotdogb/AGENTS.md`).  `03-grow-root.sh` finds the device through
`/proc/mounts`, which names it for the bind as well, so the image is still
grown to the partition on the first boot.

## Open

- Firmware blobs (Adreno, WLAN, modem) and where they come from.


################################################################
## mobile/devices/hotdogb/AGENTS.md  (last commit 2026-11-11)
################################################################
# devices/hotdogb

OnePlus 7T.  NOT the 7T Pro (hotdog): the 7T Pro has a 1440x3120 panel and a
different init sequence; its sequence garbles this phone's display
(measured 2026-11-07).

- `kernel.config` -- the config of the kernel that runs on the phone
  (since 2026-11-11 `7.0.14-makronix-unstable`: kernel.org v7.0.14 plus
  `kernel/patches`; before that 7.0.0-sm8150 on the SM8150 fork; display
  working, ADSP off).  No `CONFIG_LOCALVERSION` and no
  `LOCALVERSION_AUTO`: the name comes from `kernel_make` (`tools/lib.sh`),
  out of `src/sys/conf/makronix-release` and `makronix-codename`; since 2026-11-07 with
  netconsole (dynamic) and `PRINTK_CALLER`, since 2026-11-08 with msm DRM
  built in (`CONFIG_DRM_MSM=y`), dynamic ftrace (function, function_graph),
  Landlock, and BTF (`DEBUG_INFO_BTF`, `_MODULES`; needs `pahole` on the
  build host, Debian `dwarves`).
- `cmdline` -- the kernel arguments; `ROOT_UUID` (device.conf) is appended
  by `tools/mkbootimg.sh` as `root=UUID=` and `pmos_root_uuid=`.  The
  `modprobe.blacklist=msm` of the SMMU race (below) is gone since patch 0003.
- The DTB is built with the kernel (`KERNEL_DTB` in device.conf) from
  `arch/arm64/boot/dts/qcom/sm8150-oneplus-hotdogb.dts`, which the series
  brings in (`kernel/patches/0002` from the fork, then 0010, 0011, 0015, 0016,
  0018, 0019 -- the numbers of the v7.0.14 series) -- since 2026-11-08.
  Until then it was a binary here (`DTB_SHA256_PREFIX` 8eb4b7a7c6a6d346,
  built from `~/src/sm8150-617`, branch `hotdogb-dts`, commit c4195dd0d,
  plus the PON modes by fdtput); git history has it.
- Boot chain: slot b holds the known-good image -- since 2026-11-11 the
  same as slot a, `7.0.14-makronix-unstable` (commit 3b2cbc44f, boot image
  sha256 6e9d7ee126184d0a; `build/logs/flash-fallback-b-2026-11-11.log`),
  its system `/system/current` (Makronix 0.99.9).  The way back after a
  failed test on slot a: `fastboot set_active b`; if the test also brought
  a new /system/current, on the phone `mv /system/current /system/broken &&
  mv /system/previous /system/current`, reboot.  Test on slot a only; slot b is written with
  `FORCE_FALLBACK=1` and stays inactive.  Before: fed05a6c8
  (7.0.0-sm8150-gb55677c051b7 on the SM8150 fork, 8c098f3d3af88f9b),
  2026-11-10; b9c0aff (085b2284c981fc40), 2026-11-08.  The fork state is
  gone from the phone since 2026-11-11 (Konrad: stable now): /system holds
  only `current` (0.99.9) until the next update makes a `previous`; git
  history has the old series.
- Since 2026-11-11 slot a runs `7.0.14-makronix-unstable` with the system
  `/system/current`, Makronix 0.99.9 (`make update-root`; the version is
  `/etc/makronix-release` in the tree, from `src/sys/conf/makronix-release`);
  measured: boots from slot a, marked
  successful (`qcom-ab-slot status`: boot_a retry=6 successful=1), WLAN up
  with DHCP, Bluetooth powered with its address set on attempt 1, battery
  read (100 %, Full), display by msm DRM
  (`build/logs/flash-0.99.9-2026-11-11.log`,
  `build/logs/update-root-0.99.9-2026-11-11.log`).

## Measured 2026-11-07: Void boots from userdata

`build/root-void-hotdogb.img` (`make rootimg BASE=void`) flashed to
`userdata`, boot image on slot a with the **baseline** kernel
(`~/src/nura/sm8150-linux`, `7.0.0-sm8150-g2509837001fc-dirty`) and
`pmos_root_uuid=$ROOT_UUID`: the display hands off cleanly, `void login:` on
the screen, runit is PID 1, all services `run`, sshd takes root/`makronix`
over 172.16.42.1, the root was grown to the partition (`/dev/sda22`, 96G).
No module loads: the image carries modules for the pinned kernel's release,
not for the baseline's.  Log: `build/logs/boot-void-hotdogb-2026-11-07.log`.

**Known defect: the display init hangs the boot for most boot images.**
Measured 2026-11-07, slot a, Void root on userdata:

| boot image (kernel + initramfs)                         | result            |
|---------------------------------------------------------|-------------------|
| baseline kernel + pmOS initramfs                        | boots, 4 of 4 (incl. a warm `reboot`) |
| pinned kernel + pmOS initramfs                          | garbled, no USB, 2 of 2 |
| pinned kernel, same layout (`LOCALVERSION=-align`)      | garbled, no USB   |
| baseline kernel + our initramfs                         | garbled, no USB   |
| pinned kernel (`-align`) + pmOS, `initcall_blacklist=msm_drm_register` | boots to Void, ssh |

The pinned and the baseline kernel are the same code: same `.config`, same
sources (`git diff` of the trees: only `hotdogb/` notes), same symbols, and
with `-align` every symbol at the same address; the images differ only in
version strings, build IDs and timestamps.  So the kernel is not broken: the
start of msm DRM with the panel handoff (`panel-samsung-oneplus-dsc.c`,
`samsung_oneplus_dsc_prepare`) garbles the panel and blocks the boot before
the initramfs runs; whether it does looked fixed per boot image, but is a
race (below).

**Cause, measured the same day** with msm DRM as a module
(`CONFIG_DRM_MSM=m`, `modprobe.blacklist=msm`, loaded by hand over ssh,
`dmesg -w` streamed to the host):

- The bootloader leaves the display engine scanning out its framebuffer at
  `0x9c000000`.  When msm attaches the display to the SMMU, those reads
  fault: `arm-smmu 15000000.iommu: Unhandled context fault ...
  iova=0x9c000000`, SIDs `0x800`/`0xc20`, then
  `disp_cc_mdss_pclk0_clk_src: rcg didn't update its configuration` and
  `dsi_err_worker: status=4` (`build/logs/msm-modprobe-dmesg-2-2026-11-07.log`).
- It is a race: the same image, twice.  Once the system crawled for a minute
  (`hrtimer: interrupt took 27835729 ns`, UFS command timeouts, msm up only
  at 75 s; `build/logs/msm-modprobe-dmesg-2026-11-07.log`); once a burst of
  10 faults, msm up in 20 ms, handoff `compression enable sent, err 0`, and
  `login:` on the panel.  Built in, msm meets the race at 0.6 s, where a lost
  race also stops the boot before the initramfs.
- Not the kernel, not the panel driver: the panel handoff runs only after the
  faults.

- A third outcome, measured later that day with a tracing kernel
  (`-trace`, `build/logs/msmrun-*-2026-11-07-*.log`): faults over the whole
  framebuffer, then msm's fault handler takes a display snapshot that
  oopses in `dpu_crtc_duplicate_state`, no handoff, a frozen panel
  (`build/logs/msm-snapshot-oops-2026-11-07.log`).  Writing
  `options/func_stack_trace` while the irqsoff tracer runs oopses the
  kernel (`build/logs/trace-oops-func-stack-trace-2026-11-07.log`): do not.

**Fixed 2026-11-07** by `kernel/patches/0003-drm-msm-dpu-stop-the-bootloader-s-scanout-before-att.patch`.
The panel is in command mode, and the bootloader leaves autorefresh on in
the INTF tear check (DPU 5.0 keeps tear check and autorefresh in the INTF,
not the pingpong: `dpu_encoder_phys_cmd_init`, "DPU before 5.0 use PINGPONG
for TE handling"); msm switches it off only at its first commit, after the
IOMMU attach.  The patch switches it off before the attach, as mdp4/mdp5 do
("make sure things are off before attaching iommu", `mdp5_kms_init`).  Measured:
`intf_1: bootloader autorefresh 0x80000001, stopping`, then 0 SMMU faults,
handoff `err 0`, `login:` on the panel -- 4 of 4 loads (`msmrun-p2..p5`),
against faults in 7 of 7 loads without it.  An earlier plan here
(`iommu-addresses` in the DTS) would not have worked: it covers only the
device's default domain, and msm attaches a domain of its own
(`msm_iommu_disp_new`).

Still logged on every load, not from the IOMMU, not yet looked at:
`disp_cc_mdss_pclk0_clk_src: rcg didn't update its configuration` and
`dsi_err_worker: status=4`.

Boot with 0003 and without `modprobe.blacklist=msm`, measured the same day:
kernel `7.0.0-sm8150-ge634e5b247d2`, udev loads msm at 4.2 s, autorefresh
stopped, 0 SMMU faults, handoff `err 0`, console and `login:` on the panel,
ssh about 10 s after the reboot (`build/logs/boot-msm-udev-2026-11-07.log`).

**Second defect, fixed 2026-11-08 by
`kernel/patches/0004-drm-msm-mdss-keep-the-MDSS-active-until-the-DPU-stop.patch`:
the boot crawls.**  With 0003 alone, about one boot in three (2 of 10 on
2026-11-07, 5 of about 12 on 2026-11-08, warm reboots by `sysrq b`, also
after a cold start): garbled panel, USB network up but ping at 130-330 ms,
sshd never comes up.  Caught over netconsole (`CONFIG_NETCONSOLE`, stage-1
script `soc/sm8150/rootfs-void/etc/runit/core-services/01-netconsole.sh`,
host `tools/netconsole-listen.sh`; `build/logs/netconsole-hang-1-2026-11-07.log`
and `build/logs/netconsole-2026-11-07.log`, which kept growing on 2026-11-08):
`hrtimer: interrupt took 5-25 ms` right after msm starts, `sched: RT
throttling activated`, UFS command timeouts, vblank and commit timeouts,
the whole system 4 to 15 times slower than real time.

How it was narrowed down, each step a measurement:

- Not one interrupt storming: `/usr/bin/irqwatch` (`soc/sm8150/rootfs/`,
  opt-in `/etc/makronix-irqwatch`) saw no counter in `/proc/interrupts`
  grow beyond timer, UFS and IPIs.  `/proc/interrupts` cannot show a
  chained parent (`irq_set_chained_handler_and_data`, the MDSS
  demultiplexer) or a child without an action, so irqwatch also logs the
  per-CPU hardirq share from `/proc/stat` (`CONFIG_IRQ_TIME_ACCOUNTING`): in
  the next crawl all 8 CPUs were at 36-54% hardirq -- every handler, the
  timer tick included, about 100 times slower: the bus, not one interrupt.
- Not the bandwidth votes: `interconnect_summary` shows every node at the
  maximum (`2147483647`); no provider has reached `sync_state`.
- Not an IOMMU fault: `qcom,sm8150-mdss` gets an identity default domain
  (`arm-smmu-qcom.c`, `qcom_smmu_client_of_match`).
- Where: `initcall_debug` switched on in stage 1 (opt-in
  `/etc/makronix-initcall-debug`, `01-initcall-debug.sh`; it is a run-time
  `core_param`): `probe of ae00000.display-subsystem returned 0 after
  18832329 usecs`, nested in it `probe of ae94400.phy ... after 6714804
  usecs`; in a good boot 30 ms and 0.6 ms.
- Why: the DSI PHY's probe takes and drops runtime references, which
  resume and suspend the MDSS parent; `msm_mdss_disable` switches the MDSS
  clocks off -- in hardware, because Linux held no count on the clocks the
  bootloader left on -- while the bootloader's autorefresh (0003 stops it
  only later, in `dpu_kms_hw_init`) still fetches from memory.
- Proof without a kernel change: `power/control = on` for the MDSS before
  udev loads msm (opt-in `/etc/makronix-mdss-rpm-on`,
  `01-mdss-rpm-on.sh`): 0 crawls in 15 warm reboots.

0004 takes a runtime reference in `mdss_probe` before the children are
populated and lets the DPU drop it in `dpu_kms_hw_init` once 0003 stopped
the boot scanout.  Measured with only msm.ko replaced (switch off): 0
crawls in 20 warm reboots, MDSS probe at most 27.4 ms, autorefresh stopped
in all 20.

Found on the way, not yet fixed: the MDSS node in `sm8150.dtsi` (this tree
and `~/src/sm8150-617`) says `resets = <&gcc DISP_CC_MDSS_CORE_BCR>` -- a
dispcc index on the GCC, so `msm_mdss_reset` holds `GCC_EMAC_BCR` (index 0,
`gcc-sm8150.c`) for 20 ms and never resets the MDSS.  The pinned DTB has
the same (`resets = <0x2c 0x00>`, phandle 0x2c = `clock-controller@100000`).
Since 2026-11-08 the property is gone (`kernel/patches/0010`; why not
the dispcc reset: "the DTS in the tree", below).

## Measured 2026-11-08, after 0004

- msm is built in again (`CONFIG_DRM_MSM=y`, its helpers with it): with
  0003 and 0004 the race it met at 0.6 s is gone.  `Initialized msm` at
  0.59-0.76 s instead of 4.2 s, `fb0` at 0.68 s.
- `rcg didn't update its configuration` is gone with
  `kernel/patches/0005` (`CLK_OPS_PARENT_ENABLE` on the pixel RCGs, as
  sdm845's dispcc has it).
- `dsi_err_worker: status=4` was no FIFO error: the raw registers
  (temporary debug print) were `ack=01003f06 ... fifo=11111010`, i.e. every
  lane FIFO *empty*, which dsi_fifo_status counted as an error, and an ACK
  error, which `DSI_ERR_STATE_ACK = 0` hid.  It is the panel's error report
  on the first read after msm takes the link over (the panel driver's
  retry reads cleanly: `tries 2`).  `kernel/patches/0006` reports it as
  what it is: `dsi_err_worker: status=40 ack_err=01003f06`, once per boot.
- The DTB carries the PON reboot modes since this day, for `reboot-mode
  bootloader` (docs/BOOT.md): added to the pinned binary as an interim step,
  until the DTS moves into the tree --

      fdtput -t u sm8150-oneplus-hotdogb.dtb /soc@0/spmi@c440000/pmic@0/pon@800 mode-bootloader 2
      fdtput -t u sm8150-oneplus-hotdogb.dtb /soc@0/spmi@c440000/pmic@0/pon@800 mode-recovery 1

  (sdm845's pm8998.dtsi has the same two; `dtc -s` diff: only these two
  lines).  Pin `DTB_SHA256_PREFIX` 915e91eb7e2b1d3b -> 8eb4b7a7c6a6d346.
  Measured: the modes in `/proc/device-tree`, fastboot 7 s after
  `reboot-mode bootloader`.
- The state of this day (kernel `7.0.0-sm8150-g1299aab93171`, patches
  0001-0006, msm built in, the DTB above, root image with usb0-dhcp,
  ACM console, zram-swap): 20 of 20 warm reboots reachable
  (`tools/reboot-loop.sh 20`), `zram0` 3.8 GB swap, `landlock: Up and
  running`, tracers `function_graph function`.  Flashed without a button:
  `reboot-mode bootloader`, then `tools/flash-root.sh` and `tools/flash.sh`
  (`build/logs/selfflash3-2026-11-08.log`).

## Measured 2026-11-08: the DTS in the tree

Kernel `7.0.0-sm8150-g3c5fa409ca54`, patches 0001-0012.

- 0007: the DTS of c4195dd0d (above), on the 7.0 tree's includes, with the
  PON modes.  `dtc -s` against the old binary: only renumbered phandles and
  what the 7.0 `sm8150.dtsi` has that the 6.17 one had not (IPA and its
  smp2p entries, disabled; `#address-cells` on the GIC; the timer frame
  `17c27000`; DP pixel 1 clock, DP disabled).  Boots like the binary.
  The 7.0 tree's older `sm8150-oneplus-hotdogb.dts` (compatible
  `"oneplus,hotdobg"`) is replaced.
- 0008: the ABL framebuffer is reserved (`cont_splash_mem`, 0x9c000000,
  36 MiB, no-map; simplefb by `memory-region`).  Gone: `simplefb: cannot
  reserve video memory` and the `ioremap attempted on RAM pfn` WARN;
  `simplefb registered!` at 0.32 s, `/proc/iomem` `9c000000-9f7fffff :
  reserved`.
- 0009: with fbcon on simplefb first, msm's fbdev warned
  `fb0: sys_imageblit: framebuffer is not in virtual address space`
  (msm_fbdev never set `FBINFO_VIRTFB`); set, gone.
- 0010, the MDSS reset: the DT named `DISP_CC_MDSS_CORE_BCR` on the GCC
  (= `GCC_EMAC_BCR`).  Measured with the right one, `<&dispcc
  DISP_CC_MDSS_CORE_BCR>`: the reset works (no autorefresh left to stop),
  but it stops the DSI PHY PLL (`PLL(0) lock failed`, `dsi0_phy_pll_out_dsiclk
  already disabled` WARNs from the orphan reparenting of the pixel RCGs
  under 0005's `CLK_OPS_PARENT_ENABLE`), and with those warnings silenced
  by a clk core change the panel was **white** (Konrad, 2026-11-08):
  msm does not restore everything ABL set up.  0010 therefore drops the
  property (msm treats the reset as optional); the clk core change went
  with it.
- 0011: the `gs_close` WARN of u_serial after login's vhangup was a double
  close: with `/dev/console` on ttyGS0 the tty core closes the port once
  per file at the hangup, and again when each file is released.
  `gs_hangup` plus `tty_hung_up_p()` in `gs_close`, as `tty_port` drivers.
  Measured: login, `exit`, agetty again, no WARN.
- 0012, USB OTG: DWC3 `dr_mode = "otg"` with `usb-role-switch`, the
  pm8150b Type-C port (TCPM) and VBUS regulator on, the connector linked to
  the DWC3's high-speed endpoint (as `sm8150-google-flame.dts`).  On the
  laptop's cable: `typec/port0` data role `[device]`, power role `[sink]`,
  `usb_role` `device`, USB network as before.  Host mode (an OTG adapter)
  not measured yet.  `allow_userspace_control`: `echo host >
  /sys/class/usb_role/a600000.usb-role-switch/role` forces it.
- Wall clock: the PMIC RTC is read-only to Linux and reads 1970-08;
  `rtc-offset` (soc/sm8150/rootfs/usr/bin) keeps the offset in
  `/var/lib/makronix/rtc-offset`, loaded in stage 1, saved in stage 3;
  `tools/phone-time.sh` sets it from the host.  Measured: correct time after
  the next boot.
- BTF: `/sys/kernel/btf/vmlinux` present.
- 10 of 10 warm reboots reachable (`build/logs/reboot-loop-g3c5fa409-2026-11-08.log`),
  0 `WARNING` in dmesg, the clock right after each; display good
  (Konrad).

Same day, our initramfs (`base/initramfs`) instead of pmOS's: `make flash`
with the pinned one (`INITRAMFS_SHA256_PREFIX` 4950e286679ca4fa, boot image
eb7f310439495b96), `switch_root` at 1.27 s, a fresh root image grown online
on the first boot, 10 of 10 warm reboots
(`build/logs/reboot-loop-ownrd-2026-11-08.log`), 0 `WARNING`.

## Measured 2026-11-08: Bluetooth

`kernel/patches/0013`: WCN3998 on uart13.  Firmware from the phone's own
`bluetooth_<slot>` partition (vfat, `image/crbtfw21.tlv`, `crnv21.bin`),
mounted read-only at boot and put first in the firmware loader's path
(`/etc/makronix/firmware-partitions`, `firmware-partitions` in
`soc/sm8150/rootfs`); nothing of it is in our images.  The controller has no
address of its own (none in its NVM, none on the command line, `persist`
has only an empty `wlan_mac.bin`): `bt-address` gives it one derived from
`androidboot.serialno` (02:a4:00:f3:32:74 on this phone), from a udev rule.
Measured: `QCA setup on UART is completed` at 3.3 s, the same address after
a reboot, bluez 5.86 scans 14 devices.  Seen once per boot, harmless:
`Frame reassembly failed (-84)` during the baud-rate switch.
For WLAN, later: `persist` holds the board data `bdwlan.bin`.

## Measured 2026-11-08: modem, WLAN, charger, fuel gauge

- Modem (`kernel/patches/0015`): firmware from the phone's own `modem_<slot>`
  (vfat `image/modem.mdt`, `/etc/makronix/firmware-partitions`), started by
  rmtfs (`-r -P -s`: read-only, writes stay in memory, `storage.c`); the EFS
  partitions (`modemst1/2`, `fsg`, `fsc`) and `persist` are backed up in
  `~/src/nura/hotdogb-backup` (`SHA256SUMS.efs`).  rmtfs at the dtsi's
  0x89b00000 was refused (`Assign memory protection call failed -22`): it
  lies in the stock map's `removed_regions` (0x86200000-0x8b700000, the
  stock DT `twrp-3.7.0_12-1-hotdogb.img` dtb.08 + `dtbo_a.img` entry 3);
  tz_mem now covers it, rmtfs moved to 0xf2900000 with guard pages.
- The WLAN domain of the modem starts only when the PD mapper answers:
  `qcom_pd_mapper` is loaded in stage 1 (`modules-load.d`) -- loaded by
  udev in stage 2 it came too late, and no WLAN service ever appeared.
- WLAN: the firmware (WLAN.HL.3.0) crashed the modem twice per start
  (`WCSS_WLAN1_GDSCR.PWR_ON`, then `CCPM: PLL lock failed`).  Two causes:
  the WCN had no power before ath10k's QMI handshake
  (`kernel/patches/0014`, `qcom,keep-powered`, as stock's icnss), and the
  generic board data linux-firmware gives a chip without board id (0xff).
  The phone's own, `persist/bdwlan.bin` (none of the modem partition's
  `bdwlan.*`), wrapped by `ath10k-board` into
  `/run/makronix-firmware/ath10k/WCN3990/hw1.0/board-2.bin` (`wlan-board`,
  stage 1): `wifi fw ready`, no crash, `wlan0`, a scan finds 12 networks on
  2.4 and 5 GHz, Bluetooth alongside.
- `vreg_l11c_3p3` stays at 3.0 V: with stock's 3.104 V minimum the display
  was white once, at 3.0 V normal -- but the display was white again later
  at 3.0 V, so this is not settled (below).
- Charger and gauge (`kernel/patches/0016`): before, the PMIC took about
  110 mA from USB (ADC `usbin_i`); now `pm8150b-charger` charges with a
  450 mA limit (the port offers USB default current), and the bq27411 at
  i2c8 0x55 reads 4.433 V, 100 %, 32.9 C.

## 2026-11-10: boot splash

The Makronix M (`docs/logo/makronix-square-1080.png`) is the kernel's
fbcon logo: full width, centred, once (`KERNEL_LOGO` in device.conf,
`tools/build-kernel.sh` converts it to the 224-colour PPM that
`CONFIG_LOGO_LINUX_CLUT224_FILE` names; cmdline `fbcon=logo-pos:center
fbcon=logo-count:1`).  agetty on tty1 clears it away at the login
(`soc/sm8150/rootfs-void/etc/sv/agetty-tty1/conf`, Void's without
`--noclear`).  `kernel/patches/0021` keeps the logo after init: msm
registers its framebuffer at 0.87-1.1 s, and when that was after
late_initcall the logo was already freed (no logo in a boot at 1.1 s).
`kernel/patches/0022` switches the panel on 100 ms after .enable instead
of at the end of its on-sequence: before, the panel showed its frame
memory (noise, stripes) for about half a second.  Measured with the
camera (`build/cam/boot-0022b.mp4`): bootloader logo, dark, the M, then
the login.  The first boot after a fastboot flash can still show stripes
for a moment (ABL leaves the panel in another state there).

## Measured 2026-11-10: WLAN missing in some boots, solved

WLAN was missing in 2-3 boots of 15: the modem came up, its WLAN service
never appeared, and the modem crashed 40 s later.  `qrtr-lookup` at 25 s
showed that in those boots the modem had no QRTR service at all -- only
the phone's own 14 (rmtfs), 64 (PD mapper) and 4096 (tqftpserv) on node 1
(`build/logs/wlan-qrtr-2026-11-10.log`; a good boot,
`build/logs/qrtr-good-2026-11-10.log`, lists about 50 on node 0, the WLAN
firmware 69 among them).  The QRTR transport to the modem, `qrtr_smd`,
was loaded by udev when the modem's IPCRTR channel appeared, from rmtfs in
stage 2 -- the same race as the PD mapper before.  Loaded in stage 1 now
(`soc/sm8150/rootfs/etc/modules-load.d/qcom-pd-mapper.conf`): WLAN in 15
of 15 boots, `qrtr_smd` loaded and bound in all
(`build/logs/wlan-qrtrsmd-2026-11-10.log`).  rmtfs waiting for tqftpserv
(`etc/sv/rmtfs/conf`) stays; it was not the cause.

## Measured 2026-11-08: the white display, solved

The display came up white in some boots.  Counted with a camera on the
screen (`tools/phone-screen.sh`, `tools/display-loop.sh`: 0 for the black
console, 255 white; logs `build/logs/display-loop*-2026-11-08.log` with a
frame per boot):

| kernel, panel driver                     | white      |
|------------------------------------------|------------|
| handoff (take ABL's panel state over)    | 4 of 30    |
| handoff, PPS sent on handoff             | 10 of 30   |
| handoff, interrupt rates recorded        | 11 of 30   |
| full init (`handoff=0`, cmdline)         | 0 of 30    |
| full init by default (`kernel/patches/0019`) | 0 of 10 |

In white boots msm kept sending frames (about 75 msm and 9-10 DSI
interrupts per 2 s, as in good boots); neither the compression state the
panel reported at handoff, nor the PPS, nor the SMMU faults, nor msm's
timing predicted it.  The panel's state after ABL is not usable in about
a quarter of the boots; resetting it and sending the stock 18865
sequence (60 Hz, PPS, vendor registers) is.  `0017` (clearing ABL's blend
stages) stays: the faults it addresses are real, though harmless for the
picture.  Seen 2 times in 40 full-init boots: no msm/DSI interrupt for
2 s with a good picture (an idle console, or the measurement) -- not
followed up.

Open:
- "The phone is off" (three times) -- explained, 2026-11-08: each was a
  short press on the power key (netconsole: `elogind: Power key pressed
  short.` / `Powering off...`, e.g. while the phone was placed in front of
  the webcam), elogind's default being power-off; and every power-off or
  restart with the modem running hung right after `stopped remote
  processor modem` (ath10k still loaded), and the watchdog left the phone
  in Qualcomm's crash-dump mode, USB 05c6:900e, screen dark.  Fixed by
  `base/void/rootfs/etc/elogind/logind.conf.d/makronix-phone.conf`
  (HandlePowerKey=ignore), the stage 3 hook
  `05-wlan-before-modem.sh` (ath10k unloaded before rmtfs stops the
  modem: `reboot-mode bootloader` with WLAN connected reaches fastboot in
  12 s, the log runs to the end), and `kernel/patches/0018` (qcom_scm
  clears the bootloader's download-mode bit, so a hang on the way down
  resets instead of leaving the phone in 900e).  The hang itself (ath10k
  loaded while the modem stops) is avoided, not fixed in the kernel.

WLAN address (2026-11-08): the WCN399x has no MAC address (`ath10k_snoc:
invalid MAC address; choosing random`), so each boot was a new device to
the router, and after a day of test boots its DHCP pool had no address
left (associated, a static address pinged the router, DHCP unanswered).
`wlan-address` (udev) gives wlan0 one derived from the serial number
(ce:c4:60:1e:a8:cd), NetworkManager keeps it
(`base/void/rootfs/etc/NetworkManager/conf.d/makronix-wifi-mac.conf`):
DHCP lease at once.  Bluetooth failed its second setup in 2 of 3 boots
(`Frame reassembly failed (-84)`, `Failed to send TLV segment (-110)`)
-- not yet followed up.

Open: the DSI `Invalid response cmd 0x00` on the first read after the
takeover (the panel driver's retry reads cleanly, as with the ACK error);
OTG host mode; netconsole misses the first seconds of a boot since the ACM
rebind (the serial console has them).


################################################################
## mobile/userland/AGENTS.md  (last commit 2026-11-11)
################################################################
# mobile/userland/ -- NetBSD programs for the phone

What this is for: the programs of our `src/` built for the phone's Linux
(aarch64, glibc), one directory per program.  The plan is
`../docs/NETBSD-USERLAND.md`; how to port one program is
`../docs/PORTING-USERLAND.md` -- read both before you add or change a port.

What is in it:

    Makefile           the steps: mx-dirs, mx-compat, every port (found, not
                       listed); run as `make userland [PROG=x]` from mobile/
    mk/mx.prog.mk      the frame a port includes (NetBSD's
                       src/tools/Makefile.host with the phone as "host")
    mk/mx.dist         the destdir hierarchy (mtree), Void's usr-merged layout
    lib/mxlinux/       libmxlinux: what NetBSD's headers/libc have and glibc
                       lacks -- include/mxlinux.h (forced into every port) and
                       the library (NetBSD's getopt, signalname, humanize_number,
                       getbsize ...; ours: sys_signame, fgetwln, LC_C_LOCALE).
                       SIGINFO is SIGPWR, named INFO (Konrad, 2026-11-11)
    <prog>/Makefile    MX_SRCDIR= <dir under src/>, include ../mk/mx.prog.mk
    <prog>/test.sh     the port's test: NetBSD's own (src/tests/...) in plain
                       sh plus the man page's cases; `make userland-test PROG=x`
    <prog>/REPLACES    the Void files and package it supersedes on the phone
    <prog>/AGENTS.md   state of the port (first line), agent, date, evidence

What may be changed and how:

- A port's directory belongs to the agent that claimed it (its AGENTS.md,
  first line `state: claimed`).  Look first: `tools/userland-status.sh`.
  States: claimed, builds, runs-qemu, runs-phone, done, blocked: <why>.
- A NetBSD interface glibc lacks goes into lib/mxlinux, not into a port,
  as soon as it is not specific to one program: NetBSD's source through
  .PATH if it runs on glibc, else an mx_*.c; its declaration in
  include/mxlinux.h with the NetBSD header line.
- `mk/` and `lib/` are shared by every port: change it only with every `done` port
  rebuilt and its test green afterwards (`make userland`, then
  `make userland-test PROG=<each>`), and say so in the commit.
- Commit with explicit paths only (other agents share the index).

What must not be touched from here:

- `src/` beyond a change behind `__linux__` that keeps the NetBSD build
  green (root AGENTS.md: a broken NetBSD convention is a finding, not a
  quiet change).  Prefer the frame, libnbcompat or libmxlinux.
- The phone's /system and boot slots: a port is tested in
  /tmp/userland-test on the phone (tools/userland-test.sh), nothing else.


################################################################
## mobile/userland/basename/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.13 (docs/NETBSD-USERLAND.md)

basename(1) from src/usr.bin/basename, unchanged.  Its Makefile's
`MLINKS= basename.1 dirname.1` is installed by the frame: a man-page link
goes through install.files, not through the LINKS rule that Makefile.host
undefines, so destdir/usr/share/man/man1/dirname.1 is a hard link to
basename.1 here (link count 2).

What the port adds, and why:
- `CPPFLAGS+= -include nbtool_config.h`.  basename.c does not include
  nbtool_config.h itself (cat.c:36 does), so glibc's <sys/cdefs.h> is what
  defines __COPYRIGHT/__RCSID/__dead -- and it defines none of them.  Without
  the include the build stops at the first line, measured with this frame's
  compiler and flags (build/logs/port-basename-2026-11-11.log is the build
  with it):
      src/usr.bin/basename/basename.c:34:13: error: expected declaration
      specifiers or '...' before string constant
         34 | __COPYRIGHT("@(#) Copyright (c) 1991, 1993, 1994\
  src/tools/compat/compat_defs.h:211,709,713 supplies the three macros once
  nbtool_config.h has been read.

Tests: NetBSD has src/tests/usr.bin/basename/t_basename.sh, and its two cases
(basic, 8 atf_check, suffix, 4) are all in test.sh as one case each; then
three cases from basename.1: a non-existent suffix is ignored, a string with
no slash stays whole, and no operand is an error with a message (EXIT
STATUS).  One case was wrong in the first draft and is fixed against the man
page, not against the port: "non-existent suffix" was tested with a suffix
of the same length as the name ("x.z" for "x.y"), where basename.c:87 does
not even look for the tail; the case now uses a shorter, different suffix.

Evidence (2026-11-11, hotdogb):
- build: `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`
  exit 0, no "*** Error", no warning; "mxcheck: basename ok"
  (build/logs/port-basename-2026-11-11.log).
- test.sh under qemu: 15 PASS, 0 failed
  (build/logs/port-basename-qemu-2026-11-11.log).
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/basename):
  15 PASS, 0 failed (build/logs/port-basename-phone-2026-11-11.log).
- REPLACES: /usr/bin/basename is coreutils-9.4_1 on the phone
  (`xbps-query -o /usr/bin/basename`).
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/cat/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: claude (Opus 5.5), 2026-11-11
item: C1.1 (docs/NETBSD-USERLAND.md)

cat(1) from src/bin/cat, unchanged; the first port, made together with the
frame (docs/PORTING-USERLAND.md is written from it).

Evidence (2026-11-11):
- `make userland PROG=cat` from an empty build/userland/hotdogb: exit 0, no
  error, no warning (build/logs/make-userland-cat-clean-2026-11-11.log).
- mxcheck: needs only libc.so.6, no symbol version newer than the phone's
  glibc 2.41 (the -lz of libnbcompat's defs.mk is dropped by the linker).
- test.sh under qemu: 5 PASS, 0 failed -- NetBSD's t_cat.sh cases align,
  nonexistent, se_output with its data, plus -n -t -v and -s on stdin.
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/cat):
  5 PASS, 0 failed (build/logs/port-cat-phone-2026-11-11.log).
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/comm/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.15 (docs/NETBSD-USERLAND.md)

comm(1) from src/usr.bin/comm; comm.c is used unchanged.

Port-local change (in this directory's Makefile, src/ untouched):
- `CPPFLAGS+= -include nbtool_config.h`: comm.c has no
  `#include nbtool_config.h`, so `__COPYRIGHT`/`__RCSID`/`__dead` are
  undefined under the host's glibc cdefs and the file does not compile
  ("expected declaration specifiers ... before '__COPYRIGHT'");
  libnbcompat's header defines them.

Evidence (2026-11-11):
- Build: log build/logs/port-comm-2026-11-11.log, exit 0, no "*** Error",
  no warning; installed build/userland/hotdogb/destdir/usr/bin/comm
  (+ man1/comm.1).
- mxcheck: `mxcheck: comm ok`.
- test.sh under qemu: 5 PASS, 0 failed -- three-columns,
  suppress-column-1, suppress-column-3, common-only, fold-case.
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/comm):
  5 PASS, 0 failed (build/logs/port-comm-phone-2026-11-11.log).
- src/tests/usr.bin/comm does not exist; the cases are comm(1)'s: the
  three columns with "a number of tab characters prepended ... equal to
  the number of lower numbered columns that are being printed" (0/2 tabs
  unsuppressed, 1 tab for column 3 with -1, none for common-only with
  -12), -1, -3, and -f ("Fold case in line comparisons", the text printed
  being file1's).  The two sorted input files are made by the test.
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/consmirror/AGENTS.md  (last commit 2026-11-12)
################################################################
state: done
agent: claude (Opus 5.5), 2026-11-11
item: Makronix's own (Konrad, 2026-11-11: "i want to see on serial what I see on the display, of course not when it comes to X")

consmirror(8): the display's text console on the USB serial line, both ways.
Our own source (src/ in this directory, MX_LOCALSRC), BSD licence, NetBSD
style; not a port of NetBSD's src/.  Output from /dev/vcsu1 + /dev/vcsa1
(poll POLLPRI on change, only changed lines are drawn); input through a
uinput keyboard (US layout, control keys, arrows).  Run by the runit service
consmirror (soc/sm8150/rootfs-void/etc/sv/consmirror) instead of
agetty-ttyGS0; console=ttyGS0 is off the kernel command line, the kernel's
messages are on the display and so in the mirror.

Evidence (2026-11-11, on the phone, /tmp/cm, getty on ttyGS0 stopped):
- a line written to /dev/tty1 arrives on the host's /dev/ttyACM2;
- "echo typed-over-serial-$((6*7))" typed on the host appears on tty1
  (in the login prompt -- nobody was logged in there) and back on serial;
- the first build dropped every frame (85 KB arrive after the fix, 5.7 KB
  before): u_serial's buffer is smaller than a screen, so a write that
  returns EAGAIN now waits for POLLOUT up to 0.5 s before giving up.


################################################################
## mobile/userland/dirname/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.13 (docs/NETBSD-USERLAND.md)

dirname(1) from src/usr.bin/dirname, unchanged.  The program is the libc's
dirname(): src/usr.bin/dirname/dirname.c calls dirname(3) from <libgen.h>,
which on the phone is glibc's implementation, not NetBSD's.

What the port adds, and why:
- `CPPFLAGS+= -include nbtool_config.h`.  dirname.c does not include
  nbtool_config.h itself (cat.c:36 does); the tools frame only passes
  -DHAVE_NBTOOL_CONFIG_H, so __COPYRIGHT/__RCSID/__dead stay undefined and
  the build stops at the first line, measured with this frame's compiler and
  flags:
      src/usr.bin/dirname/dirname.c:34:13: error: expected declaration
      specifiers or '...' before string constant
         34 | __COPYRIGHT("@(#) Copyright (c) 1991, 1993, 1994\
  src/tools/compat/compat_defs.h:211,709,713 supplies the macros once the
  header has been read.
- `MAN=`.  src/usr.bin/dirname/Makefile says "NOMAN= # defined": dirname has
  no page of its own, basename.1 documents both and is linked to dirname.1 by
  basename/Makefile (`MLINKS=`).  bsd.hostprog.mk:132 defaults MAN to
  ${HOSTPROG}.1 without looking at NOMAN, and realall then wants a
  src/usr.bin/dirname/dirname.1 that does not exist.  The port states the
  empty list; the page arrives with the basename port.

One measured divergence from NetBSD, in libc, not in this program:
`dirname //` answers "/" on NetBSD (src/lib/libc/gen/dirname.c strips the
trailing and then the doubled slash) and "//" on the phone, because glibc
keeps a leading "//" as a root of its own.  POSIX makes the case
implementation-defined ("If path is //, it is implementation-defined whether
steps 3 to 6 are skipped or processed", XCU dirname), so both are conforming.
test.sh keeps NetBSD's atf case, accepts either answer and prints
"NOTE basic-2: // -> //" so the difference is visible in every log; the other
eight cases of t_dirname.sh are NetBSD's answer exactly, including
"//usr//bin//" -> "//usr", where the two libcs agree.

Tests: NetBSD's src/tests/usr.bin/dirname/t_dirname.sh has one case (basic, 9
atf_check) -- all nine are in test.sh; then basename.1's example
(`dirname /usr/bin/trail` -> /usr/bin) and the EXIT STATUS case (no operand
is an error, with a message).

Evidence (2026-11-11, hotdogb):
- build: `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`
  exit 0, no "*** Error", no warning; "mxcheck: dirname ok"
  (build/logs/port-dirname-2026-11-11.log).
- test.sh under qemu: 11 PASS, 0 failed, with the NOTE above
  (build/logs/port-dirname-qemu-2026-11-11.log).
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/dirname):
  11 PASS, 0 failed, the same NOTE (build/logs/port-dirname-phone-2026-11-11.log).
- REPLACES: /usr/bin/dirname is coreutils-9.4_1 on the phone
  (`xbps-query -o /usr/bin/dirname`).
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/echo/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.2 (docs/NETBSD-USERLAND.md)

echo(1) from src/bin/echo, unchanged.  NetBSD has no test for it
(src/tests/bin/echo does not exist), so test.sh carries the cases of echo(1)
itself: operands separated by single blanks and followed by a newline, -n,
and that -e is a string like any other and a backslash is not an escape.

Evidence (2026-11-11):
- mxcheck: echo ok, exit 0 (build/logs/port-echo-2026-11-11.log); installed
  as destdir/usr/bin/echo (mode 555) and
  destdir/usr/share/man/man1/echo.1.
- test.sh under qemu: 5 PASS, 0 failed
  (build/logs/port-echo-qemu-2026-11-11.log).
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/echo):
  5 PASS, 0 failed (build/logs/port-echo-phone-2026-11-11.log).
- REPLACES: /usr/bin/echo is coreutils-9.4_1 on the phone (xbps-query -o
  /usr/bin/echo).
- The FAIL path is real: run with coreutils' /bin/echo as the command, the
  case no-other-options fails (-e and \t are escapes there) and the test
  exits 1.

The Makefile adds one thing and no helper file: CPPFLAGS+= -include
nbtool_config.h.  echo.c includes that header only in NetBSD's host-tool
build; without the preinclude the aarch64 compiler stops at

  echo.c:34:1: error: expected declaration specifiers or '...' before string
               constant                      (__COPYRIGHT)
  echo.c:40:9: error: expected declaration specifiers or '...' before string
               constant                      (__RCSID)
  echo.c:56:9: error: implicit declaration of function 'setprogname'

The header gives __COPYRIGHT/__RCSID their declarations and names
setprogname() out of libnbcompat (compat_defs.h:611-614, 709-715).

Not yet in the image: A7 (assemble-rootfs, REPLACES) is not done.


################################################################
## mobile/userland/env/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.16 (docs/NETBSD-USERLAND.md)

env(1) from src/usr.bin/env; env.c is used unchanged.

Port-local change (in this directory's Makefile, src/ untouched):
- `CPPFLAGS+= -include nbtool_config.h`: env.c has no
  `#include nbtool_config.h`, so `__COPYRIGHT`/`__RCSID`/`__dead` are
  undefined under the host's glibc cdefs; libnbcompat's header defines them.
- the BSD getopt of the tree (SRCS= env.c getopt.c, from
  src/common/lib/libc/stdlib): env.c calls
  `getopt(argc, argv, "-0C:iu:")` (env.c:71) and expects the BSD "-"
  form, where a non-option word ends the scan.  glibc treats the same
  leading "-" as "return every non-option word as option 1"; measured
  with a probe against the phone's sysroot: `env-probe -i A=1` returned
  optind=3 with 'A=1' as getopt's value 1, which env.c's default case
  turns into usage and exit 125 (`env -i A=1` set nothing).

Evidence (2026-11-11):
- Build: `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`
  from this directory, log build/logs/port-env-2026-11-11.log, exit 0, no
  "*** Error", no warning; installed
  build/userland/hotdogb/destdir/usr/bin/env (+ man1/env.1).
- mxcheck (same log): `mxcheck: env ok`.
- test.sh under qemu: 6 PASS, 0 failed -- clear-and-set, nul-separated,
  utility-environment, utility-exit-status, unset-name, utility-not-found.
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/env):
  6 PASS, 0 failed (build/logs/port-env-phone-2026-11-11.log).
- src/tests/usr.bin/env does not exist, so there was no atf test to
  translate; the 6 cases are env(1)'s: -i, -0, -u, a utility and its exit
  status, and 127 for a utility that cannot be found.
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/fold/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.15 (docs/NETBSD-USERLAND.md)

fold(1) from src/usr.bin/fold; fold.c is used unchanged.

Port-local changes (in this directory's Makefile, src/ untouched):
- `CPPFLAGS+= -include nbtool_config.h`: fold.c has no
  `#include nbtool_config.h`, so `__COPYRIGHT`/`__RCSID`/`__dead` are
  undefined under the host's glibc cdefs and the file does not compile;
  libnbcompat's header defines them.
- `CPPFLAGS+= -D_XOPEN_SOURCE=700`: new_column_position() calls
  wcwidth(), which the phone's <wchar.h> declares only under
  __USE_XOPEN and libnbcompat's narrowing of the feature macros leaves
  out.  Measured without it: "fold.c:226:29: error: implicit declaration
  of function 'wcwidth' [-Wimplicit-function-declaration]".

Evidence (2026-11-11):
- Build: log build/logs/port-fold-2026-11-11.log, exit 0, no "*** Error",
  no warning; installed build/userland/hotdogb/destdir/usr/bin/fold
  (+ man1/fold.1).
- mxcheck: `mxcheck: fold ok`.
- test.sh under qemu: 5 PASS, 0 failed -- default-width, width-option,
  split-at-blank, split-without-blank, width-in-bytes.
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/fold):
  5 PASS, 0 failed (build/logs/port-fold-phone-2026-11-11.log).
- src/tests/usr.bin/fold does not exist; the cases are fold(1)'s: the
  default 80 columns, -w, -s at a blank within the width (the blank is
  dropped) and -s without a blank ("a longer line will still be split at
  the width"), and -b ("count width in bytes").
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/head/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.14 (docs/NETBSD-USERLAND.md)

head(1) from src/usr.bin/head, unchanged.

What the port adds, and why:
- `CPPFLAGS+= -include nbtool_config.h`.  head.c does not include
  nbtool_config.h itself (cat.c:36 does); the tools frame only passes
  -DHAVE_NBTOOL_CONFIG_H, and glibc's <sys/cdefs.h> has no
  __COPYRIGHT/__RCSID/__dead, so the build stops at the first line,
  measured with this frame's compiler and flags:
      src/usr.bin/head/head.c:34:13: error: expected declaration specifiers
      or '...' before string constant
         34 | __COPYRIGHT("@(#) Copyright (c) 1980, 1987, 1992, 1993\
  src/tools/compat/compat_defs.h:211,709,713 supplies the macros once the
  header has been read.

Tests: NetBSD has no src/tests/usr.bin/head, so all nine cases come from
head.1: the first ten lines by default, -n, -c (bytes, not lines, and a
count that ends inside a line), the standard input, the `==> XXX <==` header
for two files with the blank line before the second, -q, -v on one file, the
historic `-2` form (COMPATIBILITY), and EXIT STATUS for a file that cannot
be read.

Evidence (2026-11-11, hotdogb):
- build: `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`
  exit 0, no "*** Error", no warning; "mxcheck: head ok"
  (build/logs/port-head-2026-11-11.log).
- test.sh under qemu: 9 PASS, 0 failed
  (build/logs/port-head-qemu-2026-11-11.log).
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/head):
  9 PASS, 0 failed (build/logs/port-head-phone-2026-11-11.log).
- REPLACES: /usr/bin/head is coreutils-9.4_1 on the phone
  (`xbps-query -o /usr/bin/head`).
- Not yet in the image: A7 (assemble-rootfs) is not done.
- tail(1), the other half of C1.14, is a separate port and not in this one.


################################################################
## mobile/userland/hostname/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.9 (docs/NETBSD-USERLAND.md)

hostname(1) from src/bin/hostname, unchanged: one source file, no helper.
gethostname(2)/sethostname(2) exist on Linux with the same signatures and
the same 255-byte limit, and `-s` is done in the program, not by the OS.

Evidence (2026-11-11):
- `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`:
  exit 0, no error, no warning (build/logs/port-hostname-2026-11-11.log).
- mxcheck: "mxcheck: hostname ok".
- test.sh under qemu: 3 PASS, 0 failed
  (build/logs/port-hostname-qemu-2026-11-11.log) -- the printed name is
  the kernel's node name (what /proc/sys/kernel/hostname says, the same
  thing gethostname(3) returns) and not empty; -s is the part before the
  first dot; exit status 0, nothing on stderr.
- test.sh on the phone (7.0.14-makronix-unstable,
  /tmp/userland-test/hostname): 3 PASS, 0 failed
  (build/logs/port-hostname-phone-2026-11-11.log).
- The setting side ("The super-user can set the host name by supplying an
  argument") is not tested: that changes the phone's running system, and a
  port is tested without touching it (userland/AGENTS.md).  It is the same
  sethostname(2) call either way.
- src/tests/bin/hostname does not exist; every case is a sentence of
  hostname.1.
- From the phone: /usr/bin/hostname is a symlink to hostname-coreutils
  (the Void "alternatives" name, and there is no -inetutils one), and that
  file carries "GNU coreutils", so REPLACES names coreutils.  This settles
  the "inetutils? (check)" of the docs table (C1.9).
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/kill/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.8 (docs/NETBSD-USERLAND.md)

kill(1) from src/bin/kill/kill.c, plus three NetBSD libc functions it
calls, unchanged, from src/lib/libc/gen (signalname.c, signalnumber.c,
signalnext.c -- docs/NETBSD-USERLAND.md section 4: "where NetBSD has the
function in src/lib, build our source").  Two helper files are this port's
own; both are needed, and here is the exact error each one fixes.

1. kill/mx_signame.h -- the three prototypes (src/include/signal.h:61-63).
   Without it, measured (build/logs/port-shim-need-2026-11-11.log):
     kill.c:109:52: error: implicit declaration of function 'signalnext' [-Wimplicit-function-declaration]
     kill.c:111:38: error: implicit declaration of function 'signalname'; did you mean 'signal'? [-Wimplicit-function-declaration]
     kill.c:135:44: error: implicit declaration of function 'signalnumber' [-Wimplicit-function-declaration]
   glibc has none of the three and its <signal.h> cannot declare them.

2. kill/mx_signame.c -- the sys_signame[] table the three read
   (src/lib/libc/gen/signame.c:64-110 in NetBSD).  Without it, measured
   (same log):
     signalnext.c:(.text+0x8): undefined reference to `sys_signame'
   It cannot be NetBSD's table: the two systems number their signals
   differently from 16 up (NetBSD 16 URG, 17 STOP ...; Linux 16 STKFLT,
   17 CHLD, 18 CONT, 19 STOP, 20 TSTP, 23 URG, 30 PWR).  So the names come
   from the phone's own libc, sigabbrev_np(3) (glibc 2.32+, NULL where
   Linux has no name), and only the real-time block -- which glibc leaves
   unnamed -- is spelled the way NetBSD spells it (RT0 at SIGRTMIN ...).
   The table belongs in libmxlinux (A9/section 4) the day it exists: xargs,
   timeout and csh read the same table.

Evidence (2026-11-11):
- `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`:
  exit 0, no error, no warning (build/logs/port-kill-2026-11-11.log).
- mxcheck: "mxcheck: kill ok".
- test.sh under qemu: 10 PASS, 0 failed
  (build/logs/port-kill-qemu-2026-11-11.log) -- -l 9 (KILL), -l 143 and
  -l 137 (exit status = 128+signal), -l with no operand lists HUP/INT/
  KILL/TERM, -0 on a live process and on a dead one, -HUP (status 129),
  -s TERM (143), -9 (137), and an unknown signal name as an error.
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/kill):
  10 PASS, 0 failed (build/logs/port-kill-phone-2026-11-11.log).
- src/tests/bin/kill does not exist; every case is a sentence of kill.1.
- The SIGINT case was dropped while writing the test: an asynchronous
  command of a non-interactive shell starts with SIGINT ignored, so a
  `sleep &` survives `kill -2` -- a property of the shell, not of the
  port.  KILL (9) is used for the numeric-signal case instead.
- From the phone: /usr/bin/kill is "kill from util-linux 2.40.2", so
  REPLACES names util-linux (docs table: util-linux / procps).
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/ln/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.7 (docs/NETBSD-USERLAND.md)

ln(1) from src/bin/ln, unchanged: one source file, no helper, no option
that Linux cannot do (link(2), symlink(2), unlink(2), the `i`/`f`/`h`
logic are all POSIX).

Evidence (2026-11-11):
- `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`:
  exit 0, no error, no warning (build/logs/port-ln-2026-11-11.log). The
  "-include nbtool_config.h" in the Makefile is what the src/bin programs
  need for __RCSID()/__COPYRIGHT()/__dead.
- mxcheck: "mxcheck: ln ok" -- aarch64, every library from the sysroot
  (libc.so.6), no symbol version newer than the phone's glibc.
- test.sh under qemu: 9 PASS, 0 failed
  (build/logs/port-ln-qemu-2026-11-11.log) -- hard link (same inode, same
  content), -s with its target, several sources into a directory, -f,
  -i with "n" (target kept) and "y" (target replaced), -sfh on a symlink
  to a directory, missing source.
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/ln):
  9 PASS, 0 failed (build/logs/port-ln-phone-2026-11-11.log).
- src/tests/bin/ln does not exist, so test.sh has no atf cases to carry;
  each of its cases is a sentence of ln.1.
- From the phone: /usr/bin/ln is "ln (GNU coreutils) 9.4", so REPLACES
  names coreutils. (Checked without xbps-query: xbps is not on the phone;
  the binary answers for its package itself.)
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/logname/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.17 (docs/NETBSD-USERLAND.md)

logname(1) from src/usr.bin/logname; logname.c is used unchanged.

Port-local change (in this directory's Makefile, src/ untouched):
- `CPPFLAGS+= -include nbtool_config.h`: logname.c has no
  `#include nbtool_config.h`, so `__COPYRIGHT`/`__RCSID`/`__dead` are
  undefined under the host's glibc cdefs and the file does not compile
  ("expected declaration specifiers ... before '__COPYRIGHT'");
  libnbcompat's header defines them.

Evidence (2026-11-11):
- Build: log build/logs/port-logname-2026-11-11.log, exit 0, no
  "*** Error", no warning; installed
  build/userland/hotdogb/destdir/usr/bin/logname (+ man1/logname.1).
- mxcheck: `mxcheck: logname ok`.
- test.sh under qemu: 3 PASS, 0 failed -- ignores-LOGNAME-and-USER,
  name-or-error, no-operands.
- test.sh on the phone (7.0.14-makronix-unstable,
  /tmp/userland-test/logname): 3 PASS, 0 failed
  (build/logs/port-logname-phone-2026-11-11.log).
- src/tests/usr.bin/logname does not exist; the cases are logname(1)'s:
  LOGNAME and USER are ignored (two runs with different values answer the
  same and never the given value), the answer is a name on stdout with
  status 0 or a message on stderr with status 1 (getlogin(2) fails
  without a terminal), and an operand is a usage error with status 1
  (logname.c: `argc != optind` -> usage, exit 1).
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/nice/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.17 (docs/NETBSD-USERLAND.md)

nice(1) from src/usr.bin/nice; nice.c is used unchanged.

Port-local changes (in this directory's Makefile, src/ untouched):
- `CPPFLAGS+= -include nbtool_config.h`: nice.c has no
  `#include nbtool_config.h`, so `__COPYRIGHT`/`__RCSID`/`__dead` are
  undefined under the host's glibc cdefs and the file does not compile;
  libnbcompat's header defines them.
- the BSD getopt of the tree (SRCS= nice.c getopt.c, from
  src/common/lib/libc/stdlib).  nice runs "utility [argument ...]" and
  those arguments may be options of the utility: with glibc's getopt
  `nice -n 0 /bin/sh -c 'exit 3'` permutes and hands the "-c" to nice
  itself ("nice: invalid option -- 'c'", exit 1); NetBSD's getopt stops
  at the first non-option, which is what nice.c expects.

Evidence (2026-11-11):
- Build: log build/logs/port-nice-2026-11-11.log, exit 0, no "*** Error",
  no warning; installed build/userland/hotdogb/destdir/usr/bin/nice
  (+ man1/nice.1).
- mxcheck: `mxcheck: nice ok`.
- test.sh under qemu: 5 PASS, 0 failed -- usage-no-utility,
  invalid-increment, utility-not-found, obsolete-increment,
  utility-exit-status.
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/nice):
  5 PASS, 0 failed (build/logs/port-nice-phone-2026-11-11.log).
- src/tests/usr.bin/nice does not exist; the cases are nice(1)'s: no
  utility is a usage error (status 1, "1-125 an error occurred"), -n with
  a value that is not a decimal integer is an error (nice.c: errx, 1),
  127 for a utility that could not be found, the deprecated -increment
  form (-10 is niceness 10, not a bad option), and the utility's status
  (3) is passed through.
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/nohup/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.17 (docs/NETBSD-USERLAND.md)

nohup(1) from src/usr.bin/nohup; nohup.c is used unchanged.

Port-local changes (in this directory's Makefile, src/ untouched):
- `CPPFLAGS+= -include nbtool_config.h`: nohup.c has no
  `#include nbtool_config.h`, so `__COPYRIGHT`/`__RCSID`/`__dead` are
  undefined under the host's glibc cdefs and the file does not compile;
  libnbcompat's header defines them.
- the BSD getopt of the tree (SRCS= nohup.c getopt.c, from
  src/common/lib/libc/stdlib).  nohup runs "utility [argument ...]" and
  those arguments may be options of the utility: with glibc's getopt
  `nohup /bin/sh -c 'exit 5'` permutes and hands the "-c" to nohup
  itself ("nohup: invalid option -- 'c'", usage, exit 127); NetBSD's
  getopt stops at the first non-option, which is what nohup.c expects.

Evidence (2026-11-11):
- Build: log build/logs/port-nohup-2026-11-11.log, exit 0, no
  "*** Error", no warning; installed
  build/userland/hotdogb/destdir/usr/bin/nohup (+ man1/nohup.1).
- mxcheck: `mxcheck: nohup ok`.
- test.sh under qemu: 5 PASS, 0 failed -- usage-no-utility,
  utility-not-found, utility-not-executable, utility-exit-status,
  no-nohup-out-without-a-terminal.
- test.sh on the phone (7.0.14-makronix-unstable,
  /tmp/userland-test/nohup): 5 PASS, 0 failed
  (build/logs/port-nohup-phone-2026-11-11.log).
- src/tests/usr.bin/nohup does not exist; the cases are nohup(1)'s: no
  utility is a usage error (nohup.c's usage() exits 127), 127 for a
  utility that could not be found, 126 for one "found but could not be
  invoked" (/etc/passwd), the utility's status (5) is passed through, and
  nohup.out is created only when standard output is a terminal (it is a
  file here, so no nohup.out must appear in the working directory).
  SIGHUP being ignored is not tested: that needs a signal sent to a child
  and watched, not a filter case.
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/paste/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.15 (docs/NETBSD-USERLAND.md)

paste(1) from src/usr.bin/paste; paste.c is used unchanged.

Port-local change (in this directory's Makefile, src/ untouched):
- `CPPFLAGS+= -include nbtool_config.h`: paste.c has no
  `#include nbtool_config.h`, so `__COPYRIGHT`/`__RCSID`/`__dead` are
  undefined under the host's glibc cdefs and the file does not compile
  ("expected declaration specifiers ... before '__COPYRIGHT'");
  libnbcompat's header defines them.

Evidence (2026-11-11):
- Build: log build/logs/port-paste-2026-11-11.log, exit 0, no
  "*** Error", no warning; installed
  build/userland/hotdogb/destdir/usr/bin/paste (+ man1/paste.1).
- mxcheck: `mxcheck: paste ok`.
- test.sh under qemu: 5 PASS, 0 failed -- parallel-default, delimiter,
  delimiter-tab-escape, sequential, sequential-circular-delimiters.
- test.sh on the phone (7.0.14-makronix-unstable,
  /tmp/userland-test/paste): 5 PASS, 0 failed
  (build/logs/port-paste-phone-2026-11-11.log).
- src/tests/usr.bin/paste does not exist; the cases are paste(1)'s:
  corresponding lines with the default tab and the exhausted file read
  "as if it were an endless source of empty lines", -d with a character
  and with the "\t" escape, -s, and the list of -d "used circularly".
  The input files are made by the test.
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/printenv/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.16 (docs/NETBSD-USERLAND.md)

printenv(1) from src/usr.bin/printenv; printenv.c is used unchanged.

Port-local change (in this directory's Makefile, src/ untouched):
- `CPPFLAGS+= -include nbtool_config.h`: printenv.c has no
  `#include nbtool_config.h`, so `__COPYRIGHT`/`__RCSID`/`__dead` are
  undefined under the host's glibc cdefs and the file does not compile
  ("expected declaration specifiers ... before '__COPYRIGHT'");
  libnbcompat's header defines them.

Evidence (2026-11-11):
- Build: log build/logs/port-printenv-2026-11-11.log, exit 0, no
  "*** Error", no warning; installed
  build/userland/hotdogb/destdir/usr/bin/printenv (+ man1/printenv.1).
- mxcheck: `mxcheck: printenv ok`.
- test.sh under qemu: 4 PASS, 0 failed -- named-variable,
  undefined-name, name-must-match-whole, whole-environment.
- test.sh on the phone (7.0.14-makronix-unstable,
  /tmp/userland-test/printenv): 4 PASS, 0 failed
  (build/logs/port-printenv-phone-2026-11-11.log).
- src/tests/usr.bin/printenv does not exist; the cases are printenv(1)'s:
  the value of a name, status 1 and no output for an undefined name, a
  name that is only a prefix of a defined variable, and the whole
  environment with no name.
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/pwd/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.5 (docs/NETBSD-USERLAND.md)

pwd(1) from src/bin/pwd, unchanged.  NetBSD has no test for it
(src/tests/bin/pwd does not exist), so test.sh carries pwd(1): the default
is -P, -P resolves a symbolic link, -L prints $PWD when it is absolute, has
no "/./" or "/../" and names the current directory, -L falls back to the
physical path when $PWD contains "/./" or names another directory, and an
operand is a usage error.

Evidence (2026-11-11):
- mxcheck: pwd ok, exit 0 (build/logs/port-pwd-2026-11-11.log); installed as
  destdir/usr/bin/pwd (mode 555) and destdir/usr/share/man/man1/pwd.1.
- test.sh under qemu: 6 PASS, 0 failed
  (build/logs/port-pwd-qemu-2026-11-11.log).
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/pwd):
  6 PASS, 0 failed (build/logs/port-pwd-phone-2026-11-11.log).
- REPLACES: /usr/bin/pwd is coreutils-9.4_1 on the phone (xbps-query -o
  /usr/bin/pwd).

The Makefile adds one thing and no helper file: CPPFLAGS+= -include
nbtool_config.h.  pwd.c includes that header only in NetBSD's host-tool
build; without the preinclude the aarch64 compiler stops at

  pwd.c:34:13: error: expected declaration specifiers or '...' before string
               constant                       (__COPYRIGHT)
  pwd.c:42:9: error: expected declaration specifiers or '...' before string
              constant                        (__RCSID)
  pwd.c:59:7: error: expected ';' before 'static'   (__dead)

The header gives __COPYRIGHT/__RCSID/__dead their declarations and names
setprogname() out of libnbcompat (compat_defs.h:611-614, 709-715).

Not yet in the image: A7 (assemble-rootfs, REPLACES) is not done.


################################################################
## mobile/userland/rev/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.15 (docs/NETBSD-USERLAND.md)

rev(1) from src/usr.bin/rev; rev.c is used unchanged.

Port-local changes (in this directory, src/ untouched):
- `CPPFLAGS+= -include nbtool_config.h` (Makefile): rev.c has no
  `#include nbtool_config.h`, so `__COPYRIGHT`/`__RCSID`/`__dead` are
  undefined under the host's glibc cdefs and the file does not compile;
  libnbcompat's header defines them.
- mx-fgetwln.h + mx-fgetwln.c, and `SRCS= rev.c mx-fgetwln.c` with
  `-I${MX_PORTDIR} -include ${MX_PORTDIR}/mx-fgetwln.h`: rev.c reads with
  fgetwln() (rev.c:93), which NetBSD's <stdio.h> declares and glibc's
  does not (checked: no "fgetwln" in the sysroot's stdio.h or wchar.h),
  and libnbcompat carries only fgetln().  Measured without the helper,
  with this port's exact compile flags: "rev.c:93:29: error: implicit
  declaration of function 'fgetwln'; did you mean 'fgetln'?
  [-Wimplicit-function-declaration]" plus "assignment to 'wchar_t *' ...
  from 'int' makes pointer from integer without a cast".  The helper is
  fgetwln(3)'s contract over glibc's public stdio (NetBSD's own
  implementation is written against its stdio internals): the line
  without a terminating null, its length including the final newline to
  *len, NULL with *len 0 at end of file or on error, the buffer valid
  until the next read -- what rev.c prints before reading the next line.

Evidence (2026-11-11):
- Build: log build/logs/port-rev-2026-11-11.log, exit 0, no "*** Error",
  no warning; installed build/userland/hotdogb/destdir/usr/bin/rev
  (+ man1/rev.1).
- mxcheck: `mxcheck: rev ok`.
- test.sh under qemu: 5 PASS, 0 failed -- standard-input, file-operand,
  two-files, empty-lines, empty-file.
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/rev):
  5 PASS, 0 failed (build/logs/port-rev-phone-2026-11-11.log).
- src/tests/usr.bin/rev does not exist; the cases are rev(1)'s: "copies
  the specified files to the standard output, reversing the order of
  characters in every line", several file operands, and the standard
  input when no file is given; empty lines stay empty and an empty file
  yields nothing.
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/rmdir/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.6 (docs/NETBSD-USERLAND.md)

rmdir(1) from src/bin/rmdir, unchanged.  NetBSD has no test for it
(src/tests/bin/rmdir does not exist), so test.sh carries rmdir(1): an empty
directory is removed with exit status 0, a directory that is not empty is an
error (>0) and stays, -v prints each directory as it is processed, -p
removes all components of the pathname starting with the last most one (the
case uses a relative pathname, so the walk stops at its first component),
-pv prints each of them, and no operand is a usage error.

Evidence (2026-11-11):
- mxcheck: rmdir ok, exit 0 (build/logs/port-rmdir-2026-11-11.log);
  installed as destdir/usr/bin/rmdir (mode 555) and
  destdir/usr/share/man/man1/rmdir.1.
- test.sh under qemu: 6 PASS, 0 failed
  (build/logs/port-rmdir-qemu-2026-11-11.log).
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/rmdir):
  6 PASS, 0 failed (build/logs/port-rmdir-phone-2026-11-11.log).
- REPLACES: /usr/bin/rmdir is coreutils-9.4_1 on the phone (xbps-query -o
  /usr/bin/rmdir).
- The FAIL path is real: run with coreutils' /bin/rmdir as the command, the
  cases verbose and parents-verbose fail (it prints "rmdir: removing
  directory, ..." instead of the pathname) and the test exits 1.

The Makefile adds one thing and no helper file: CPPFLAGS+= -include
nbtool_config.h.  rmdir.c includes that header only in NetBSD's host-tool
build; without the preinclude the aarch64 compiler stops at

  rmdir.c:34:13: error: expected declaration specifiers or '...' before
                 string constant                 (__COPYRIGHT)
  rmdir.c:42:9: error: expected declaration specifiers or '...' before
               string constant                   (__RCSID)
  rmdir.c:58:7: error: expected ';' before 'static'   (__dead)

The header gives __COPYRIGHT/__RCSID/__dead their declarations and names
setprogname() out of libnbcompat (compat_defs.h:611-614, 709-715).  warn()
and err() come from glibc's own <err.h>, not from libnbcompat.

Not yet in the image: A7 (assemble-rootfs, REPLACES) is not done.


################################################################
## mobile/userland/sleep/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.3 (docs/NETBSD-USERLAND.md)

sleep(1) from src/bin/sleep, unchanged, built with one helper header in this
directory (mx_sleep.h, below).  test.sh carries all three cases of NetBSD's
own test src/tests/bin/sleep/t_sleep.sh -- fraction (5 atf_check), hex (3),
nonnumeric (8) -- and three cases of sleep(1): zero seconds, the minimum
duration, and SIGALRM's exit status.

One case is reported as SKIP and none as PASS in its place:
fraction-comma-under-ru runs `LC_ALL=ru_RU.UTF-8 sleep 0,2`, which needs a
locale whose radix character is ','.  The phone's image has only C, C.utf8,
POSIX and en_US.utf8 (`locale -a`), so the locale cannot be used at all and
the case cannot be run; the dot-radix case under the same LC_ALL does run
and passes.  The test asks the program's own locale(1) for the list (the
sysroot's under qemu, the phone's on the phone), so it would run the case if
the locale were installed.

Evidence (2026-11-11):
- mxcheck: sleep ok, exit 0 (build/logs/port-sleep-2026-11-11.log);
  installed as destdir/usr/bin/sleep (mode 555) and
  destdir/usr/share/man/man1/sleep.1.
- test.sh under qemu: 18 PASS, 1 SKIP, 0 failed
  (build/logs/port-sleep-qemu-2026-11-11.log).
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/sleep):
  18 PASS, 1 SKIP, 0 failed (build/logs/port-sleep-phone-2026-11-11.log).
- REPLACES: /usr/bin/sleep is coreutils-9.4_1 on the phone (xbps-query -o
  /usr/bin/sleep).

What the Makefile adds and why:

1. mx_sleep.h, this directory -- the four NetBSD interfaces sleep.c uses that
   the phone's glibc does not have.  Measured: with the header left out, the
   aarch64 compiler stops at five places and nothing else:

     sleep.c:137:31: error: implicit declaration of function 'strtod_l';
                     did you mean 'strtok_r'?
     sleep.c:137:52: error: 'LC_C_LOCALE' undeclared (first use in this
                     function)
     sleep.c:180:9: error: implicit declaration of function 'timespecadd';
                    did you mean 'timespec_get'?
     sleep.c:186:16: error: 'SIGINFO' undeclared (first use in this
                     function); did you mean 'SIGIO'?
     sleep.c:203:17: error: implicit declaration of function 'timespecsub';
                     did you mean 'timespec_get'?

   The header carries, each with the src/ line it comes from: timespecadd()/
   timespecsub() (src/sys/sys/time.h:253-270), LC_C_LOCALE (src's
   <locale.h>:115 names a libc object; glibc has to make one with
   newlocale(3)), strtod_l()'s declaration (glibc declares it only under
   _GNU_SOURCE, and forcing _GNU_SOURCE for the whole compile would change
   the headers the rest of the program sees) and SIGINFO (Linux has no such
   signal and 29 is SIGIO; it is bound to SIGPWR, 30 on aarch64, whose
   default action is "ignore" and which init does not use).  It is named by
   its full path in CPPFLAGS because Makefile.host reads the program's
   Makefile with .CURDIR switched to src/bin/sleep, where a relative
   include is not in scope.

2. CPPFLAGS+= -include nbtool_config.h -- sleep.c includes it only in
   NetBSD's host-tool build.  Without it, with mx_sleep.h in place:

     sleep.c:34:13: error: expected declaration specifiers or '...' before
                    string constant                (__COPYRIGHT)
     sleep.c:42:9: error: expected declaration specifiers or '...' before
                   string constant                  (__RCSID)
     sleep.c:58:7: error: expected ';' before 'static'   (__dead)

   The header gives those their declarations and names setprogname() out of
   libnbcompat (compat_defs.h:611-614, 709-715).

3. LDADD+= -lm with LIBM=${MX_SYSROOT}/usr/lib/libm.so -- src/bin/sleep/
   Makefile says LDADD+= -lm and DPADD+= ${LIBM}; floor() needs it.
   bsd.hostprog.mk:38 defaults LIBM to the build host's /usr/lib/libm.a,
   which does not exist here, so DPADD (a dependency of the link) is pointed
   at the phone's library.  -lm itself needs no path.

No file outside this directory and the frame changed.

Not yet in the image: A7 (assemble-rootfs, REPLACES) is not done.


################################################################
## mobile/userland/stty/AGENTS.md  (last commit 2026-11-12)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.12 (docs/NETBSD-USERLAND.md)

stty(1) from src/bin/stty (stty.c gfmt.c key.c modes.c print.c cchar.c),
unchanged, with one helper header: src/lib/libmxlinux/mx_termios.h (since 2026-11-12 shared by every
program of the normal build), force-included by the
Makefile.  This is the port of the list that is written against NetBSD's tty
interface, so the helper is the port: it carries the names glibc does not
have, and every value is chosen so that the program stays harmless on a
phone tty.  The build without it fails with, measured
(build/logs/port-shim-need-2026-11-11.log):

    stty.h:42:9:  error: unknown type name 'linedn_t'
    stty.c:102:25: error: 'TIOCGLINED' undeclared (first use in this function)
    stty.c:106:25: error: 'TIOCGQSIZE' undeclared (first use in this function)
    cchar.c:61:25: error: 'VDSUSP' undeclared here (not in a function)
    cchar.c:73:25: error: 'VSTATUS' undeclared here (not in a function)
    cchar.c:123:39: error: '_POSIX_VDISABLE' undeclared (first use in this function)
    key.c:212:22: error: '_PATH_URANDOM' undeclared (first use in this function)
    key.c:323:23: error: 'TIOCSTART' undeclared (first use in this function)
    key.c:330:23: error: 'TIOCSTOP' undeclared (first use in this function)

and it also adds ALTWERASE, NOKERNINFO, MDMBUF, CDTRCTS and OXTABS, which
print.c, modes.c and key.c use.  The header's own comment says, for each
name, which NetBSD line it comes from and which Linux value or ioctl it is
mapped to.

Three things the helper cannot fix, and the port therefore says differently
from NetBSD's — all three are Linux properties, not port bugs:

1. The line discipline is a number on Linux, a name on NetBSD.  stty.c:102
   calls TIOCGLINED (NetBSD: a char[32] holding "termios") as its first act and warns on
   any error; the header maps it to Linux's TIOCGETD (an int, N_TTY = 0),
   which succeeds and puts a NUL in the first byte.  So `stty -a` prints
   "line = ;" where NetBSD prints "line = termios;".  The alternative --
   NetBSD's own ioctl number -- fails on every run and puts
   "stty: TIOCGLINED: Inappropriate ioctl for device" on stderr each time.
   Same for TIOCGQSIZE (mapped to FIONREAD: 0 while nothing is pending, so
   the "queue = N" field is left out exactly as NetBSD leaves it out).
2. Baud rates.  NetBSD's Bxxx ARE the rate; Linux's Bxxx are indices
   (B9600 = 13, B38400 = 15), and stty prints what cfgetospeed() returns
   and hands cfsetospeed() what the user typed.  Unported, `stty -a` said
   "speed 15 baud;" and `stty 9600` set nothing.  The header wraps the four
   cf*speed() calls (rate <-> code, a rate Linux has no code for returns
   -1 and the terminal keeps its speed).  Measured after the wrapper:
   "speed 38400 baud;", and `stty 9600 && stty speed` says 9600.
3. `stty ostart` / `stty ostop` are NetBSD's TIOCSTART/TIOCSTOP
   (src/sys/sys/ttycom.h:140,141); Linux has no such ioctl.  The two are
   defined as 0 so the call fails with ENOTTY and key.c's own
   `err(1, "TIOCSTART")` reports the operand as unsupported instead of
   pretending.  key.c:197,311 keep `extproc` and `tty` inside #ifdef
   TIOCEXT/#ifdef TTYDISC; neither is defined, so those two operands are
   compiled out (an honest missing feature, not a guessed ioctl).

One more define, BSD4_4: gfmt.c:69 writes the ispeed= and ospeed= keys of
the gfmt1 form unconditionally, but gfmt.c:100,115 only read them under
#ifdef BSD4_4 (src/sys/sys/param.h:51).  On Linux that made `stty -g` print
two keys its own reader rejects ("illegal gfmt1 option -- ispeed"), which
breaks exactly what the -g option promises.  glibc's struct termios has
c_ispeed/c_ospeed, so defining BSD4_4 is the whole fix; nothing else in
src/bin/stty uses it.

Evidence (2026-11-11):
- `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`:
  exit 0, no error, no warning (build/logs/port-stty-2026-11-11.log).
- mxcheck: "mxcheck: stty ok".
- test.sh under qemu: 8 PASS, 0 failed
  (build/logs/port-stty-qemu-2026-11-11.log).  stty needs a terminal, and
  neither the qemu run nor the phone run has one on stdin, so each case
  runs the port inside a pty: `SHELL=/bin/sh script -q -c ...` (util-linux
  script, on the phone and on the build host; SHELL= because script starts
  $SHELL for -c and the build host's login shell talks).  Cases, all from
  stty.1: -g is a form that restores the terminal (read it, hand it back,
  read it again -- the same form); -a shows speed and control characters;
  `stty -echo` then no operands reports "-echo" (the man page: "additional
  ones if they differ from their default values"), `stty echo` does not;
  `rows 24 columns 80` then `size` says "24 80"; `speed` is a number;
  `9600` then `speed` says 9600; an unknown operand is a usage error.
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/stty):
  8 PASS, 0 failed (build/logs/port-stty-phone-2026-11-11.log).
- src/tests/bin/stty does not exist; there was no atf case to translate.
- From the phone: /usr/bin/stty is "stty (GNU coreutils) 9.4", so REPLACES
  names coreutils.
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/sync/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.4 (docs/NETBSD-USERLAND.md)

sync(8) from src/bin/sync, unchanged.  It has no options and no NetBSD test
(src/tests/bin/sync does not exist), so test.sh carries sync(8): no
arguments, nothing on stdout or stderr, exit 0; a write made before it is
still readable and unchanged after it; and a second call works too.

Evidence (2026-11-11):
- mxcheck: sync ok, exit 0 (build/logs/port-sync-2026-11-11.log); installed
  as destdir/usr/bin/sync (mode 555) and
  destdir/usr/share/man/man8/sync.8.
- test.sh under qemu: 4 PASS, 0 failed
  (build/logs/port-sync-qemu-2026-11-11.log).
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/sync):
  4 PASS, 0 failed (build/logs/port-sync-phone-2026-11-11.log).
- REPLACES: /usr/bin/sync is coreutils-9.4_1 on the phone (xbps-query -o
  /usr/bin/sync).

The Makefile adds one thing and no helper file: CPPFLAGS+= -include
nbtool_config.h.  sync.c includes that header only in NetBSD's host-tool
build; without the preinclude the aarch64 compiler stops at

  sync.c:34:13: error: expected declaration specifiers or '...' before string
                constant                     (__COPYRIGHT)
  sync.c:42:9: error: expected declaration specifiers or '...' before string
               constant                      (__RCSID)
  sync.c:53:9: error: implicit declaration of function 'setprogname'

The header gives __COPYRIGHT/__RCSID their declarations and names
setprogname() out of libnbcompat (compat_defs.h:611-614, 709-715).

Not yet in the image: A7 (assemble-rootfs, REPLACES) is not done.


################################################################
## mobile/userland/tee/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.15 (docs/NETBSD-USERLAND.md)

tee(1) from src/usr.bin/tee, unchanged.

What the port adds, and why:
- `CPPFLAGS+= -include nbtool_config.h`.  tee.c does not include
  nbtool_config.h itself (cat.c:36 does); the tools frame only passes
  -DHAVE_NBTOOL_CONFIG_H, and glibc's <sys/cdefs.h> has no
  __COPYRIGHT/__RCSID/__dead, so the build stops at the first line,
  measured with this frame's compiler and flags:
      src/usr.bin/tee/tee.c:34:13: error: expected declaration specifiers or
      '...' before string constant
         34 | __COPYRIGHT("@(#) Copyright (c) 1988, 1993\
  src/tools/compat/compat_defs.h:211,709,713 supplies the macros once the
  header has been read.

Tests: NetBSD has no src/tests/usr.bin/tee, so the twelve cases come from
tee.1: the input copied to the standard output alone, to one file, to two
files (each a copy, the standard output too), -a appending to a file that
already has content (the old content stays in front), -i accepted and
copying as without it, and the EXIT STATUS of a file that cannot be opened
(non-zero plus a message on the standard error) with the standard output
still getting its copy.

-i does not send SIGINT: signalling the running port from sh would have to
survive "qemu-aarch64 -L <sysroot>" in the qemu run and a second ssh in the
phone run, and would test the signal delivery of the harness, not the port.
The option handler (tee.c:84) is the same code path as -a.

Evidence (2026-11-11, hotdogb):
- build: `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`
  exit 0, no "*** Error", no warning; "mxcheck: tee ok"
  (build/logs/port-tee-2026-11-11.log).
- test.sh under qemu: 12 PASS, 0 failed
  (build/logs/port-tee-qemu-2026-11-11.log).
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/tee):
  12 PASS, 0 failed (build/logs/port-tee-phone-2026-11-11.log).
- REPLACES: /usr/bin/tee is coreutils-9.4_1 on the phone
  (`xbps-query -o /usr/bin/tee`).
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/test/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.10 (docs/NETBSD-USERLAND.md)

test(1) from src/bin/test/test.c, unchanged, with one helper file:

  test/mx_timespec.h -- NetBSD's timespeccmp() macro (src/sys/sys/time.h:249),
  which -nt and -ot use on struct stat's st_mtim (test.c:882,892) and glibc
  does not have.  Without it, measured
  (build/logs/port-shim-need-2026-11-11.log):
    test.c:882:17: error: implicit declaration of function 'timespeccmp'; did you mean 'timercmp'? [-Wimplicit-function-declaration]
    test.c:882:55: error: expected expression before '>' token
  libnbcompat's compat_defs.h carries timercmp() and friends but no
  timespeccmp(), so the macro is brought along instead of changing
  src/tools/compat for one program.  It is force-included by full path
  because Makefile.host reads this Makefile with .CURDIR switched to
  src/bin/test, where this directory is not in scope.

"[" is installed since 2026-11-11: the frame reads LINKS from the program's
own Makefile (mk/mx.prog.mk, mx-links) and makes /usr/bin/[ a hard link of
/usr/bin/test, as NetBSD does.

Evidence (2026-11-11):
- `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`:
  exit 0, no error, no warning (build/logs/port-test-2026-11-11.log).
- mxcheck: "mxcheck: test ok".
- test.sh under qemu: 44 PASS, 0 failed
  (build/logs/port-test-qemu-2026-11-11.log).  Every case is a primary or
  an operator of test.1 with the exit status the man page gives it: no
  argument (1), the string primaries (-n -z and a bare string), string
  =/!=/</> ("based on the ASCII value"), the integer comparators
  (-eq -ne -gt -ge -lt -le, including a negative operand), the file
  primaries (-f -d -e -s -x -r -w -h), -nt/-ot (the helper above) and -ef,
  and the operators ! -a -o ( ) with "-a has higher precedence than -o".
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/test):
  44 PASS, 0 failed (build/logs/port-test-phone-2026-11-11.log).
- src/tests/bin/test does not exist; there was no atf case to translate.
- From the phone: /usr/bin/test carries "GNU coreutils" (Void's coreutils
  9.4 builds, same date as its ln and stty), so REPLACES names coreutils.
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/tty/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.17 (docs/NETBSD-USERLAND.md)

tty(1) from src/usr.bin/tty; tty.c is used unchanged.

Port-local change (in this directory's Makefile, src/ untouched):
- `CPPFLAGS+= -include nbtool_config.h`: tty.c has no
  `#include nbtool_config.h`, so `__COPYRIGHT`/`__RCSID`/`__dead` are
  undefined under the host's glibc cdefs and the file does not compile
  ("expected declaration specifiers ... before '__COPYRIGHT'");
  libnbcompat's header defines them.

Evidence (2026-11-11):
- Build: log build/logs/port-tty-2026-11-11.log, exit 0, no "*** Error",
  no warning; installed build/userland/hotdogb/destdir/usr/bin/tty
  (+ man1/tty.1).
- mxcheck: `mxcheck: tty ok`.
- test.sh under qemu: 3 PASS, 0 failed -- not-a-tty, silent-flag,
  bad-option.
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/tty):
  3 PASS, 0 failed (build/logs/port-tty-phone-2026-11-11.log).
- src/tests/usr.bin/tty does not exist; the cases are tty(1)'s: "not a
  tty" with status 1, -s writing nothing and only setting the status, and
  a bad option, which is an error (>1; tty.c's usage() exits 2).  The
  positive case needs a terminal on standard input, which neither the
  qemu run nor the phone run has; it is not tested.
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/uniq/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.15 (docs/NETBSD-USERLAND.md)

uniq(1) from src/usr.bin/uniq, unchanged.

What the port adds, and why:
- `CPPFLAGS+= -include nbtool_config.h`.  uniq.c does not include
  nbtool_config.h itself (cat.c:36 does); the tools frame only passes
  -DHAVE_NBTOOL_CONFIG_H, and glibc's <sys/cdefs.h> has no
  __COPYRIGHT/__RCSID/__dead, so the build stops at the first line,
  measured with this frame's compiler and flags:
      src/usr.bin/uniq/uniq.c:37:13: error: expected declaration specifiers
      or '...' before string constant
         37 | __COPYRIGHT("@(#) Copyright (c) 1989, 1993\
  src/tools/compat/compat_defs.h:211,709,713 supplies the macros once the
  header has been read.

Tests: NetBSD's src/tests/usr.bin/uniq/t_uniq.sh has five cases (basic,
test_counts, show_duplicates, show_uniques,
show_duplicates_from_third_character); all five are in test.sh with their
data files (d_basic.in/out, d_input.in, d_counts.out,
d_show_duplicates.out, d_show_uniques.out) as one case each; then four cases
from uniq.1: standard input, -c on stdin (the count is "%4d " before the
line, uniq.c:195), the second operand as an output file with nothing on the
standard output, and the content of that output file.

One case was broken in the first draft and is fixed: `output-file-content`
compared the expected file with the standard-output capture instead of with
the output file `o1`, so it could never pass; it now compares o1 with
d_basic.out.  The case was checked against uniq.1 ("the latter as the name of
an output file"), not against what the port printed.

Evidence (2026-11-11, hotdogb):
- build: `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`
  exit 0, no "*** Error", no warning; "mxcheck: uniq ok"
  (build/logs/port-uniq-2026-11-11.log).
- test.sh under qemu: 9 PASS, 0 failed
  (build/logs/port-uniq-qemu-2026-11-11.log).
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/uniq):
  9 PASS, 0 failed (build/logs/port-uniq-phone-2026-11-11.log).
- REPLACES: /usr/bin/uniq is coreutils-9.4_1 on the phone
  (`xbps-query -o /usr/bin/uniq`).
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/wc/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.15 (docs/NETBSD-USERLAND.md)

wc(1) from src/usr.bin/wc, unchanged.

What the port adds, and why:
- `CPPFLAGS+= -include nbtool_config.h`.  wc.c does not include
  nbtool_config.h itself (cat.c:36 does); the tools frame only passes
  -DHAVE_NBTOOL_CONFIG_H, and glibc's <sys/cdefs.h> has no
  __COPYRIGHT/__RCSID/__dead, so the build stops at the first line,
  measured with this frame's compiler and flags:
      src/usr.bin/wc/wc.c:34:13: error: expected declaration specifiers or
      '...' before string constant
         34 | __COPYRIGHT("@(#) Copyright (c) 1980, 1987, 1991, 1993\
  src/tools/compat/compat_defs.h:211,709,713 supplies the macros once the
  header has been read.

Tests: NetBSD has no src/tests/usr.bin/wc, so the ten cases come from wc.1:
the default (lines, words, bytes, file name in the layout of wc.c's WCFMT
" %7llu"), each of -l -w -c -m -L alone, -lw together (only what was asked
for is printed), the cumulative `total` line for two files, a last line
without a newline (not a line per wc.1's definition, but its word and bytes
are counted), and standard input with no file name.

One clause of wc.1 is not tested, deliberately: "-c and -m are incompatible,
the last specified is used".  The two counts can only differ for a non-ASCII
file, and in the C locale -- the locale a test starts in -- mbrtowc() rejects
those bytes and wc(1) fails with "invalid byte sequence" by design
(wc.c:149-162), so the ordering cannot be observed without a UTF-8 locale,
which is a property of the environment, not of the port.

Evidence (2026-11-11, hotdogb):
- build: `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`
  exit 0, no "*** Error", no warning; "mxcheck: wc ok"
  (build/logs/port-wc-2026-11-11.log).
- test.sh under qemu: 10 PASS, 0 failed
  (build/logs/port-wc-qemu-2026-11-11.log).
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/wc):
  10 PASS, 0 failed (build/logs/port-wc-phone-2026-11-11.log).
- REPLACES: /usr/bin/wc is coreutils-9.4_1 on the phone
  (`xbps-query -o /usr/bin/wc`).
- Not yet in the image: A7 (assemble-rootfs) is not done.


################################################################
## mobile/userland/yes/AGENTS.md  (last commit 2026-11-11)
################################################################
state: done
agent: opencode deepseek-v4.1-flash, 2026-11-11
item: C1.16 (docs/NETBSD-USERLAND.md)

yes(1) from src/usr.bin/yes, unchanged.

What the port adds, and why:
- `CPPFLAGS+= -include nbtool_config.h`.  yes.c does not include
  nbtool_config.h itself (cat.c:36 does); the tools frame only passes
  -DHAVE_NBTOOL_CONFIG_H, and glibc's <sys/cdefs.h> has no
  __COPYRIGHT/__RCSID/__dead, so the build stops at the first line,
  measured with this frame's compiler and flags:
      src/usr.bin/yes/yes.c:34:13: error: expected declaration specifiers or
      '...' before string constant
         34 | __COPYRIGHT("@(#) Copyright (c) 1987, 1993\
  src/tools/compat/compat_defs.h:211,709,713 supplies the macros once the
  header has been read.

Tests: NetBSD has no src/tests/usr.bin/yes (yes.1 has no options, no exit
status, only SYNOPSIS and DESCRIPTION), so the four cases come from the man
page: the default "y", an expletive operand, a quoted operand with a blank
in it printed as one line, and "forever" -- a hundred lines read through
head(1), every one of them the expletive.  head(1) is what ends the port
(SIGPIPE) in every case; the port itself has no terminating mode by design
(yes.c:55, "while(puts(yes) >= 0)").

Evidence (2026-11-11, hotdogb):
- build: `sh ../../tools/mxmake.sh ../../devices/hotdogb dependall install`
  exit 0, no "*** Error", no warning; "mxcheck: yes ok"
  (build/logs/port-yes-2026-11-11.log).
- test.sh under qemu: 4 PASS, 0 failed
  (build/logs/port-yes-qemu-2026-11-11.log).
- test.sh on the phone (7.0.14-makronix-unstable, /tmp/userland-test/yes):
  4 PASS, 0 failed (build/logs/port-yes-phone-2026-11-11.log).
- REPLACES: /usr/bin/yes is coreutils-9.4_1 on the phone
  (`xbps-query -o /usr/bin/yes`).
- Not yet in the image: A7 (assemble-rootfs) is not done.
