---
name: "extattr"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/extattr/3"
---

# extattr(3)

convert an extended attribute namespace identifier to a string and vice versa

## NAME

**extattr\_namespace\_to\_string**, **extattr\_string\_to\_namespace** – convert an extended attribute namespace identifier to a string and vice versa

## LIBRARY

System Utilities Library (libutil, -lutil)

## SYNOPSIS

**#include \<sys/extattr.h\>**

**#include \<libutil.h\>**

*int*\

**extattr\_namespace\_to\_string**(*int attrnamespace*, *char \*\*string*);

*int*\

**extattr\_string\_to\_namespace**(*const char \*string*, *int \*attrnamespace*);

## DESCRIPTION

The **extattr\_namespace\_to\_string**() function converts a VFS extended attribute identifier to a human-readable string; the **extattr\_string\_to\_namespace**() function undoes the aforementioned operation, and converts a human-readable string representing a namespace to a namespace identifier. Although a file system may implement arbitrary namespaces, these functions only support the EXTATTR\_NAMESPACE\_USER (“user”) and EXTATTR\_NAMESPACE\_SYSTEM (“system”) namespaces, which are defined in [extattr(9)](/extattr/9.md).

These functions are meant to be used in error reporting and other interactive tasks. For example, instead of printing the integer identifying an extended attribute in an error message, a program might use **extattr\_namespace\_to\_string**() to obtain a human-readable representation. Likewise, instead of requiring a user to enter the integer representing a namespace, an interactive program might ask for a name and use **extattr\_string\_to\_namespace**() to get the desired identifier.

## RETURN VALUES

If any of the calls are unsuccessful, the value -1 is returned and the global variable *errno* is set to indicate the error.

## ERRORS

- \[EINVAL\]

  The requested namespace could not be identified.

## SEE ALSO

[extattr(2)](/extattr/2.md), [getextattr(8)](/getextattr/8.md), [setextattr(8)](/setextattr/8.md), [extattr(9)](/extattr/9.md)

## HISTORY

Extended attribute support was developed as part of the TrustedBSD Project, and introduced in FreeBSD 5.0. It was developed to support security extensions requiring additional labels to be associated with each file or directory.
