Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ write(D2DK) — Motorola System V 88k Release 4 Version 4.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

write(D2DK)  —  

NAME

write − write data to a device

SYNOPSIS

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/uio.h>
#include <sys/cred.h>
int prefixwrite(dev_t dev, uio_t ∗uiop, cred_t ∗crp);

ARGUMENTS

dev Device number. 

uiop Pointer to the uio(D4DK) 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.  The data to be transferred may be of any size or alignment. Only devices which cannot break data transfers into smaller blocks are allowed to refuse a write request on this basis.  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(D3DK) function provides a convenient way to copy data using the uio structure. 

Block drivers that provide a character interface can use physiock(D3DK) to perform the data transfer with the driver’s strategy(D2DK) routine. 

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 asynchronous to the user’s request, losing the ability to return an error with the associated request. 

NOTES

This interface is optional.  The write routine has user context and can sleep. 

RETURN VALUE

The write routine should return 0 for success, or the appropriate error number. 

ERROR RETURN CODES

EAGAINTemporary resource allocation failure; try again later.  Drivers can return this error when resource allocation fails, for example, kmem_alloc(D3DK) or allocb(D3DK). 

EFAULTBad address.  Drivers should return this error whenever a call to copyin(D 3DK) or copyout(D3DK) fails. 

EINTRInterrupted operation.  Drivers can return this error whenever an interruptible operation is interrupted by receipt of an asynchronous signal. 

EINVALInvalid argument.  Drivers can return this error for operations that have invalid parameters specified. 

EIOAn I/O error has occurred.  Drivers can return this error when an input or output request has failed. 

ENXIONo such device or address.  Drivers can return this error when trying to open an invalid minor device, or when trying to perform I/O past the end of a device. 

EPERMPermission denied.  Drivers can return this error when the current process doesn’t have sufficient privilege for the operation attempted. 

SEE ALSO

read(D2DK), strategy(D2DK), drv_priv(D3DK), physiock(D3DK), uiomove(D3DK), uwritec(D3DK), uio(D4DK), uiophysio(D3DK), errnos(D5DK)

REPLACE WITH BLANK PAGE

DDI/DKI

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026