---
name: "acl_set_file"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/acl_set"
---

# acl\_set\_file(3)

set an ACL for a file

Part of [acl\_set(3)](/acl_set/3.md).

## NAME

**acl\_set\_fd**, **acl\_set\_fd\_np**, **acl\_set\_file**, **acl\_set\_link\_np** – set an ACL for a file

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<sys/types.h\>**

**#include \<sys/acl.h\>**

*int*\

**acl\_set\_fd**(*int fd*, *acl\_t acl*);

*int*\

**acl\_set\_fd\_np**(*int fd*, *acl\_t acl*, *acl\_type\_t type*);

*int*\

**acl\_set\_file**(*const char \*path\_p*, *acl\_type\_t type*, *acl\_t acl*);

*int*\

**acl\_set\_link\_np**(*const char \*path\_p*, *acl\_type\_t type*, *acl\_t acl*);

## DESCRIPTION

The **acl\_set\_fd**(), **acl\_set\_fd\_np**(), **acl\_set\_file**(), and **acl\_set\_link\_np**() each associate an ACL with an object referred to by *fd* or *path\_p*. The **acl\_set\_fd\_np**() and **acl\_set\_link\_np**() functions are not POSIX.1e calls. The **acl\_set\_fd**() function allows only the setting of ACLs of type ACL\_TYPE\_ACCESS where as **acl\_set\_fd\_np**() allows the setting of ACLs of any type. The **acl\_set\_link\_np**() function acts on a symlink rather than its target, if the target of the path is a symlink.

Valid values for the *type* argument are:

| |
| --- |
| ACL\_TYPE\_ACCESS POSIX.1e access ACL |
| ACL\_TYPE\_DEFAULT POSIX.1e default ACL |
| ACL\_TYPE\_NFS4 NFSv4 ACL |

Trying to set ACL\_TYPE\_NFS4 with *acl* branded as POSIX.1e, or ACL\_TYPE\_ACCESS or ACL\_TYPE\_DEFAULT with ACL branded as NFSv4, will result in error.

## IMPLEMENTATION NOTES

FreeBSD's support for POSIX.1e interfaces and features is still under development at this time.

## RETURN VALUES

The **acl\_set\_fd()** function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

## ERRORS

If any of the following conditions occur, these functions shall return -1 and set *errno* to the corresponding value:

- \[EACCES\]

  Search permission is denied for a component of the path prefix, or the object exists and the process does not have appropriate access rights.

- \[EBADF\]

  The *fd* argument is not a valid file descriptor.

- \[EINVAL\]

  Argument *acl* does not point to a valid ACL for this object, or the ACL type specified in *type* is invalid for this object, or there is branding mismatch.

- \[ENAMETOOLONG\]

  A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters.

- \[ENOENT\]

  The named object does not exist, or the *path\_p* argument points to an empty string.

- \[ENOMEM\]

  Insufficient memory available to fulfill request.

- \[ENOSPC\]

  The directory or file system that would contain the new ACL cannot be extended, or the file system is out of file allocation resources.

- \[EOPNOTSUPP\]

  The file system does not support ACL retrieval.

- \[EROFS\]

  This function requires modification of a file system which is currently read-only.

## SEE ALSO

[acl(3)](/acl/3.md), [acl\_delete(3)](/acl_delete/3.md), [acl\_get(3)](/acl_get/3.md), [acl\_get\_brand\_np(3)](/acl_get_brand_np/3.md), [acl\_valid(3)](/acl_valid/3.md), [posix1e(3)](/posix1e/3.md)

## STANDARDS

POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion of the draft continues on the cross-platform POSIX.1e implementation mailing list. To join this list, see the FreeBSD POSIX.1e implementation page for more information.

## HISTORY

POSIX.1e support was introduced in FreeBSD 4.0, and development continues.

## AUTHORS

Robert N M Watson
