Repository navigation
fix(du): follow directory-symlink operands under -L/-H (Refs #1656) - #1663
Closed
caomengxuan666 wants to merge 1 commit into
Closed
caomengxuan666 wants to merge 1 commit into
caomengxuan666 wants to merge 1 commit into
Conversation
The -L/-H operand gate probed with std::filesystem::status(), which reports an error for a directory-symlink operand even when its target exists, so a live directory link was misread as dangling: `du: cannot access 'dirlink'`, rc 1. Probe through native_path::attributes_w (GetFileAttributesW follows the link; ls already routes its operand probes through the same helper, #1145). The dangling-vs-missing distinction is unchanged: a dangling link still prints no errno text, exactly like GNU coreutils 9.4 (probed). Tests: 5 new cases in tests/unit/du/du_unit_test.cpp (-L/-H dirlink operands, file-link lock, dangling exact no-reason form, missing reason form).
Member
Author
队长复核:FAIL(自家新钉在 CI 红)build-windows x64 default 红,3882 测中仅 2 败,皆为本 PR 新钉(并行跑 + ctest-gate 串行重试皆红,非 flake;队长读过失败日志原文):
Windows 上 返工:给 dangling 操作数补报错臂(rc 1 + |
Member
Author
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.
fix(du): follow directory-symlink operands under -L/-H (Refs #1656)
Summary
du -L -s dirlink(dirlink → dir)报du: cannot access 'dirlink'、rc=1;GNU 9.4 跟随链接并打印分配行、rc=0。根因是 -L/-H 门谓词
(du.cpp:1548)用的
std::filesystem::status()对目录符号链接操作数报错,活链接被误判为悬空。改用
native_path::attributes_w(GetFileAttributesW 跟随链接;ls 已因 #1145 走同一原语)。
“错误行缺原因”不是独立格式缺陷:悬空链接的报错按 GNU 本来就没有原因
后缀(本地 9.4 实测
du: cannot access 'dangling');活链接修好后不再报错,该症状随之消失。悬空臂与缺失臂文本原样保留。
GNU semantics
本地 coreutils 9.4 实测:
du -L -s dirlink→4<TAB>dirlinkrc 0;du -L -s dangling→du: cannot access 'dangling'rc 1;du -L -s missing→du: cannot access 'missing': No such file or directoryrc 1;du -H -s dirlink→ 跟随 rc 0。Verification
文件链接锁、悬空精确无原因形、缺失带原因形。
编译 Windows-only C++。
What this PR deletes
Refs #1656