python / python/cpython

Add os.linkat() function to create a hard link with flags

Open
#136,413 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

extension-modules type-feature
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

os.link() can call linkat() but it only supports AT_SYMLINK_FOLLOW flag (follow_symlinks=True), it doesn't support AT_EMPTY_PATH. I propose adding the os.linkat() function to create a hard link with flags, and add the following constants:

  • os.AT_FDCWD
  • os.AT_SYMLINK_FOLLOW
  • os.AT_EMPTY_PATH

AT_EMPTY_PATH allows creating a hard link from an unnamed name even if /proc is not mounted.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

https://github.com/python/cpython/issues/136156

Linked PRs
  • gh-136417

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the related discussion in issue 136156 and the linked PR 136417, then inspect how os.link() currently exposes linkat() and AT_SYMLINK_FOLLOW. Done means the proposed os.linkat() behavior and the AT_FDCWD, AT_SYMLINK_FOLLOW, and AT_EMPTY_PATH constants are implemented with appropriate platform handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.