---
name: "af_unlock"
section: "3"
platform: "linux"
package: "atfs-dev"
version: "1.4pl6-15+b1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/af_lock"
---

# af\_unlock(3)

mechanism for reserving update rights in AtFS

Part of [af\_lock(3)](/af_lock/3.md).

## NAME

af\_lock, af\_unlock, af\_testlock - mechanism for reserving update rights in AtFS

## SYNOPSIS

\#include \<atfs.h\>

Af\_user \*af\_lock (Af\_key \*aso, Af\_user \*locker)

Af\_user \*af\_unlock (Af\_key \*aso)

Af\_user \*af\_testlock (Af\_key \*aso)

## DESCRIPTION

This manual page describes the interface to the AtFS locking mechanism. Locks are used to avoid conflicting updates to one object history. After a user has reserved the update rights, no other user may add new versions to the reserved history. Reserving the update rights happens by locking the *most recent* *version* of the history.  As AtFS allows adding new versions to each generation in a history, each generation may be locked separately. Reserving update rights for old generations (with generation numbers smaller than the newest generation) are performed by locking the most recent version of the corresponding generation. Removing an ASO (af\_rm - manual page [af\_files(3)](/af_files/3.md)) and changing an ASO's version number (af\_svnum - manual page [af\_version(3)](/af_version/3.md)) also requires a lock on the corresponding ASO.

*af\_lock* reserves the update permission for the user identified by *locker*. On successful completion, a buffer identical to locker is returned, a NULL pointer otherwise.

*af\_unlock* cancels a formerly established reservation of update rights. Only the owner or the locker of an ASO (identified by the Af\_user structure that was given to the corresponding call of af\_lock) are allowed to do this. On successful completion, af\_unlock returns a buffer containing the identification of the former locker. This may be empty, if the ASO was not locked. Upon error, a NULL pointer is returned.

*af\_testlock* returns a buffer containing an identification of the current locker of the specified ASO. It returns an empty buffer, if no lock is set.

## SEE ALSO

[af\_version(3)](/af_version/3.md), [af\_files(3)](/af_files/3.md)

## DIAGNOSTICS

af\_lock and af\_unlock return -1 on error and *af\_errno* is set to indicate the error number.
