EXTATTRCTL(2) System Calls Manual EXTATTRCTL(2)

extattrctlcontrol extended attributes on a UFS1 file system

#include <sys/extattr.h>
#include <ufs/ufs/extattr.h>

int
extattrctl(const char *path, int cmd, const char *filename, int attrnamespace, const char *attrname);

The () system call provides low-level control over extended attributes on a UFS1 file system. It allows enabling, disabling, and managing extended attributes.

Since there was no provision in the UFS1 file system for attributes, they are stored as regular files and directories in the file system under the /.attribute directory. By convention, there are usually two directories directly under it, separating two namespaces: “user” and “system”. Under these, there are named attributes that can be created and managed using extattrctl(8).

This programming interface is currently only used by extattrctl(8), and is not intended for general use.

path
The path to the mount point of the file system.
cmd
The command to execute. Valid commands are:
Enable a specific extended attribute.
Disable a specific extended attribute.
Start extended attribute support on the file system.
Stop extended attribute support on the file system.
attrname
The name of the extended attribute (for relevant commands).
attrnamespace
The attribute namespace, such as EXTATTR_NAMESPACE_USER or EXTATTR_NAMESPACE_SYSTEM.
filename
The path to a backing file for extended attribute storage (if required by the command).

The extattrctl() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

Enable an attribute on a file system:

#include <sys/extattr.h>
#include <ufs/ufs/extattr.h>

if (extattrctl("/home", UFS_EXTATTR_CMD_ENABLE,
    "/.attribute/user/comment",
    EXTATTR_NAMESPACE_USER, "comment") == -1)
	err(EXIT_FAILURE, "extattrctl");

The extattrctl() system call may fail with the following errors:

[]
The calling user does not have permission to access the file specified.
[]
Invalid arguments were provided.
[]
The specified path, attribute, or file does not exist.
[]
The file system does not support extended attributes.
[]
The calling user is not permitted to change extended attributes.

extattr_delete_file(2), extattr_get_file(2), extattr_list_file(2), extattr_set_file(2), extattrctl(8)

The extattrctl() system call was imported from FreeBSD 5.0 in NetBSD 3.0.

March 9, 2025 NetBSD 11.0