---
name: "BUF_LOCK"
section: "9"
platform: "linux"
package: "freebsd-manpages"
version: "6.0-5"
release: "Debian 4.0 (Etch)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/BUF_LOCK"
---

# BUF\_LOCK(9)

locks a buffer

## NAME

**BUF\_LOCK** – locks a buffer

## SYNOPSIS

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

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

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

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

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

*int*\

**BUF\_LOCK**(*struct buf \*bp*, *int locktype*);

## DESCRIPTION

The **BUF\_LOCK**() function locks the given buffer. If the lock is already held this call will block until it can acquire the lock unless LK\_NOWAIT is set.

Its arguments are:

- *bp*

  The buffer to lock.

- *locktype*

  Flags controlling the type of lock. See [lockmgr(9)](/lockmgr/9.md) for details.

## RETURN VALUES

A value of 0 is returned upon success. See [lockmgr(9)](/lockmgr/9.md) for information on non-zero return values.

## SEE ALSO

[buf(9)](/buf/9.md), [BUF\_TIMELOCK(9)](/BUF_TIMELOCK/9.md), [BUF\_UNLOCK(9)](/BUF_UNLOCK/9.md), [lockmgr(9)](/lockmgr/9.md)

## AUTHORS

This manual page was written by Chad David ⟨davidc@acns.ab.ca⟩.
