Skip to content

Add symlinkat, renameatx_np, and unlinkat system call wrappers#3505

Merged
glbrntt merged 3 commits intoapple:mainfrom
stepan-ulyanin:add-system-calls
Feb 9, 2026
Merged

Add symlinkat, renameatx_np, and unlinkat system call wrappers#3505
glbrntt merged 3 commits intoapple:mainfrom
stepan-ulyanin:add-system-calls

Conversation

@stepan-ulyanin
Copy link
Copy Markdown
Contributor

@stepan-ulyanin stepan-ulyanin commented Feb 7, 2026

Adds three new system call wrappers for the symlinkat, renameatx_np, and unlinkat system calls.

Motivation:

Related to #3403 and #3470. This PR adds syscall wrappers needed to atomically overwrite existing files or symlinks at the destination during copy operations. On Linux, atomic overwrites require a "copy to temp file, then rename" strategy. We use the *at family of syscalls (which operate relative to directory file descriptors) to avoid TOCTOU race conditions.

Modifications:

  1. Adds three system call wrappers for the symlinkat, renameatx_np, and unlinkat system calls.
  2. Adds related tests
  3. Updates the FileSystemError for symlink and unlink to take in the system call name to allow for the *at names to be passed.

@stepan-ulyanin stepan-ulyanin marked this pull request as draft February 7, 2026 00:58
Copy link
Copy Markdown
Contributor

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @stepan-ulyanin!

@glbrntt glbrntt added the 🔨 semver/patch No public API change. label Feb 9, 2026
@glbrntt glbrntt merged commit db01d87 into apple:main Feb 9, 2026
55 of 56 checks passed
@stepan-ulyanin stepan-ulyanin deleted the add-system-calls branch February 9, 2026 23:46
glbrntt pushed a commit that referenced this pull request Mar 2, 2026
…to the `_NIOFileSystem` module (#3524)

Ports the added system calls from `NIOFS` (from
#3505) to `_NIOFileSystem`:

> Adds three new system call wrappers for the `symlinkat`,
`renameatx_np`, and `unlinkat` system calls.

### Motivation:

`_NIOFileSystem` module is around for backward compatibility - hence, we
are porting the new feature to it.

### Modifications:

Exactly same as in #3505 but
applied to the `_NIOFileSystem`:

> Related to #3403 and
#3470. This PR adds syscall
wrappers needed to atomically overwrite existing files or symlinks at
the destination during copy operations. On Linux, atomic overwrites
require a "copy to temp file, then rename" strategy. We use the `*at`
family of syscalls (which operate relative to directory file
descriptors) to avoid TOCTOU race conditions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants