Repository navigation
fix: report make_path's own errno when --mkpath meets a file - #8901
Merged
Merged
Conversation
A local --mkpath into a destination whose chain holds a regular file printed an invented inspect-destination line and exited 23. rsync 3.5.2 hands an unstattable destination to make_path() and prints mkdir %s failed with the deepest mkdir's errno, exiting 11. make_path_beneath_cwd now tries the deepest directory first and maps a non-directory intermediate to ELOOP like secure_relative_dirfd(), the absolute arm uses operator_make_path, and the network receiver lets that walk report the errno instead of its counting stat.
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
A local copy with
--mkpathinto a destination whose path runs through aregular file printed an invented line,
failed to inspect destination, andexited 23. rsync 3.5.2 prints
mkdir "<dest>" failed: <make_path's errno>andexits 11.
rsync 3.5.2:
get_local_name()hands a destination that does not stat tomake_path()(main.c:757-761). A failure jumps to
mkdir_error(main.c:818-821):mkdir %s failedwithfull_fname(dest_path)as given (trailing slashkept), then
RERR_FILEIO(11).make_path()(util1.c:231-247) tries the deepest directory first and climbsonly on
ENOENT, so the errno reported is the deepest mkdir's.EEXISTcounts as success only for a directory (util1.c:244-246).
do_mkdir_at()opens the parentthrough
secure_relative_dirfd(), which reports a non-directoryintermediate as
ELOOP(syscall.c:3279-3281). An absolute destination usesplain
mkdir()and keepsENOTDIR.This change:
--mkpathno longer aborts; thedestination goes to make_path, and its failure renders as
mkdir "<dest>" failedwith exit 11. The--mkpathline keeps the trailingslash (main.c:760); the plain-mkdir line still cuts it (main.c:815).
directory (util1.c:244-246).
make_path_beneath_cwdwalks deepest-first like make_path, and mapsa non-directory intermediate to
ELOOPthe waysecure_relative_dirfddoes. The absolute arm uses
operator_make_path.ENOTDIRso themaking pass reports the errno (the same deepest-first rule as fix: walk a network receiver destination before mkdir #8899).
Measured, rsync 3.5.2 vs this branch
dst/dstfileis a regular file. Errno printed; every cell exits 11 on both.Local, push and pull give the same results.
f dst/dstfile/xf dst/dstfile/x/f dst/dstfile/x/y/f dst/dstfile/x/y-r dst/dstfile/x-r dst/dstfile/x/y/Before this change, a local copy printed
failed to inspect destinationandexited 23 for every row. A network receiver given a relative destination
printed 20 where 3.5.2 prints 40.
No deviation from rsync 3.5.2.
Tests
crates/cli/tests/mkpath_through_a_regular_file.rs: the 6 shapes xrelative/absolute on the local, push and pull legs. Each cell runs oc to oc,
and when
OC_RSYNC_UPSTREAM_BIN_3_5_2resolves also 3.5.2 to 3.5.2 and bothmixed pairs. Asserts exit 11, the exact
mkdir "<path>" failed: <strerror> (<n>)line, no invented text, and that the regular file survives. Thestrerror and errno come from the kernel, not from strings in the test.
crates/fast_io/tests/make_path_beneath_cwd.rs: a regular file as thedeepest directory's parent gives
ENOTDIR; one higher givesELOOP.Mutations, each restored afterwards:
ELOOPmapping for a non-directory intermediateENOTDIRVerification
cargo fmt --all -- --check: cleancargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings: cleanx86_64-pc-windows-gnu: cleancargo doc --workspace --all-features --no-deps --locked: cleancargo nextest run -p cli --test mkpath_through_a_regular_filewith the3.5.2 oracle required (
OC_RSYNC_UPSTREAM_COMPAT=1): 3 passedcargo nextest run -p fast_io --test make_path_beneath_cwd: 8 passed-p engine -p fast_io -p transfer -E 'test(mkpath) | test(make_path) | test(destination) | test(dest_root)': 338 run, 323 passed. The 15 failures were tests thatspawn
oc-rsyncbefore it was built; aftercargo build -p bin, a rerun ofthose 15 (39 matching tests) passed.
rsync_io, the 3ssh_config_differentialcells failon the build host: its ssh is OpenSSH_10.6p2, which rejects the
transportkeyword. This branch does not touchrsync_io.bin'sdestination_root_owner_walkneeds root orpasswordless sudo. It runs in the nextest and musl jobs.