Skip to content

feat: Implement Lchown function for changing file ownership#5161

Merged
deadprogram merged 2 commits into
tinygo-org:devfrom
Itxaka:lchown
Jan 10, 2026
Merged

feat: Implement Lchown function for changing file ownership#5161
deadprogram merged 2 commits into
tinygo-org:devfrom
Itxaka:lchown

Conversation

@Itxaka

@Itxaka Itxaka commented Jan 7, 2026

Copy link
Copy Markdown
Contributor
  • Added Lchown function to change the numeric uid and gid of a file or symbolic link.
  • Included error handling to return *PathError for failed operations.
  • Added unit tests for Lchown to verify behavior on different error scenarios.

- Added Lchown function to change the numeric uid and gid of a file or symbolic link.
- Included error handling to return *PathError for failed operations.
- Added unit tests for Lchown to verify behavior on different error scenarios.
@Itxaka

Itxaka commented Jan 7, 2026

Copy link
Copy Markdown
Contributor Author

I think this is ok, but not sure about the libc part. I was mostly guided by the existing chown implementation to provide this one :D

@dgryski dgryski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just need to update the test. I'm not sure why CI is failing with internal/itoa issues.

Comment thread src/os/os_chmod_test.go Outdated
"runtime"
"testing"

"github.com/tinygo-org/tinygo/src/os"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The os package is already impred with . above. Remove.

Comment thread src/os/os_chmod_test.go Outdated
f := newFile("TestLchown", t)
defer Remove(f.Name())
defer f.Close()
link := filepath.Join(os.TempDir(), "TestLchownLink")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

os.TempDir() -> TempDir()

Comment thread src/os/os_chmod_test.go Outdated
defer Remove(f.Name())
defer f.Close()
link := filepath.Join(os.TempDir(), "TestLchownLink")
_ = os.Symlink(f.Name(), link)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

os.Symlink(...) -> Symlink(...)

@Itxaka Itxaka requested a review from dgryski January 9, 2026 17:57
@Itxaka

Itxaka commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

Fixed, thanks for the heads up. Cant believe I blatantly copied the test case from the chown and manage to broke it 😆

@dgryski dgryski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@deadprogram deadprogram changed the base branch from release to dev January 10, 2026 08:29
@deadprogram

Copy link
Copy Markdown
Member

@Itxaka please note that I changed the merge target to dev as mentioned here:

https://tinygo.org/docs/guides/contributing/#how-to-use-our-github-repository

Now squash/merging. Thanks @Itxaka for the addition and to @dgryski for review.

@deadprogram deadprogram merged commit ca36fba into tinygo-org:dev Jan 10, 2026
19 checks passed
deadprogram pushed a commit that referenced this pull request Mar 23, 2026
* feat: Implement Lchown function for changing file ownership

- Added Lchown function to change the numeric uid and gid of a file or symbolic link.
- Included error handling to return *PathError for failed operations.
- Added unit tests for Lchown to verify behavior on different error scenarios.

* fix: fix chmod tests
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.

3 participants