xref: /illumos-gate/usr/src/man/man9f/getrbuf.9f (revision 406fc5100dac8d225a315a6def6be8d628f34e24)
te
Copyright 2015 Nexenta Systems, Inc. All rights reserved.
Copyright 1989 AT&T
Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
GETRBUF 9F "Jan 27, 2015"
NAME
getrbuf - get a raw buffer header
SYNOPSIS

#include <sys/buf.h>
#include <sys/kmem.h>
#include <sys/ddi.h>



struct buf *getrbuf(int sleepflag);
INTERFACE LEVEL

Architecture independent level 1 (DDI/DKI).

PARAMETERS
sleepflag

Indicates whether driver should sleep for free space.

DESCRIPTION

The getrbuf() function allocates the space for a buffer header to the caller. It is used in cases where a block driver is performing raw (character interface) I/O and needs to set up a buffer header that is not associated with the buffer cache.

The getrbuf() function calls kmem_alloc(9F) to perform the memory allocation. kmem_alloc() requires the information included in the sleepflag argument. If sleepflag is set to KM_SLEEP, the driver may sleep until the space is freed up. If sleepflag is set to KM_NOSLEEP, the driver will not sleep. In either case, a pointer to the allocated space is returned or NULL to indicate that no space was available.

RETURN VALUES

The getrbuf() function returns a pointer to the allocated buffer header, or NULL if no space is available.

CONTEXT

The getrbuf() function can be called from user, interrupt, or kernel context. (Drivers must not allow getrbuf() to sleep if called from an interrupt routine.)

SEE ALSO

bioinit(9F), freerbuf(9F), kmem_alloc(9F), kmem_free(9F)

Writing Device Drivers