---
name: "removexattr"
section: "2"
platform: "macos"
package: "xnu"
version: "12377.121.6"
release: "macOS 26.5"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/removexattr"
---

# removexattr(2)

remove an extended attribute value

## NAME

**removexattr,** **fremovexattr** – remove an extended attribute value

## SYNOPSIS

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

*int*\

**removexattr**(*const char \*path*, *const char \*name*, *int options*);

*int*\

**fremovexattr**(*int fd*, *const char \*name*, *int options*);

## DESCRIPTION

Extended attributes extend the basic attributes associated with files and directories in the file system.  They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

**removexattr**() deletes the extended attribute *name* associated with *path*.

An extended attribute's *name* is a simple NULL-terminated UTF-8 string. *Options* is a bit mask specifying various options:

- XATTR\_NOFOLLOW

  do not follow symbolic links.  Normally, **removexattr**() acts on the target of *path* if it is a symbolic link.  With this option, **removexattr**() will act on the link itself.

- XATTR\_NOFOLLOW\_ANY

  do not follow any symbolic links encountered during pathname resolution. An error is returned if a symlink is encountered before the last component of path.

- XATTR\_RESOLVE\_BENEATH

  If *path* does not reside in the hierarchy beneath the starting directory, an error is returned.

- XATTR\_SHOWCOMPRESSION

  **removexattr**() and  **fremovexattr**() will remove HFS Plus Compression extended attribute *name* (if present) for the file referred to by *path* or *fd*.

**fremovexattr**() is identical to **removexattr**(), except that it removes an extended attribute from an open file referenced by file descriptor *fd*.

## RETURN VALUES

On success, 0 is returned.  On failure, -1 is returned and the global variable *errno* is set as follows.

## ERRORS

- \[ENOATTR\]

  The specified extended attribute does not exist.

- \[ENOTSUP\]

  The file system does not support extended attributes or has the feature disabled.

- \[EROFS\]

  The file system is mounted read-only.

- \[EPERM\]

  This type of object does not support extended attributes.

- \[EINVAL\]

  *name* or *options* is invalid. *name* must be valid UTF-8 *options* must make sense.

- \[EINVAL\]

  XATTR\_NOFOLLOW, XATTR\_NOFOLLOW\_ANY or XATTR\_RESOLVE\_BENEATH option was passed in **fremovexattr**().

- \[ENOTDIR\]

  A component of the *path*, *'s* prefix is not a directory.

- \[ENAMETOOLONG\]

  *Name* exceeded XATTR\_MAXNAMELEN UTF-8 bytes, or a component of *path* exceeded NAME\_MAX characters, or the entire *path* exceeded PATH\_MAX characters.

- \[EACCES\]

  Search permission is denied for a component *path* or permission to remove the attribute is denied.

- \[ELOOP\]

  Too many symbolic links were encountered in *path*.

- \[ELOOP\]

  If XATTR\_NOFOLLOW\_ANY option was passed and a symbolic link was encountered in translating the pathname.

- \[ENOTCAPABLE\]

  If XATTR\_RESOLVE\_BENEATH was passed and *path* does not reside in the directory hierarchy beneath the starting directory.

- \[EFAULT\]

  *path* or *name* points to an invalid address.

- \[EIO\]

  An I/O error occurred while reading from or writing to the file system.

## SEE ALSO

[getxattr(2)](/getxattr/2.md), [listxattr(2)](/listxattr/2.md), [setxattr(2)](/setxattr/2.md)

## HISTORY

**removexattr**() and **fremovexattr**() first appeared in Mac OS X 10.4.
