ACL_CALC_MASK(3)
๐ ACL_CALC_MASK ๐
okay bestie, so this is a page from the Linux Access Control Lists library manual โ section 3, library functions, the whole vibe. it's called acl_calc_mask and it's literally here to do math for you. no cap. ๐งฎโจ
โจ NAME โจ
acl_calc_mask โ calculate the file group class mask
๐ LIBRARY ๐
Linux Access Control Lists library (libacl, -lacl).
like, that's the library you're linking against, babes. -lacl. put it in your build and go ๐
๐ธ SYNOPSIS ๐ธ
#include <sys/types.h>
#include <sys/acl.h>
int
acl_calc_mask(acl_t *acl_p);
so you include the two headers, and then the function takes a pointer to an acl_t and hands you back an int. that's it. that's the whole signature. ๐
๐ฆ DESCRIPTION ๐ฆ
okay so here's what's actually happening. the acl_calc_mask() function calculates and sets the permissions that go with the ACL_MASK ACL entry of the ACL that acl_p points at. ๐ซถ
and the value it computes for those new permissions? it's the union of the permissions granted by all entries whose tag type is ACL_GROUP, ACL_GROUP_OBJ, or ACL_USER. every single one of them, smooshed together into one mask. iconic behavior honestly.
now, two scenarios, pay attention bestie:
- if the ACL that
acl_prefers to already has anACL_MASKentry, its permissions get overwritten. bye old permissions ๐ - if it doesn't have an
ACL_MASKentry, one gets added. surprise! you have a mask now ๐
and here's the part where it gets a lil spicy: if the ACL that acl_p points at doesn't have enough space for that new ACL entry, then extra working storage may get allocated. and if that working storage can't be grown where it currently lives, then it may get relocated โ the previous working storage is released, and a pointer to the new working storage comes back to you via acl_p. so yeah, your pointer might move. it's giving glow-up relocation ๐งณโจ
also important, and don't skip this:
the order of existing entries in the ACL is undefined after this function runs. undefined!! don't build your whole personality on the order, it's not guaranteed to survive this call. ๐
but good news for your pointers:
- any existing ACL entry descriptors that refer to entries in the ACL continue to refer to those entries. they stay valid, they stay pointing at the right stuff.
- any existing ACL pointers that refer to the ACL referred to by
acl_pcontinue to refer to that ACL. still your ACL. still valid.
so the order is chaotic but the identity is stable. we love a consistent queen ๐
๐ฅ RETURN VALUE ๐ฅ
- it returns the value
0if it's successful ๐ - otherwise it returns the value
-1, and the global variableerrnogets set to indicate the error ๐ญ
that's the whole contract. 0 good, -1 check errno.
๐ ERRORS ๐
if any of these conditions happen, acl_calc_mask() returns -1 and sets errno to the corresponding value:
[EINVAL]โ the argumentaclis not a valid pointer to an ACL. bestie. that's not an ACL. ๐ซ[ENOMEM]โ theacl_calc_mask()function is unable to allocate the memory required for anACL_MASKACL entry. out of memory, out of luck ๐
โญ STANDARDS โญ
IEEE Std 1003.1e draft 17 (โPOSIX.1eโ, abandoned)
yeah. abandoned. the standard said "nvm" but we're still here using it, and honestly? main character energy. periodt. ๐
๐ SEE ALSO ๐
go read those too, they're part of the lore ๐โจ
๐ 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 ๐ซก๐
Linux ACL โ dated March 23, 2002. that's the source and the date, bestie, and that's a wrap on ACL_CALC_MASK(3). go forth and mask responsibly ๐โญ๐ฆ
๐ฆ where this page comes from
- alpine 3.22: acl-doc 2.3.2-r1 ยท LGPL-2.1-or-later AND GPL-2.0-or-later
- alpine 3.23: acl-doc 2.3.2-r1 ยท LGPL-2.1-or-later AND GPL-2.0-or-later
- alpine 3.24: acl-doc 2.3.2-r1 ยท LGPL-2.1-or-later AND GPL-2.0-or-later
- 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+
- debian bookworm: libacl1-dev 2.3.1-3
- debian trixie: libacl1-dev 2.3.2-2+b1
- fedora 43: libacl-devel 2.3.2-4.fc43 ยท LGPL-2.1-or-later
- fedora 43: libacl-devel 2.3.2-4.fc43 ยท LGPL-2.1-or-later
- 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.3.2-6.fc44 ยท LGPL-2.1-or-later
- fedora 44: libacl-devel 2.3.2-6.fc44 ยท 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 jammy: libacl1-dev 2.3.1-1
- ubuntu noble: libacl1-dev 2.3.2-1build1
- ubuntu noble: libacl1-dev 2.3.2-1build1.1
- ubuntu resolute: libacl1-dev 2.3.2-2
- ubuntu stonking: libacl1-dev 2.4.0-1
- (C) 2002 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