acl: define Go type alias for acl_perm_t

Define exported type alias for C.acl_perm_t and accept that for UpdatePerm. This makes representing its function signature significantly less cumbersome.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
Ophestra 2024-09-21 22:25:03 +09:00
parent 2763ec730e
commit 11832a9379
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q

View File

@ -25,7 +25,9 @@ const (
Other = C.ACL_OTHER
)
func UpdatePerm(path string, uid int, perms ...C.acl_perm_t) error {
type Perm C.acl_perm_t
func UpdatePerm(path string, uid int, perms ...Perm) error {
// read acl from file
a, err := aclGetFile(path, TypeAccess)
if err != nil {
@ -55,7 +57,7 @@ func UpdatePerm(path string, uid int, perms ...C.acl_perm_t) error {
// add target perms
for _, perm := range perms {
if _, err = C.acl_add_perm(p, perm); err != nil {
if _, err = C.acl_add_perm(p, C.acl_perm_t(perm)); err != nil {
return err
}
}