Refer to the FreeBSD manual page at https://www.freebsd.org/doc/handbook/permissions.html for a full description of the permission bits. Note that the illustrations of permission bits are in octal format.
Search engines are your friends - I searched for "FreeBSD permission bits" and instantly found the above link as the first returned result.
From chat:
"I'm trying to find out if the user is setting the sticky bit, so in setfmode() I think I'll bitwise AND the mode variable with the sticky bit constant, then check if that equals the sticky bit constant"
The sticky bit is octal 1000
- see the FreeBSD chmod
man page
To write numbers in octal in C, precede the value with a 0
, so assuming your mode value is in a variable named mode
, do (mode & 01000)
. If that value is zero, the sticky bit is not set, if it is non-zero (i.e., 01000
), the sticky bit is set.
Mark: "Ok my check seems to be working -
if ((mode & S_ISTXT) == S_ISTXT)
"