strtofflags(3)

strtofflags3

Convert between file flag bits and their string names

Usage

#include <unistd.h>

char *

fflagstostr(u_long flags);

int

strtofflags(char **stringp, u_long *setp, u_long *clrp);

Library

Standard C Library (libc, -lc)

Overview

The fflagstostr() function returns a comma separated string of the file flags represented by flags. If no flags are set a zero length string is returned.

If memory cannot be allocated for the return value, fflagstostr() returns NULL.

The value returned from fflagstostr() is obtained from malloc() and should be returned to the system with free() when the program is done with it.

The strtofflags() function takes a string of file flags, as described in chflags(1), parses it, and returns the 'set' flags and 'clear' flags such as would be given as arguments to chflags(2). On success strtofflags() returns 0, otherwise it returns non-zero and stringp is left pointing to the offending token.

Errors

The fflagstostr() function may fail and set errno for any of the errors specified for the library routine malloc(3).

Releases

69 releases since FreeBSD 4.1-RELEASE; the text changed 36 times.

  1. 4.1–4.2
  2. 4.3–4.4
  3. 4.5–4.11
  4. 5.0–6.3
  5. 6.4
  6. 7.0
  7. 7.1
  8. 7.2
  9. 7.3
  10. 7.4
  11. 8.0
  12. 8.1
  13. 8.2
  14. 8.3
  15. 8.4
  16. 9.0
  17. 9.1
  18. 9.2
  19. 9.3
  20. 10.0
  21. 10.1
  22. 10.2
  23. 10.3
  24. 10.4
  25. 11.0
  26. 11.1
  27. 11.2
  28. 11.3
  29. 11.4
  30. 12.0
  31. 12.1
  32. 12.2
  33. 12.3
  34. 12.4
  35. 13.0–13.2
  36. 13.3–14.5
  37. 15.0–16.0

History

The fflagstostr() and strtofflags() functions first appeared in FreeBSD 4.0.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.