SVR5
write(D2)
write --
write data to a character device
Synopsis (Not in current DDI version)
#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's
write( )
entry point routine is called
during the
write
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 from those listed on the
errnos(D5)
manual page.
Usage
This entry point is optional,
and is valid only for non-STREAMS character device drivers.
If this entry point is not provided,
all write I/O requests fail
with the ENODEV error number.
This entry point is called
only when the device is open.
The
write( )
routine is a named entry point
and must be defined as a global symbol.
The pointer to the user credentials, crp, is available
so the driver can check for required privileges, if any, using the
drv_priv(D3)
function.
The
uio(D4)
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.
Context and synchronization
User
context.
The driver can block and can do operations such as
copyout(D3)
that require access to
the requesting process's user-level address space.
The
write( )
operation is intended to be synchronous
from the caller's perspective.
Minimally, the driver's
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.
Hardware applicability
All
Version applicability
ddi:
1, 2, 3, 4, 5, 5mp, 6, 6mp, 7, 7mp, 7.1, 7.1mp
External dependencies
Named entry point routines must be declared
in the driver's
Master(DSP/4dsp)
file.
The declaration for this entry point is
$entry write.
Differences between versions
Starting with DDI version 8, the
write(D2)
entry point routine is replaced by the
biostart(D2)
entry point.
References
drv_priv(D3),
errnos(D5),
physiock(D3),
read(D2),
strategy(D2),
uio(D4)
uiomove(D3),
uwritec(D3)
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005