SCO OpenServer
close(D2oddi)
close --
relinquish access to a device
Synopsis
#include <sys/file.h>
#include <sys/open.h>
void prefixclose(dev_t dev, int flag, int otyp);
Description
The
close( )
entry point routine ends the connection
between the user process
and the previously-opened device
and prepares the device and software
so that they are ready to be opened again.
Arguments
dev-
device number
flag-
flag with which the file was opened.
The value is merely a reference to be used as needed;
it does not control how the file is closed.
The flag is taken from the
f_flag
member
of the file structure.
open(D2oddi)
lists the supported flags.
otyp-
parameter used to determine how many times
a device was opened and for what reasons.
The flags assume that the
open( )
routine may be called many times, but the
close( )
routine is called by the kernel
only on the last close of a device.
See
open(D2oddi)
for a list of supported values.
Return values
None.
Usage
A device may be opened simultaneously
by multiple processes and the
open(D2oddi)
driver routine is called for each open,
but, unless the OTYP_LYR otyp is used,
the device is closed only by the last
close
system call (after all forked processes have been closed).
The kernel calls the driver's
close( )
routine when the last process using the device
issues a
close
call or exits.
Block device close routines
can also be called when the device is being unmounted (see
umount.
A
close( )
routine should use the flag parameters
that are listed on the
open(D2oddi)
manual page when applicable.
The
close( )
routine should make the device available
for later use by performing the following:
-
deallocate buffers from a private buffering scheme
-
unlock resources that were locked in the
open( )
routine
-
flush buffers
-
notify the device of the close operation
Adhere to the following guidelines:
-
If an error occurs during the
close( )
routine, the driver should call the
seterror(D3oddi)
function
or set the
u.u_error
member
of the user
structure directly.
Test u.u_error
before assigning a value;
if an error exists already, do not change the value.
TTY
The
close( )
routine in a TTY driver
should call the
ttclose(D3oddi)
function, then disconnect the link to the terminal
and return to the caller.
Multithreaded TTY drivers call
ttyclose( )
through the
run_ld(D3oddi)
function.
Context and synchronization
Blockable
context.
The driver can block but cannot do operations such as
copyout(D3)
that require access to
the requesting process's address space.
Hardware applicability
All
Version applicability
oddi:
1, 2, 2mp, 3, 3mp, 4, 4mp, 5, 5mp, 6, 6mp
SVR5 DDI compatibility
The
close(D2)
entry point routine provides similar functionality
for DDI drivers,
although note that the syntax is different.
External dependencies
Drivers that contain a
close(D2oddi)
routine must have a c in the function list of the
mdevice(F)
file.
References
open(D2mdi),
open(D2oddi),
open(D2osdi),
open(D2str),
open(S) ,
close(S)
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 5 HDK - June 2005