ACL_GET_FILE(3)
π ACL_GET_FILE β get an ACL by filename
okay bestie, sit DOWN, because we're doing file ACLs and this one is genuinely so useful. this is the Library Functions Manual page for acl_get_file(3), and yes it lives in the Linux Access Control Lists library.
πΈ LIBRARY
Linux Access Control Lists library (libacl, -lacl). link it and you're golden π«Ά
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <sys/acl.h>
acl_t
acl_get_file(const char *path_p, acl_type_t type);
acl_t
acl_get_file_at(int dirfd, const char *path_p, int at_flags,
acl_type_t type);
π¦ DESCRIPTION
so the whole vibe of acl_get_file() is: you give it a path, it gives you the ACL. specifically it retrieves the access ACL associated with a file or directory, OR the default ACL associated with a directory. the pathname for the file or directory goes in the argument path_p. and here's the cute part β if path_p is a symbolic link, acl_get_file() does not care about the link itself, it returns info about the file or directory the link refers to. dereference slay π
the ACL gets placed into working storage and acl_get_file() hands you a pointer to that storage.
heads up bestie: to read an ACL from an object, a process must have read access to the object's attributes. no read access, no ACL, periodt.
the value of the argument type is what decides whether you get the access ACL or the default ACL for path_p:
- if
typeisACL_TYPE_ACCESSβ you get the access ACL ofpath_p. - if
typeisACL_TYPE_DEFAULTβ you get the default ACL ofpath_p. - if
typeisACL_TYPE_DEFAULTand there is no default ACL associated with the directorypath_pβ you get an ACL containing zero ACL entries. yes, an empty one. it's giving "nothing to see here" π - if
typespecifies a type of ACL that cannot be associated withpath_pβ the function fails. no cap.
also, this function may cause memory to be allocated. so when you're done with the new ACL, be a good citizen and free any releasable memory by calling acl_free(3) with the (void*)acl_t returned by acl_get_file() as an argument. clean up after yourself, it's the main character thing to do β¨
π acl_get_file_at()
acl_get_file_at() operates in exactly the same way as acl_get_file(), except for the differences described right here. think of it as the glow-up version with extra control:
- if the pathname given in
path_pis relative, then it is interpreted relative to the directory referred to by the file descriptordirfdβ rather than relative to the current working directory of the calling process, likeacl_get_file()does. lowkey a whole different starting point πΊοΈ - if
path_pis relative anddirfdis the special valueAT_FDCWD, thenpath_pis interpreted relative to the current working directory of the calling process (likeacl_get_file()). so back to normal behavior, iconic. - if
path_pis absolute, thendirfdis ignored. sorrydirfd, you're not the moment.
the at_flags argument can either be 0, or include one or more of the following flags ORed together:
AT_EMPTY_PATHβ ifpath_pis an empty string, operate on the file referred to bydirfd(which may have been obtained using theopen(2)O_PATHflag). in this case,dirfdcan refer to any type of file, not just a directory, and the behavior ofacl_get_file_at()is similar to that ofacl_get_fd(). versatile queen πAT_SYMLINK_NOFOLLOWβ ifpath_prefers to a symbolic link, do not dereference it: instead, fail the operation and set the global variableerrnotoENOTSUP. this indicates that the symbolic link cannot have ACLs. links don't have ACLs, bestie, it's just the rules π
π₯ RETURN VALUE
on success, the acl_get_file() and acl_get_file_at() functions return a pointer to the working storage. yay! π
on error, a value of (acl_t)NULL is returned, and errno is set appropriately. that's the sad path, and you will be checking it.
π ERRORS
if any of the following conditions occur, the acl_get_file() and acl_get_file_at() functions return a value of (acl_t)NULL 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.
Argument type specifies a type of ACL that cannot be associated with path_p.
[EBADF]β The argumentpath_pis relative but the argumentdirfdis neitherAT_FDCWDnor a valid file descriptor.[EINVAL]β The argumenttypeis notACL_TYPE_ACCESSorACL_TYPE_DEFAULT.
An invalid flag was specified in the at_flags argument.
[ENAMETOOLONG]β The length of the argumentpath_pis too long.[ENOENT]β The named object does not exist or the argumentpath_ppoints to an empty string.[ENOMEM]β The ACL working storage requires more memory than is allowed by the hardware or system-imposed memory management constraints.[ENOTDIR]β A component of the path prefix is not a directory.
The argument path_p is relative and the argument dirfd is a file descriptor referring to a file other than a directory.
[ENOTSUP]β The argumentat_flagsincludes the flagAT_SYMLINK_NOFOLLOWandpath_pis a symbolic link.
The file system on which the file identified by path_p is located does not support ACLs, or ACLs are disabled.
not all of these are your fault, bestie. some file systems just don't support ACLs and there's nothing you can do about it. vibe check failed, move on π
π STANDARDS
IEEE Std 1003.1e draft 17 (βPOSIX.1eβ, abandoned). rip to that draft, it really tried π
Function acl_get_file_at() is a Linux specific extension. iykyk.
β SEE ALSO
acl_free(3), acl_get_entry(3), acl_get_fd(3), acl_set_file(3), acl(5)
π«Ά AUTHOR
Derived from the FreeBSD manual pages written by Robert N M Watson <rwatson@FreeBSD.org>, and adapted for Linux by Andreas Gruenbacher <andreas.gruenbacher@gmail.com>. thank you for your service, legends π
and that's the whole page, bestie! this one came from the Linux ACL crew and it's dated June 5, 2026. go get those ACLs, slay, and remember to acl_free(3) when you're done πβ¨π¦
π¦ where this page comes from
- arch rolling: acl 2.4.0-1 Β· LGPL-2.1-or-later AND GPL-2.0-or-later
- centos-stream 10: libacl-devel 2.4.0-2.el10 Β· LGPL-2.1-or-later
- centos-stream 9: libacl-devel 2.4.0-2.el9 Β· LGPLv2+
- centos-stream 9: libacl-devel 2.4.0-2.el9 Β· LGPLv2+
- fedora 43: libacl-devel 2.4.0-1.fc43 Β· LGPL-2.1-or-later
- fedora 43: libacl-devel 2.4.0-1.fc43 Β· LGPL-2.1-or-later
- fedora 44: libacl-devel 2.4.0-1.fc44 Β· LGPL-2.1-or-later
- fedora 44: libacl-devel 2.4.0-1.fc44 Β· LGPL-2.1-or-later
- nixpkgs unstable: acl 2.4.0
- opensuse-leap 16.0: libacl-devel 2.4.0-160000.1.1 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: libacl-devel 2.4.0-160000.1.1 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: libacl-devel 2.4.0-160000.1.1 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: libacl-devel 2.4.0-160000.1.1 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- ubuntu stonking: libacl1-dev 2.4.0-1
- (C) 2002-2026 Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms