80 lines
2.3 KiB
Plaintext
80 lines
2.3 KiB
Plaintext
.if n .pH ddi.rm/d2/gen/write @(#)write 43.9 of 11/25/92
|
|
.\" Copyright 1992, 1991 UNIX System Laboratories, Inc.
|
|
.TH write D2
|
|
.IX "\f4write\fP(D2)"
|
|
.SH NAME
|
|
\f4write\fP \- write data to a device
|
|
.SH SYNOPSIS
|
|
.nf
|
|
.na
|
|
.ft 4
|
|
#include <sys/types.h>
|
|
#include <sys/errno.h>
|
|
#include <sys/uio.h>
|
|
#include <sys/cred.h>
|
|
#include <sys/ddi.h>
|
|
.sp 0.4
|
|
int \f2prefix\fPwrite(dev_t \f2dev\fP, uio_t *\f2uiop\fP, cred_t *\f2crp\fP);
|
|
.ft 1
|
|
.ad
|
|
.fi
|
|
.SS Arguments
|
|
.RS 0
|
|
.TP 10
|
|
\f2dev\fP
|
|
Device number.
|
|
.TP
|
|
\f2uiop\fP
|
|
Pointer to the \f4uio\fP(D4) structure that describes where the data
|
|
is to be fetched from user space.
|
|
.TP
|
|
\f2crp\fP
|
|
Pointer to the user credential structure for the I/O
|
|
transaction.
|
|
.RE
|
|
.SH DESCRIPTION
|
|
The driver \f4write\fP routine is called
|
|
during the \f4write\fP(2) system call.
|
|
The \f4write\fP routine is responsible for transferring data from
|
|
the user data area to the device.
|
|
.SS "Return Values"
|
|
The \f4write\fP routine should return 0 for success,
|
|
or the appropriate error number.
|
|
.SH USAGE
|
|
This entry point is optional,
|
|
and is valid for character device drivers only.
|
|
.P
|
|
The pointer to the user credentials, \f2crp\fP, is available
|
|
so the driver can check to see if the user can write privileged
|
|
information, if the driver provides access to any.
|
|
The \f4uio\fP structure provides the information necessary to determine
|
|
how much data should be transferred.
|
|
The \f4uiomove\fP(D3) function provides
|
|
a convenient way to copy data using the \f4uio\fP structure.
|
|
.P
|
|
Block drivers that provide a character interface can use \f4physiock\fP(D3) to
|
|
perform the data transfer with the driver's \f4strategy\fP(D2) routine.
|
|
.SS "Synchronization Constraints"
|
|
The \f4write\fP routine has user context and can sleep.
|
|
.P
|
|
The write operation is intended to be synchronous from the caller's perspective.
|
|
Minimally, the driver \f4write\fP 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.
|
|
.SH REFERENCES
|
|
.na
|
|
\f4drv_priv\fP(D3),
|
|
\f4errnos\fP(D5),
|
|
\f4physiock\fP(D3),
|
|
\f4read\fP(D2),
|
|
\f4strategy\fP(D2),
|
|
\f4uio\fP(D4),
|
|
\f4uiomove\fP(D3),
|
|
\f4uwritec\fP(D3)
|
|
.ad
|