[fix][uab-packager] Enhance statvfs failure logs with system error details#1759
Conversation
statvfs error messages now include the errno description using std::generic_category().message(errno) for better diagnostics. Affected functions: prepareExecutableBundle and prepareDistributedBundle. Signed-off-by: zhaohaihzb <zhaohaihzb@126.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zhaohai666 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @zhaohai666. Thanks for your PR. I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Code Review
This pull request improves error reporting in uab_packager.cpp by using fmt::format to include the directory path and the system error message when statvfs fails. The reviewer feedback correctly points out that errno is volatile and can be overwritten by intermediate function calls (such as .string() or memory allocations) before it is evaluated. It is recommended to capture errno immediately after the failing system call to ensure the correct error message is logged.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| return LINGLONG_ERR(fmt::format("couldn't stat module files directory {}: {}", | ||
| moduleFilesDir.string(), | ||
| std::generic_category().message(errno))); |
There was a problem hiding this comment.
The value of errno is highly volatile and can be overwritten by subsequent function calls (such as moduleFilesDir.string() or memory allocations inside fmt::format's arguments evaluation) before std::generic_category().message(errno) is evaluated. To ensure the correct error code is logged, capture errno immediately after the failing system call.
const int err = errno;
return LINGLONG_ERR(fmt::format("couldn't stat module files directory {}: {}",
moduleFilesDir.string(),
std::generic_category().message(err)));| return LINGLONG_ERR(fmt::format("couldn't stat files directory {}: {}", | ||
| layer.filesDirPath().string(), | ||
| std::generic_category().message(errno))); |
There was a problem hiding this comment.
The value of errno is highly volatile and can be overwritten by subsequent function calls (such as layer.filesDirPath().string() or memory allocations inside fmt::format's arguments evaluation) before std::generic_category().message(errno) is evaluated. To ensure the correct error code is logged, capture errno immediately after the failing system call.
const int err = errno;
return LINGLONG_ERR(fmt::format("couldn't stat files directory {}: {}",
layer.filesDirPath().string(),
std::generic_category().message(err)));| return LINGLONG_ERR(fmt::format("couldn't stat layers directory {}: {}", | ||
| layersDir.string(), | ||
| std::generic_category().message(errno))); |
There was a problem hiding this comment.
The value of errno is highly volatile and can be overwritten by subsequent function calls (such as layersDir.string() or memory allocations inside fmt::format's arguments evaluation) before std::generic_category().message(errno) is evaluated. To ensure the correct error code is logged, capture errno immediately after the failing system call.
const int err = errno;
return LINGLONG_ERR(fmt::format("couldn't stat layers directory {}: {}",
layersDir.string(),
std::generic_category().message(err)));| return LINGLONG_ERR(fmt::format("couldn't stat layer directory {}: {}", | ||
| layerPath.string(), | ||
| std::generic_category().message(errno))); |
There was a problem hiding this comment.
The value of errno is highly volatile and can be overwritten by subsequent function calls (such as layerPath.string() or memory allocations inside fmt::format's arguments evaluation) before std::generic_category().message(errno) is evaluated. To ensure the correct error code is logged, capture errno immediately after the failing system call.
const int err = errno;
return LINGLONG_ERR(fmt::format("couldn't stat layer directory {}: {}",
layerPath.string(),
std::generic_category().message(err)));272a5c9 to
4c33ab8
Compare
Summary
When the
statvfs()syscall fails, original error messages only printed the target path without the detailed system error description derived fromerrno. This lack of context makes troubleshooting difficult for issues such as insufficient permissions or missing directories.Changes
Updated four statvfs error log statements to append human-readable system error text via
std::generic_category().message(errno)using formatted strings:couldn't stat module files directory " + pathRevised:
fmt::format("couldn't stat module files directory {}: {}", path, std::generic_category().message(errno))couldn't stat files directory " + pathRevised with the same formatting pattern
couldn't stat layers directory " + pathRevised with the same formatting pattern
couldn't stat layer directory " + pathRevised with the same formatting pattern
Modified File
libs/linglong/src/linglong/package/uab_packager.cppBenefits