strmode(3bsd)
β¨ strmode β bestie we're turning inode status into a cute lil string π
okay so this one's from the Utility functions from BSD systems collection, a.k.a. libbsd, and you link it with -lbsd. she's a libbsd girlie, not a glibc one, iykyk π«Ά
πΈ SYNOPSIS πΈ
#include <string.h>
(See libbsd(7) for include usage.)
void
strmode(mode_t mode, char *bp);
heads up bestie: peep libbsd(7) for how the include actually goes, it's got lore π
π DESCRIPTION π
so strmode() takes a file mode β that's the type + permission info that lives on an inode, like what stat(2) gives you β and it converts it into a symbolic string, which it stores at the location bp points to. that string is eleven characters long, plus a trailing NUL. no cap, exactly eleven. π
The first character is the inode type, and it's gonna be one of these iconic lil guys:
-β regular filebβ block specialcβ character specialdβ directorylβ symbolic linkpβ fifosβ socketwβ whiteout?β unknown inode type
π¦ the next nine characters (the permission part) π¦
the next nine characters encode three sets of permissions, three characters each:
- the first three = permissions for the owner of the file
- the second three = permissions for the group the file belongs to
- the third three = permissions for the
other, a.k.a. the default set of users
and permission checking is done as specifically as possible, fr fr. if read permission is denied to the owner in that first set, then the owner genuinely cannot read the file. that's true even if the owner is in the file's group and the group perms allow reading, or the other perms allow reading. owner set wins. periodt. π
here's the breakdown of each character in a set:
- first character of the set: an
rmeans the file is readable for that set of users; a dash-means it's not readable π - second character of the set: a
wmeans the file is writable for that set of users; a dash-means it's not writable - third character: it's the first one of the following that applies β¬οΈ
Sβ if the character is part of the owner permissions and the file is not executable (or the directory is not searchable by the owner), and the set-user-id bit is setSβ if the character is part of the group permissions and the file is not executable (or the directory is not searchable by the group), and the set-group-id bit is setTβ if the character is part of the other permissions and the file is not executable (or the directory is not searchable by others), and thesticky(S_ISVTX) bit is setsβ if the character is part of the owner permissions and the file is executable (or the directory is searchable by the owner), and the set-user-id bit is setsβ if the character is part of the group permissions and the file is executable (or the directory is searchable by the group), and the set-group-id bit is settβ if the character is part of the other permissions and the file is executable (or the directory is searchable by others), and thesticky(S_ISVTX) bit is setxβ the file is executable, or the directory is searchable β¨-β none of the above apply, sorry babe
π the last character π
the last character is a plus sign + if there are any alternate or additional access control methods associated with the inode β otherwise it's just a space. that's the whole vibe check. π
π SEE ALSO π
β HISTORY β
strmode() first appeared in 4.4BSD. a true vintage queen, she's been serving since forever π
and that's the whole page bestie!! this lil icon dropped from the Debian crew on July 28, 1994 β yeah she's older than us and still slaying π π«Ά go format some modes, mwah π
π¦ where this page comes from
- alpine 3.22: libbsd-doc 0.12.2-r0 Β· BSD-3-Clause
- alpine 3.23: libbsd-doc 0.12.2-r0 Β· BSD-3-Clause
- alpine 3.24: libbsd-doc 0.12.2-r0 Β· BSD-3-Clause
- arch rolling: libbsd 0.12.2-2 Β· custom
- debian bookworm: libbsd-dev 0.11.7-2
- debian trixie: libbsd-dev 0.12.2-2
- epel 10: libbsd-devel 0.12.2-4.el10_0 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- epel 9: libbsd-devel 0.12.2-1.el9 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 43: libbsd-devel 0.12.2-6.fc43 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 43: libbsd-devel 0.12.2-6.fc43 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 44: libbsd-devel 0.12.2-7.fc44 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 44: libbsd-devel 0.12.2-7.fc44 Β· Beerware AND BSD-2-Clause AND BSD-3-Clause AND ISC AND libutil-David-Nugent AND MIT AND LicenseRef-Fedora-Public-Domain
- nixos 26.05: libbsd 0.12.2
- opensuse-leap 16.0: libbsd-devel 0.11.7-160000.3.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libbsd-devel 0.11.7-160000.3.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libbsd-devel 0.11.7-160000.3.2 Β· BSD-3-Clause
- opensuse-leap 16.0: libbsd-devel 0.11.7-160000.3.2 Β· BSD-3-Clause
- ubuntu noble: libbsd-dev 0.12.1-1build1
- ubuntu noble: libbsd-dev 0.12.1-1build1.1
- ubuntu questing: libbsd-dev 0.12.2-2build1
- ubuntu resolute: libbsd-dev 0.12.2-2build2
- ubuntu stonking: libbsd-dev 0.12.2-3
- Copyright (c) 1990, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms