Skip to content

[fix][uab-packager] Enhance statvfs failure logs with system error details#1759

Open
zhaohai666 wants to merge 1 commit into
OpenAtom-Linyaps:masterfrom
zhaohai666:fix/uab-packager-statvfs-error-messages
Open

[fix][uab-packager] Enhance statvfs failure logs with system error details#1759
zhaohai666 wants to merge 1 commit into
OpenAtom-Linyaps:masterfrom
zhaohai666:fix/uab-packager-statvfs-error-messages

Conversation

@zhaohai666

Copy link
Copy Markdown

Summary

When the statvfs() syscall fails, original error messages only printed the target path without the detailed system error description derived from errno. 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:

  1. Original: couldn't stat module files directory " + path
    Revised: fmt::format("couldn't stat module files directory {}: {}", path, std::generic_category().message(errno))
  2. Original: couldn't stat files directory " + path
    Revised with the same formatting pattern
  3. Original: couldn't stat layers directory " + path
    Revised with the same formatting pattern
  4. Original: couldn't stat layer directory " + path
    Revised with the same formatting pattern

Modified File

  • libs/linglong/src/linglong/package/uab_packager.cpp

Benefits

  • Complete error logs include root causes like permission denied, no such file or directory
  • Faster diagnosis of disk stat failures without extra debugging
  • Follow standard C++ error reporting conventions instead of plain path-only logs

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>
@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +361 to +363
return LINGLONG_ERR(fmt::format("couldn't stat module files directory {}: {}",
moduleFilesDir.string(),
std::generic_category().message(errno)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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)));

Comment on lines +367 to +369
return LINGLONG_ERR(fmt::format("couldn't stat files directory {}: {}",
layer.filesDirPath().string(),
std::generic_category().message(errno)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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)));

Comment on lines +642 to +644
return LINGLONG_ERR(fmt::format("couldn't stat layers directory {}: {}",
layersDir.string(),
std::generic_category().message(errno)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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)));

Comment on lines +664 to +666
return LINGLONG_ERR(fmt::format("couldn't stat layer directory {}: {}",
layerPath.string(),
std::generic_category().message(errno)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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)));

@zhaohai666
zhaohai666 force-pushed the fix/uab-packager-statvfs-error-messages branch from 272a5c9 to 4c33ab8 Compare July 17, 2026 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants