0

I'm trying to figure out what the mode parameter of setfmode() which is called eventually by chmod() is.

When I print it out and do something like chmod +t test.txt "33700" gets printed out. When I do chmod +w test.txt "33252" gets printed out.

Is there a way to see which specific bits are being set using these numbers?

MarksCode
  • 8,074
  • 15
  • 64
  • 133

1 Answers1

2

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)"

FKEinternet
  • 1,050
  • 1
  • 11
  • 20