home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Press 1997 July
/
Sezamfile97_1.iso
/
msdos
/
c
/
cbase11.a03
/
CBASE11.ZIP
/
MAN
/
BLKIO.MAN
next >
Wrap
Text File
|
1993-01-01
|
6KB
|
175 lines
NAME
lockb - block file record locking
SYNOPSIS
#include <blkio.h>
int lockb(bp, ltype, start, len)
BLKFILE *bp;
int ltype;
bpos_t start;
bpos_t len;
DESCRIPTION
The lockb function will allow segments of a block file to be
locked. bp is the BLKFILE pointer for the file to be locked.
ltype indicates the target status of the lock. The lock types
available are:
B_UNLCK unlock block file segment
B_RDLCK lock block file segment for reading
B_WRLCK lock block file segment for reading and writing
B_RDLKW lock block file segment for reading (wait)
B_WRLKW lock block file segment for reading and writing (wait)
For the lock types which wait, lockb will not return until the
lock is available. For the lock types which do not wait, if the
lock is unavailable because of a lock held by another process a
value of -1 is returned and errno set to EAGAIN.
start is the first block to lock. len is the number of
contiguous blocks including and following block start to be
locked or unlocked. A lock may be set to extend to the end of
the file by setting len to zero.
The buffers are flushed before unlocking.
lockb will fail if one or more of the following is true:
[EAGAIN] ltype is B_RDLCK and the file segment to be locked
is already write locked by another process, or
ltype is B_WRLCK and the file segment to be locked
is already read or write locked by another
process.
[EINVAL] bp is is not a valid BLKFILE pointer.
[EINVAL] ltype is not one of the valid lock types.
[BENOPEN] bp is not open.
[BENOPEN] ltype is B_RDLCK or B_RDLKW and bp is not opened
for reading or ltype is B_WRLCK or B_WRLKW and bp
is not open for writing.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned, and errno set to indicate the error.
NAME
bsetbuf - assign buffering to a block file
SYNOPSIS
#include <blkio.h>
int bsetbuf(bp, buf)
BLKFILE *bp;
void *buf;
DESCRIPTION
The bsetbuf function causes the storage area pointed to by buf to
be used by the block file associated with BLKFILE pointer bp
instead of an automatically allocated buffer area. If buf is the
NULL pointer, bp will be completely unbuffered. Otherwise, it
must point to a storage area of size no less than
header size + block size * buffer count
bsetbuf may be called at any time after opening the block file,
before and after it is read or written; the buffers are flushed
before installing the new buffer area.
bsetbuf will fail if one or more of the following is true:
[EINVAL] bp is not a valid BLKFILE pointer.
[BENBUF] bp is unbuffered and buf is not the NULL
pointer.
[BENOPEN] bp is not open.
SEE ALSO
bopen, bsetvbuf.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned, and errno set to indicate the error.
NOTES
A common source of error is allocating buffer space as an
automatic variable in a code block, and then failing to close the
block file in the same block.
NAME
bsetvbuf - assign buffering to a block file
SYNOPSIS
#include <blkio.h>
int bsetvbuf(bp, buf, blksize, bufcnt)
BLKFILE *bp;
void *buf;
size_t blksize;
size_t bufcnt;
DESCRIPTION
The bsetvbuf function causes the block size and buffer block
count of the block file associated with BLKFILE pointer bp to be
changed to bufcnt and blksize, with the same effects as if the
file had been opened with these values. If bufcnt has a value of
zero, the file will be completely unbuffered. If buf is not the
NULL pointer, the storage area it points to will be used instead
of one automatically allocated for buffering. In this case, buf
must point to a storage area of size no less than
header size + block size * buffer count
bsetvbuf may be called at any time after opening the block file,
before and after it is read or written.
bsetvbuf will fail if one or more of the following is true:
[EINVAL] bp is not a valid BLKFILE pointer.
[EINVAL] blksize is less than 1.
[ENOMEM] Enough memory is not available for the
calling process to allocate.
[BENOPEN] bp is not open.
SEE ALSO
bopen, bsetbuf.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned, and errno set to indicate the error.
NOTES
A common source of error is allocating buffer space as an
automatic variable in a code block, and then failing to close the
block file in the same block.
NAME
bsync - synchronize a block file
SYNOPSIS
#include <blkio.h>
int bsync(bp)
BLKFILE *bp;
DESCRIPTION
The bsync function causes the block file associated with BLKFILE
pointer bp to be synchronized with its buffers; any buffered data
which has been written to the buffers is written to the file.
The header, if it has been modified, is written out last. The
block file remains open and the buffers retain their contents.
If bp is open read-only or is not buffered, there will be no data
to synchronize and bsync will return a value of zero immediately.
bsync will fail if one or more of the following is true:
[EINVAL] bp is not a valid BLKFILE pointer.
[BENOPEN] bp is not open.
SEE ALSO
bexit, bflush, bputb.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned, and errno set to indicate the error.