mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 18:53:29 +00:00
feat: Implement Lchown function for changing file ownership (#5161)
* 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
This commit is contained in:
@@ -166,6 +166,19 @@ func Chown(name string, uid, gid int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Lchown changes the numeric uid and gid of the named file.
|
||||
// If the file is a symbolic link, it changes the uid and gid of the link itself.
|
||||
// If there is an error, it will be of type [*PathError].
|
||||
//
|
||||
// If there is an error, it will be of type *PathError.
|
||||
func Lchown(name string, uid, gid int) error {
|
||||
e := ignoringEINTR(func() error { return syscall.Lchown(name, uid, gid) })
|
||||
if e != nil {
|
||||
return &PathError{Op: "lchown", Path: name, Err: e}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ignoringEINTR makes a function call and repeats it if it returns an
|
||||
// EINTR error. This appears to be required even though we install all
|
||||
// signal handlers with SA_RESTART: see #22838, #38033, #38836, #40846.
|
||||
|
||||
Reference in New Issue
Block a user