---
name: "blkdev_get"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/blkdev_get"
---

# blkdev\_get(9)

open a block device

## NAME

blkdev\_get - open a block device

## SYNOPSIS

**int blkdev\_get(struct block\_device \*** *bdev***, fmode\_t** *mode***, void \*** *holder***);**

## ARGUMENTS

*bdev*

block\_device to open

*mode*

FMODE\_\* mask

*holder*

exclusive holder identifier

## DESCRIPTION

Open *bdev* with *mode*. If *mode* includes **FMODE\_EXCL**, *bdev* is open with exclusive access. Specifying **FMODE\_EXCL** with **NULL** *holder* is invalid. Exclusive opens may nest for the same *holder*.

On success, the reference count of *bdev* is unchanged. On failure, *bdev* is put.

## CONTEXT

Might sleep.

## RETURN

0 on success, -errno on failure.

## COPYRIGHT
