Skip to content

Comments

ac_fs: Re-work ac_fs_mkdir_p()#30

Merged
ac000 merged 1 commit intomasterfrom
mkdir_p
Sep 15, 2025
Merged

ac_fs: Re-work ac_fs_mkdir_p()#30
ac000 merged 1 commit intomasterfrom
mkdir_p

Conversation

@ac000
Copy link
Owner

@ac000 ac000 commented Sep 15, 2025

Avoid prepending a '/' to absolute pathnames.

Also use fstatat(2) to check if the current directory component exists and if so skip the mkdirat(2).

@ac000 ac000 requested a review from Copilot September 15, 2025 22:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the ac_fs_mkdir_p() function to improve handling of absolute pathnames and optimize directory creation by checking for existing directories before attempting to create them.

Key changes:

  • Fixes handling of absolute paths by avoiding prepending '/' when the path already starts with '/'
  • Adds fstatat(2) check to skip mkdirat(2) calls for existing directories
  • Optimizes the directory creation process by reducing unnecessary system calls

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Avoid prepending a '/' to absolute pathnames.

Also use fstatat(2) to check if the current directory component exists
and if so skip the mkdirat(2).

Signed-off-by: Andrew Clayton <ac@sigsegv.uk>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ac000 ac000 merged commit d8e4ba4 into master Sep 15, 2025
8 of 9 checks passed
@ac000 ac000 deleted the mkdir_p branch September 15, 2025 22:54
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.

1 participant