|
DB_MPOOLFILE->open
|
|
#include <db.h>
int
DB_MPOOLFILE->open(DB_MPOOLFILE *mpf,
char *file, u_int32_t flags, int mode, size_t pagesize);
Description
The DB_MPOOLFILE->open function opens a file in the shared memory buffer pool.
The file argument is the name of the file to be opened. If
file is NULL, a private temporary file is created that
cannot be shared with any other process (although it may be shared with
other threads).
The flags and mode arguments specify how files will be opened
and/or created if they do not already exist.
The flags value must be set to 0 or by bitwise inclusively OR'ing together one or
more of the following values:
- DB_CREATE
- Create any underlying files, as necessary. If the files do not already
exist and the DB_CREATE flag is not specified, the call will fail.
- DB_NOMMAP
- Always copy this file into the local cache instead of potentially mapping
it into process memory (see the description of the
DB_ENV->set_mp_mmapsize function for further information).
- DB_ODDFILESIZE
- Attempts to open files which are not a multiple of the page size in
length will fail, by default. If the DB_ODDFILESIZE flag is
set, any partial page at the end of the file will be ignored and the
open will proceed.
- DB_RDONLY
- Open any underlying files for reading only. Any attempt to write the file
using the pool functions will fail, regardless of the actual permissions
of the file.
On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) environments, all files created by
function DB_MPOOLFILE->open are created with mode mode (as described in chmod(2)) and modified by the process' umask value at the time of creation
(see umask(2)). If mode is 0, function DB_MPOOLFILE->open will use a default
mode of readable and writable by both owner and group. On Windows
systems, the mode argument is ignored. The group ownership of created
files is based on the system and directory defaults, and is not further
specified by Berkeley DB.
The pagesize argument is the size, in bytes, of the unit of transfer
between the application and the pool, although it is not necessarily the
unit of transfer between the pool and the source file.
The DB_MPOOLFILE->open function returns a non-zero error value on failure and 0 on success.
Errors
The DB_MPOOLFILE->open function may fail and return a non-zero error for the following conditions:
- EINVAL
- An invalid flag value or parameter was specified.
The file has already been entered into the pool, and the pagesize
value is not the same as when the file was entered into the pool, or the
length of the file is not zero or a multiple of the pagesize.
The DB_RDONLY flag was specified for an in-memory pool.
- ENOMEM
- The maximum number of open files has been reached.
The DB_MPOOLFILE->open function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions.
If a catastrophic error has occurred, the DB_MPOOLFILE->open function may fail and return
DB_RUNRECOVERY, in which case all subsequent Berkeley DB calls will fail
in the same way.
See Also
DB_ENV->set_cachesize,
DB_ENV->set_mp_mmapsize,
DB_ENV->memp_fcreate,
DB_MPOOLFILE->close,
DB_MPOOLFILE->get,
DB_MPOOLFILE->open,
DB_MPOOLFILE->put,
DB_MPOOLFILE->set,
DB_MPOOLFILE->sync,
DB_ENV->memp_register,
DB_MPOOLFILE->set_clear_len,
DB_MPOOLFILE->set_fileid,
DB_MPOOLFILE->set_ftype,
DB_MPOOLFILE->set_lsn_offset,
DB_MPOOLFILE->set_pgcookie,
DB_ENV->memp_stat,
DB_ENV->memp_sync,
and
DB_ENV->memp_trickle.
Copyright Sleepycat Software
|