Move (or rename) one path onto another inside a single PdxFS v1 transaction,
with an audit-journal record written before commit and a WAL undo record
whose replay is mv <dst> <src>.
mv [-v|--verbose] [-i] [-f|--force] [--dry-run] <src> <dst>
Exactly two positionals are required. MvArgv::mv_argv_parse rejects any
other positional count with MV_ARG_TOO_FEW_POS and any flag outside the
whitelist {v, verbose, i, f, force, dry-run} with MV_ARG_UNKNOWN_FLAG
(src/argv.pdx). The multi-source form mv f1 f2 … dir/ is not accepted
at 1.1.0.
At 1.1.0 mv refuses to overwrite an existing destination by default
(mv.ENH-004, #20). Pass -f / --force to consent to the overwrite; the
refuse path returns MV_MV_DST_EXISTS (0xFFFFEB3E) and leaves both
source and destination untouched.
mv moves a dirent from one parent directory to another. Move::move_dispatch
(src/move.pdx) is the single entry point for all four move shapes, and every
one of them runs inside one PdxFS transaction opened in PXT_MODE_MODIFY:
- same-dir —
src_parent == dst_parent; the unlink and the link touch the same parent inode. - cross-dir — different parents on the same device;
pdxfs_unlinkatsrc_parentandpdxfs_linkatdst_parentare both threaded through the one TXN, so commit publishes both dirent writes or neither. - cross-device —
pdxfs_linkreturnsPDXFS_ERR_EXDEV(-18), andMove::move_cross_dev_bodybyte-copies the file through a 4 KiB scratch buffer (mv_move_xdev_buf) withsys_open/read/write/close, then unlinks the source dirent inside the same outer TXN. The operation is no longer O(1);-vsays so on stderr. - cross-user —
Inode::mv_inode_preservecompares the source inode's owner key against the destination parent's. On a mismatch,Elevate::mv_elevate_cross_useraskssvc.elevate-brokerto lendKIND_USER(sign, dst_owner_key)for a 60-second window so the inode can be re-signed. A denied elevate is not fatal: the inode keeps its old owner tail and the degrade is reported under-v.
The pipeline inside move_dispatch is fixed:
resolve_parent(src) → resolve_parent(dst) → inode_of(src) →
txn_open → unlink → link (or the EXDEV fallback) → inode_preserve →
MoveRecord emit → audit write → undo write → txn_commit.
The audit write is a hard gate — under the D3 audit-first discipline, an mv
that cannot log itself is refused, and mv_md_audit_fail aborts the TXN so the
source dirent survives and no destination artifact appears. The undo write is
best-effort by design: a failed pdxfs_txn_write_undo leaves the move
committed and audited, it only means pdx-undo cannot replay it automatically.
The undo record itself is simply the two paths swapped
(replay_src = dst, replay_dst = src), so replaying it re-invokes mv in
reverse.
mv is a Category-A coreutil in wave R50 of paideia-os, released as v1.0.0
(2026-08-22, dual-signed with manifest.pdxsig in the SHAPE-PENDING state
described in RELEASE.md). It links two shared libraries per deps.list:
libpdx-argv (src/argv.pdx) and libpdx-audit (src/audit.pdx, via its
AuditClient, mv.ENH-008). deps.list previously also claimed libpdx-cap,
libpdx-semantic-pipe, and libpdx-elevate, but src/mv.pdx + src/inode.pdx,
src/schema.pdx, and src/elevate.pdx all use local trampolines against the
raw kernel syscalls instead — those three entries were removed (mv.ENH-008,
#24).
Substrate caveat. Every Pdxfs::* trampoline in src/pdxfs.pdx is still an
M2 stub that returns 0 (or 1 for handle-valued calls) without issuing a
syscall; live TXN dispatch lands with the R42 PdxFS v1 substrate in the
paideia-os kernel. The IPC path used by the audit and elevate hops
(sys_ipc_send = 42, sys_svc_lookup = 43) is real R20b substrate and is live.
There is also no _start frame in this tree — mv_argv_parse and
move_dispatch are both present and tested, but nothing yet reads
mv_argv_src/mv_argv_dst into the dispatcher.
# When T-INFRA-001 (pkgs.paideia-os) is live:
pkg install mv
# Today, from source (skips the [sig.author] check per §9.3;
# still verifies the source-tree root matches the tag):
pkg install --from-source mv
Flag names are matched byte-for-byte against the whitelist in
MvArgv::mv_argv_parse; all four are boolean (no value operand), and all
four default to 0.
| Short | Long | Argument | Default | Description |
|---|---|---|---|---|
-v |
--verbose |
none | 0 |
Emit the cross-device / cross-user advisories on stderr (fd 2) after a successful commit. Sets mv_argv_verbose. |
-i |
— | none | 0 |
Interactive. Parsed into mv_argv_interactive; no consumer at 1.1.0 — the prompt lands with the shell.M4 line reader reachable through KIND_TTY. |
-f |
--force |
none | 0 |
Consent to overwriting an existing destination (mv.ENH-004, #20). Without it, move_dispatch refuses the move with MV_MV_DST_EXISTS when Pdxfs::pdxfs_dst_exists reports the destination present. Sets mv_argv_force. |
| — | --dry-run |
none | 0 |
Parse + validate + resolve parents only (mv.ENH-007, #23). move_dispatch checks mv_argv_dry_run immediately after resolving both parents and the source inode, and returns success without opening a TXN, emitting a MoveRecord, writing the audit journal, or threading an undo record. |
One caveat that the source contradicts the .pdxdoc on, and which the source
wins:
-
--interactive(the long spelling of-i) is not accepted. The whitelist compares against the literal names"v","verbose","i","f","force","dry-run"; anything else returnsMV_ARG_UNKNOWN_FLAGwith the offending index left inmv_argv_error_flag_index. -
-v/--verbosedoes not print a genericmv <src> <dst>line.Verbose::mv_verbose_diagemits only the two advisories, and only when the corresponding flag fired:mv: crossed device (cp+rm fallback, not O(1)) mv: crossed user (inode kept old owner)Both can fire in one operation. Emission is best-effort — the function always returns
0, even if the fd-2 write is refused.
Every successful move emits exactly one MoveRecord — 88 bytes, eleven u64
fields at schema v2 (widened from 80/10 by mv.ENH-004, #20 for the
dst_existed field at offset 80) — via Schema::mv_schema_emit. A refused
move (destination existed and no -f / --force) also emits the record
with dst_existed = 1 so the semantic-pipe consumer sees the refused intent.
At 1.1.0 that is a raw pdxfs_write(fd = 1, …) to stdout; when
libpdx-semantic-pipe lands the same call site switches to a schema-tagged
endpoint without changing any caller. A reader validates
magic == 0xFFFFEB5000000002 (high half = the 0xFFFFEB50 Schema band, low
half = layout version 2) before decoding.
The emit is best-effort from move_dispatch's perspective: a short write
(MV_SCH_SHORT_WRITE) or a negative errno (MV_SCH_EMIT_FAIL) bumps
MV_ST_ERRORS but does not gate the commit. Success bumps
MV_ST_RECORDS_EMITTED (stats slot 11).
Additive to the fd-1 stub blob above: Pipe::pipe_emit_move_record
(src/pipe.pdx) emits a second, real record — MoveRecord@0.2, 120 bytes
populated in a 128-byte buffer — through the kernel-side sys_semantic_send
producer ring (sysno 115, R107-M0-001 #2350), the same substrate cp's own
pipe_emit_copy_record (cp#33) uses. The record carries version/op
(packed into one u64), a seeded-FNV-1a64 (src_hash_lo, src_hash_hi) /
(dst_hash_lo, dst_hash_hi) path-fingerprint pair, bytes_moved (0 for a
same-device rename; the cross-device byte count otherwise), and an rdtsc
timestamp. The field shape is published independently as a schema
fingerprint in src/move_schema.pdx (MoveSchema::move_record_ddl +
MOVE_RECORD_SCHEMA_ID = 0xE0604D560002). Not yet wired into
Move::move_dispatch's success tail — see src/pipe.pdx's own header for
why that call-site edit is a deferred follow-up.
mv follows the shared I4 process-exit convention:
| Exit | Meaning |
|---|---|
0 |
Success — MoveRecord emitted, TXN committed, undo record threaded. |
1 |
Reserved; mv has no "query returned nothing" outcome. |
2 |
User error — the MV_ARG_* band (0xFFFFEB1x). |
3 |
System error — the MV_RN_* / MV_MV_* bands (0xFFFFEB2x / 0xFFFFEB3x). |
4 |
Capability denied — a cap from caps.decl is missing from the caller's InitCap sidecar. |
5 |
Signing / verification failure — reserved; manifest.pdxsig is checked by pkg, not by mv. |
Internally, every function returns a u64 in the 0xFFFFEBxx band whose high
two bytes identify the mv layer to a downstream consumer. The sub-bands are
declared in src/mv.pdx; the full per-code table is in STATUS.md.
| Sub-band | Module | Covers |
|---|---|---|
0xFFFFEB00 |
Mv |
MV_OK |
0xFFFFEB1x |
MvArgv |
bad argc/argv, wrong positional count, unknown flag, libpdx-argv parse error |
0xFFFFEB2x |
Rename |
M1 same-dir skeleton: bad src/dst, TXN open/unlink/link/commit refusals |
0xFFFFEB3x |
Move |
resolve/inode/txn-open/unlink/link/commit failures, plus the six cross-device fallback codes 0xFFFFEB38–0xFFFFEB3D |
0xFFFFEB4x |
Inode |
reserved — mv_inode_preserve returns 0 for every outcome |
0xFFFFEB5x |
Schema |
MV_SCH_EMIT_FAIL, MV_SCH_SHORT_WRITE |
0xFFFFEB6x |
Audit |
MV_AUD_LOOKUP_FAIL, MV_AUD_SEND_FAIL |
0xFFFFEB7x |
Undo |
MV_UND_WRITE_FAIL |
0xFFFFEB8x |
Elevate / ElevateGate |
MV_ELV_LOOKUP_FAIL, MV_ELV_SEND_FAIL, MV_ELV_DENIED, MV_ELVG_STUB (LE-001, #29) |
caps.decl declares six required capabilities, each refusable at exec via
--no-cap:<name>:
requires:
- KIND_USER (self)
- KIND_IPC_ENDPOINT (invoke)
- KIND_PDXFS_FILE (write, <src-parent>)
- KIND_PDXFS_FILE (write, <dst-parent>)
- KIND_PDXFS_TXN (invoke, mint)
- KIND_ELEVATE_CHANNEL (invoke, svc.elevate-broker)
declares_output_schemas: (none)
The effect and capability rows on the entry points, verbatim from source:
Move::move_dispatch : (u64, u64) -> u64 !{mem, sysreg} @{cap, sched}
Move::move_cross_dev_body : (u64, u64) -> u64 !{mem, sysreg} @{cap, sched}
MvArgv::mv_argv_parse : (u64, u64) -> u64 !{mem} @{}
Audit::mv_audit_write_move : () -> u64 !{mem, sysreg} @{cap, sched}
Undo::mv_undo_write : (u64) -> u64 !{mem, sysreg} @{}
Schema::mv_schema_emit : () -> u64 !{mem, sysreg} @{}
Elevate::mv_elevate_cross_user : (u64) -> u64 !{mem, sysreg} @{cap}
Inode::mv_inode_preserve : (u64, u64) -> u64 !{mem, sysreg} @{cap}
Verbose::mv_verbose_diag : () -> u64 !{mem, sysreg} @{}
@{cap} appears wherever a capability is minted or consumed — pdxfs_txn_open
mints a fresh KIND_PDXFS_TXN (0x196), svc_lookup mints a
KIND_IPC_ENDPOINT (5), and ipc_send consumes it. @{sched} marks the
paths that may block on the WAL drain or on device I/O.
Rename in place. Same parent, one TXN, one dirent rewrite:
mv old.txt new.txt
Move into a subdirectory. src_parent != dst_parent, still one TXN;
MV_ST_CROSS_DIR bumps alongside MV_ST_MOVES. If sub/ is not writable, the
exec-time cap_manifest_verify fails on the KIND_PDXFS_FILE (write, <dst-parent>) requirement and mv exits 4 before any TXN opens:
mv file.txt sub/file.txt
Cross-volume move with the advisory shown. pdxfs_link returns EXDEV, the
cp+rm fallback runs inside the outer TXN, and stderr gets one line:
$ mv -v report.pdx /mnt/archive/report.pdx
mv: crossed device (cp+rm fallback, not O(1))
A destination-clobber guard refusal (mv.ENH-004, #20). b already exists
and -f / --force is absent; move_dispatch probes pdxfs_dst_exists
before opening a TXN, refuses with MV_MV_DST_EXISTS (0xFFFFEB3E), and
emits the diagnostic to stderr:
$ mv a b
mv: cannot move 'a' to 'b': destination exists (use -f to overwrite)
$ mv -f a b # overwrite consented; mv proceeds
A rejected flag. --unknown is not in the whitelist, so parsing stops
before any filesystem work and mv_argv_parse returns
MV_ARG_UNKNOWN_FLAG (0xFFFFEB14), exit 2:
mv --unknown a b
An audit-journal outage. svc.audit-journal is unreachable, ipc_send returns
-104, mv_audit_write_move returns MV_AUD_SEND_FAIL (0xFFFFEB62), and
move_dispatch aborts the TXN — a is still a and b never appeared:
mv a b
Three fixed-layout records are built in .bss and shipped off the process.
All fields are u64; all offsets are literal in the emitting assembly.
MoveRecord — 88 bytes at schema v2, src/schema.pdx. Populated by
mv_schema_populate(src_ptr, dst_ptr) and emitted on the semantic pipe by
Schema::mv_schema_emit. Audit::mv_audit_write_move (mv.ENH-008, #24) no
longer sends this record verbatim to svc.audit-journal itself — it reports
the move through libpdx-audit's AuditClient three-call lifecycle
(audit_begin / audit_record_output / audit_commit), the same wire rm
uses, with the record's src_ptr field carried as audit_record_output's
placeholder output_hash.
| Offset | Field | Notes |
|---|---|---|
| 0 | magic |
MV_MOVE_RECORD_MAGIC = 0xFFFFEB5000000002 (schema v2) |
| 8 | was_rename |
1 iff src_parent == dst_parent |
| 16 | was_cross_device |
mirrors Move::mv_move_was_cross_device |
| 24 | was_cross_user |
mirrors Move::mv_move_was_cross_user |
| 32 | src_ptr |
pointer to the NUL-terminated source path |
| 40 | dst_ptr |
pointer to the NUL-terminated destination path |
| 48 | src_inode |
the moved inode |
| 56 | src_parent |
source parent inode |
| 64 | dst_parent |
destination parent inode |
| 72 | txn_handle |
lets a consumer correlate the record to PdxFS TXN state |
| 80 | dst_existed |
mv.ENH-004 (#20): 1 iff destination existed at probe time |
The path fields are opaque pointers into the caller's argv memory — mv does
not copy the strings into the record. Both M3 consumers write synchronously, so
the pointers are live for the duration; an inline path trailer is deferred to
the R42 substrate landing.
UndoRecord — 32 bytes, src/undo.pdx. Written into the TXN's WAL group by
mv_undo_write(txn_handle) via pdxfs_txn_write_undo (sysno 522), so it is
durable exactly when the commit succeeds and discarded with the rest of the WAL
group on abort.
| Offset | Field | Notes |
|---|---|---|
| 0 | magic |
MV_UNDO_MAGIC = 0xFFFFEB7000000001 |
| 8 | replay_op |
MV_UNDO_OP_MV = 0x6D76, "mv" packed little-endian |
| 16 | replay_src_ptr |
the original dst — source of the reverse move |
| 24 | replay_dst_ptr |
the original src — target of the reverse move |
ElevateRequest — 32 bytes, src/elevate.pdx. Sent to svc.elevate-broker
by mv_elevate_cross_user(dst_owner_key) on the cross-user path.
| Offset | Field | Notes |
|---|---|---|
| 0 | magic |
MV_ELV_REQUEST_MAGIC = 0xFFFFEB8000000001 |
| 8 | requested_kind |
ELV_KIND_USER = 0x190 |
| 16 | requested_key |
the destination owner's key to sign under |
| 24 | duration_secs |
MV_ELV_WINDOW_SECS = 60 |
doc/mv.pdxdoc and manifest.pdxsig previously described the MoveRecord as 64
bytes under schema id 0x4D56 and the undo magic as 0x4D566E52 — pre-M3
placeholders that were never updated to match the M3 implementation. Both were
corrected to the layouts above by mv.ENH-009 (#25); CHANGELOG.md's historical
M3 entry keeps the original (wrong) numbers with an erratum note rather than
rewriting release history.
- libpdx-argv — the flag/positional
parser
MvArgvwraps. - libpdx-audit — user-events journal client.
- cp — peer coreutil; shares the cross-device byte-copy discipline.
- rm — peer coreutil; shares the audit and elevate integration.
In-tree: doc/mv.pdxdoc (read via doc mv), design/architecture.md for the
module shape, STATUS.md for the per-milestone rollup and the complete
return-code table, CHANGELOG.md, RELEASE.md for the signing runbook, and
MIRROR-PUSH.md for the pkgs.paideia-os mirror push.
MIT — see LICENSE.