write(D2) write(D2)
NAME
write - write data to a device
SYNOPSIS
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/uio.h>
#include <sys/cred.h>
#include <sys/ddi.h>
int prefixwrite(dev_t dev, uio_t *uiop, cred_t *crp);
Arguments
dev Device number.
uiop Pointer to the uio(D4) structure that describes
where the data is to be fetched from user space.
crp Pointer to the user credential structure for the I/O
transaction.
DESCRIPTION
The driver write routine is called during the write(2) system
call. The write routine is responsible for transferring data
from the user data area to the device.
Return Values
The write routine should return 0 for success, or the
appropriate error number.
USAGE
This entry point is optional, and is valid for character
device drivers only.
The pointer to the user credentials, crp, is available so the
driver can check to see if the user can write privileged
information, if the driver provides access to any. The uio
structure provides the information necessary to determine how
much data should be transferred. The uiomove(D3) function
provides a convenient way to copy data using the uio
structure.
Block drivers that provide a character interface can use
physiock(D3) to perform the data transfer with the driver's
strategy(D2) routine.
Copyright 1994 Novell, Inc. Page 1
write(D2) write(D2)
Synchronization Constraints
The write routine has user context and can sleep.
The write operation is intended to be synchronous from the
caller's perspective. Minimally, the driver write routine
should not return until the caller's buffer is no longer
needed. For drivers that care about returning errors, the
data should be committed to the device. For others, the data
might only be copied to local staging buffers. Then the data
will be committed to the device asynchronously to the user's
request, losing the ability to return an error with the
associated request.
REFERENCES
drv_priv(D3), errnos(D5), physiock(D3), read(D2),
strategy(D2), uio(D4), uiomove(D3), uwritec(D3)
NOTICES
Portability
All processors
Applicability
ddi: 1, 2, 3, 4, 5, 5mp, 6, 6mp, 7, 7mp
Copyright 1994 Novell, Inc. Page 2