Skip to content

Conversation

@eriksjolund
Copy link
Contributor

@eriksjolund eriksjolund commented Dec 8, 2025

Fail early to make the code easier to read.

What do you think? Does it make sense?

Summary by Sourcery

Bug Fixes:

  • Return a specific error when opening the parent directory component fails instead of silently continuing after access checks.

Fail early to make the code easier to read.

Signed-off-by: Erik Sjölund <[email protected]>
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 8, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors error handling around openat failure in make_parent_mount_private to fail early with a clearer, more precise error while preserving the original errno.

File-Level Changes

Change Details Files
Improve error handling when openat("..") fails in make_parent_mount_private to fail fast with a specific error and preserved errno.
  • Capture errno immediately when openat on the parent directory fails
  • On access failure, continue to return an EACCES error indicating an inaccessible component
  • On successful access check but open failure, return an error using the saved errno with a message indicating the component cannot be opened
src/libcrun/linux.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • This change alters behavior by treating an openat failure as fatal even when the subsequent faccessat succeeds; if the intent is only to fail when the directory is inaccessible, consider whether you still want to allow execution to continue when faccessat passes but openat fails for another reason (e.g., ENFILE, EMFILE).
  • Consider declaring saved_errno as const int to document that it is not modified after capturing errno and to make the intent slightly clearer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- This change alters behavior by treating an `openat` failure as fatal even when the subsequent `faccessat` succeeds; if the intent is only to fail when the directory is inaccessible, consider whether you still want to allow execution to continue when `faccessat` passes but `openat` fails for another reason (e.g., `ENFILE`, `EMFILE`).
- Consider declaring `saved_errno` as `const int` to document that it is not modified after capturing `errno` and to make the intent slightly clearer.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@packit-as-a-service
Copy link

TMT tests failed. @containers/packit-build please check.

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@giuseppe giuseppe merged commit 357d650 into containers:main Dec 9, 2025
44 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants