Repository navigation
fix: report a failed destination-root mkdir as RERR_FILEIO on every path - #8344
Merged
Merged
Conversation
oferchen
force-pushed
the
fix/local-dest-mkdir-fileio
branch
from
November 10, 2026 15:13
bd84f3f to
f58c293
Compare
oferchen
force-pushed
the
fix/local-dest-mkdir-fileio
branch
from
November 10, 2026 17:52
f58c293 to
de41e63
Compare
oferchen
force-pushed
the
fix/local-dest-mkdir-fileio
branch
2 times, most recently
from
November 10, 2026 20:35
7aed4df to
b1fa129
Compare
This was referenced Nov 10, 2026
oferchen
force-pushed
the
fix/local-dest-mkdir-fileio
branch
3 times, most recently
from
November 11, 2026 10:32
80f9e2f to
0a6a71b
Compare
oferchen
force-pushed
the
fix/local-dest-mkdir-fileio
branch
2 times, most recently
from
November 11, 2026 10:55
cb27979 to
435f882
Compare
Owner
Author
|
Merge train: this pull request failed its batch run on its own (https://github.com/oferchen/rsync/actions/runs/43031147828). Failed required checks: upstream-testsuite / upstream testsuite, . It is held out of batches until its head changes. |
oferchen
added a commit
that referenced
this pull request
Nov 11, 2026
…8360) ## Summary A daemon session's process now exits with the code its transfer ended on, and the daemon log carries log_exit()'s lines in place of an invented summary, as rsync 3.5.1's per-connection child does. - **Exit status** (cleanup.c:213-218, :264): - A transfer that runs to its end maps `io_error` and `got_xfer_error` to its code via `core::exit_code::io_error_exit_code`, so a partial transfer exits 23. - A fatal transfer exits with the peer's `MSG_ERROR_EXIT` code if one arrived (io.c:1930), otherwise with its own RERR code. - The code goes into `session_exit_code`. The forked TCP child now exits with it; before, it dropped it via `.map(|_| ())` and always exited 0. The stdio and inetd sessions already turned that field into their exit status. - **Daemon log** (log.c:937-963, log.c:310-327): - A fatal error logs the cause line and the `rsync error: ... (code N)` trailer from `fatal_report_lines`, the same lines the client is sent. This replaces the invented `transfer failed to HOST (IP): module=M error=E` line. - The `sent ... received ... total size` line is written only for a clean exit or a sender (log.c:941). - A partial transfer's end-of-run exit logs no trailer (`am_server = 2`, cleanup.c:121-122). - **Abortive close** on the receiver now keys on a fatal error rather than on a nonzero code, so a partial push (code 23) keeps the graceful close. ## Evidence All cells are measured against the 3.5.1 tarball build. Server exit statuses come from strace (TCP daemon) or an rsh shim (daemon mode via `--rsync-path`). | cell | 3.5.1 server | oc before | oc after | |---|---|---|---| | pull of a missing file | exit 23, totals | exit 0, totals | exit 23, totals | | clean pull | exit 0, totals | exit 0 | exit 0, totals | | push with an unreadable source subdir (receiver io_error) | exit 23, no totals, no trailer | exit 0, totals | exit 23, no totals, no trailer | | push into a 0555 dir | exit 11, mkdir cause + trailer | exit 0, `transfer failed to` line | exits with the trailer's code, trailer logged (3, see residuals) | `tests/daemon_session_exit_status.rs` covers four cells in rsh daemon mode and asserts the server process's exit status and the daemon log. It is deterministic: the oc client reaps its rsh child before exiting. The unreadable-dir cell skips with a printed reason when run as root. **Mutants, all killed:** - A partial transfer exits 0: two cells. - A receiver logs totals on code 23: the io_error push cell. - Nothing is logged on a fatal error: the fatal push cell. - `session_exit_code` is not set: three cells. - A fatal error exits 1: the fatal push cell. ## Residuals - **Push into a 0555 dir:** oc reports code 3 where 3.5.1 reports 11 with the `mkdir ... failed` cause. That is #8344 (local) and task 611 (daemon); this PR makes the session exit with whatever code is reported. - **Trailer role tag:** it says `[generator=` on the receiver; 3.5.1 says `[Receiver=` for the pre-fork mkdir. - **Sender totals on a fatal exit:** oc's sender logs none, because it has no stats on the error path. 3.5.1 logs them even on error (log.c:941). - **Missing source:** the oc daemon sender logs neither the `link_stat ... failed` line nor the real totals. That is task 280. - **Forked TCP child's exit status:** a test can't observe it. The parent records it only at `--debug=EXIT`, and upstream discards it. The strace oracle cell above covers it, and the rsh cells exercise the same `session_exit_code` path. ## Test plan - [x] `python3 tools/ci/check_rustfmt_all.py` - [x] Workspace clippy with all features, plus no-default-features clippy of `daemon` - [x] `cargo nextest run -p daemon --all-features`: 2152 passed - [x] Targeted `-p bin` (178), `-p core` and `-p transfer` (530) daemon, inetd and stdio tests - [x] 3.5.1 oracle: TCP strace exits and rsh daemon-mode statuses and logs
upstream main.c:817-821 get_local_name() makes the destination root with one do_mkdir() (make_path() under --mkpath jumps to the same label) and on failure prints `mkdir %s failed` through rsyserr(), then exits RERR_FILEIO. It runs before do_recv() forks, so the line and the log_exit() trailer name the unforked `Receiver` (rsync.c:987-995). oc exited 23 on a local copy and 3 on an rsh or daemon push. - local copy: the engine reports the failure as DestinationMkdirFailed (exit 11), which the client renders as rsyserr's program line plus the `[Receiver=` trailer - a local copy decides the pre-flight mkdir from upstream's file_total > 1 (main.c:808): the operands of the first file list, a repeated one counted twice, after the filter rules, plus the contents of a lone expanded directory (flist.c:3096); `src/`, `-d src/` and a file given twice now take it, a directory whose every child is excluded does not, and a followed directory symlink keeps its name under the destination - rsh and daemon receivers wrap the cause in DestRootMkdirError, which grades RERR_FILEIO; the server writes its report through the fatal report hook before MSG_ERROR_EXIT, on the fds and stdio entries alike - a daemon renders the root module-relative, `"dir" (in module)` (util1.c:1528)
oferchen
force-pushed
the
fix/local-dest-mkdir-fileio
branch
from
November 12, 2026 23:19
435f882 to
090e921
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When rsync cannot create the destination root, 3.5.1 exits 11 (RERR_FILEIO) with
mkdir "<dir>" failed: <errno>on every transfer path. oc exited 23 on a local copy and 3 on an rsh or daemon push. This PR fixes all three paths, which share one cause (tasks 585, 576 and 611).Upstream: main.c:808-821
get_local_name(). Whenfile_total > 1 || trailing_slash, it callsdo_mkdir(); with--mkpath,make_path()jumps to the same label. On failure it printsrsyserr(FERROR, errno, "mkdir %s failed", full_fname(dest_path))and exitsRERR_FILEIO. This runs beforedo_recv()forks, so the line and the trailer name the unforkedReceiver(rsync.c:987-995).Changes
DestinationMkdirFailedkind (exit 11).[Receiver=trailer.file_total_exceeds_one(newsources/file_total.rs), now decides it the way upstream's first file list counts:-r/-dcount nothing (flist.c:2937-2966).send_extra_file_list()), judged by the same rules the walk applies there, its per-dir merge files included. A directory whose every child is excluded stays a single entry, so the destination becomes that directory and a mkdir failure is recv_generator's per-file error (exit 23).-d src/ dstanda a dstnow createdst/like 3.5.1, and-rL/-rkof a symlink to a directory now lands atdst/<link>/...like 3.5.1 (oc copied the contents intodst/itself; the three engine tests that pinned that are corrected).DestRootMkdirError, which grades RERR_FILEIO.MSG_ERROR_EXIT.run_server_fdsandrun_server_stdioboth pass the hook now."ro/new" (in m). The daemon skips change_dir#4 (main.c:1212), so full_fname uses the module form (util1.c:1528).Evidence
The 3.5.1 oracle is the tarball build (
~/up351/rsync-3.5.1/rsync). The fixture is a destinationro/new, whererois 0555.-r src ro/new/rsync: [Receiver] mkdir "…/ro/new" failed: Permission denied (13)-r src/ ro/new-r a b ro/newmkdir "ro/new" (in m) failedLocal operand edges of the main.c:808 rule, destination
ro/newunder a 0555ro, 3.5.1 exit vs oc exit (all match except the two pre-existing rows marked):-r src,-r src/,-r src/ ro/new/,-R src,-R src/-r src/with every child excluded;-r srclikewise-r empty/-d src/-d srca a(same file twice)a bro/new/--mkpath src/ ro/x/new-rn src/a missing(pre-existing, task 623)-R src/a(pre-existing, task 623)The success-path trees match 3.5.1 for two files,
-d src/, every child excluded (with and without the slash), a file given twice and one child excluded.The happy path is unchanged against 3.5.1 for
-ri,-rv,--stats,-rinand-di.Tests:
tests/server_error_exit_code_reaches_client.rsgains cells per path:local_copy_dest_mkdir_failure_reports_file_io, the existing rsh cell,daemon_dest_mkdir_failure_reports_file_io, andlocal_copy_dest_root_mkdir_follows_file_total(every child excluded: 23;-d src/: 11; a file given twice: 11). Each runs under both the oc client and the 3.5.1 client. Engine tests:permission_destination_mkdir_denied_exits_file_io(new).execute_directory_source_deep_missing_dest_errors_without_mkpath(now expects exit 11).map_destination_mkdir_failed_reports_file_io_as_receiver.Mutation, each mutant run against the targeted filter:
local_copy_dest_root_mkdir_follows_file_total(every child excluded).-dcopy-contents not expanded) is killed by the same test (-d src/).Gates on the amended head, rebased on 75c4a1d (after #8321):
tools/ci/check_rustfmt_all.pyOK.-D warnings --all-targets --all-featuresclean on engine, core, cli, transfer, embedding and daemon.cargo nextest -p engine4952/4952, plus the cli server, signal, error-exit and local-copy cells.Residual
a missing dstexits 11 (3.5.1: 23, file_total 1);-R src/a dstrefuses with oc's own text (3.5.1: 11, the impliedsrccounts).-m, a top-level operand excluded by- *is still walked by oc; 3.5.1 lists nothing. The new count mirrors oc's walk there, so behaviour is unchanged.A 3.5.1 client against an oc daemon prints one extra trailing line,
[sender] read error: Connection reset by peer (104), after the matching mkdir line and exit 11. This is task 232 (echo MSG_ERROR_EXIT and drain until the peer exits), not part of this PR.