IDZEBRA
2.2.7
|
#include <stdio.h>
#include <yaz/yconfig.h>
#include <idzebra/version.h>
#include <idzebra/util.h>
#include <sys/types.h>
#include <sys/param.h>
#include <zebra-lock.h>
Go to the source code of this file.
Data Structures | |
struct | mf_dir |
struct | part_file |
struct | meta_file |
struct | MFile_area_struct |
Macros | |
#define | mfile_seek lseek |
#define | FILENAME_MAX MAXPATHLEN |
#define | MF_MIN_BLOCKS_CREAT 1 /* minimum free blocks in new dir */ |
#define | MF_MAX_PARTS 28 /* max # of part-files per metafile */ |
#define | mf_blocksize(mf) ((mf)->blocksize) |
Typedefs | |
typedef off_t | mfile_off_t |
typedef struct mf_dir | mf_dir |
typedef struct part_file | part_file |
typedef struct MFile_area_struct * | MFile_area |
typedef struct meta_file * | MFile |
typedef struct meta_file | meta_file |
Functions | |
MFile_area | mf_init (const char *name, const char *spec, const char *base, int only_shadow_files) ZEBRA_GCC_ATTR((warn_unused_result)) |
creates a metafile area More... | |
void | mf_destroy (MFile_area ma) |
destroys metafile area handle More... | |
MFile | mf_open (MFile_area ma, const char *name, int block_size, int wflag) ZEBRA_GCC_ATTR((warn_unused_result)) |
opens metafile More... | |
int | mf_close (MFile mf) |
closes metafile More... | |
int | mf_read (MFile mf, zint no, int offset, int nbytes, void *buf) ZEBRA_GCC_ATTR((warn_unused_result)) |
reads block from metafile More... | |
int | mf_write (MFile mf, zint no, int offset, int nbytes, const void *buf) ZEBRA_GCC_ATTR((warn_unused_result)) |
writes block to metafile More... | |
void | mf_reset (MFile_area ma, int unlink_flag) |
reset all files in a metafile area (optionally delete them as well) More... | |
int | mf_area_directory_stat (MFile_area ma, int no, const char **directory, double *bytes_used, double *bytes_max) |
metafile area statistics More... | |
#define MF_MAX_PARTS 28 /* max # of part-files per metafile */ |
#define MF_MIN_BLOCKS_CREAT 1 /* minimum free blocks in new dir */ |
typedef struct MFile_area_struct* MFile_area |
typedef off_t mfile_off_t |
int mf_area_directory_stat | ( | MFile_area | ma, |
int | no, | ||
const char ** | directory, | ||
double * | used_bytes, | ||
double * | max_bytes | ||
) |
metafile area statistics
ma | metafile area handle |
no | area number (0=first, 1=second, ..) |
directory | holds directory upon completion (if non-NULL) |
used_bytes | holds used bytes upon completion (if non-NULL) |
max_bytes | holds max size bytes upon completion (if non-NULL) |
0 | area number does not exist |
1 | area number exists (and directory,used_bytes,.. are set) |
Definition at line 612 of file mfile.c.
References mf_dir::avail_bytes, MFile_area_struct::dirs, mf_dir::max_bytes, mf_dir::name, and mf_dir::next.
Referenced by bfs_register_directory_stat(), and bfs_shadow_directory_stat().
int mf_close | ( | MFile | mf | ) |
closes metafile
mf | metafile handle |
0 | OK |
Definition at line 431 of file mfile.c.
References part_file::fd, meta_file::files, meta_file::name, meta_file::no_files, meta_file::open, and meta_file::wr.
Referenced by bf_close2(), bf_commitExec(), cf_close(), and tst2().
void mf_destroy | ( | MFile_area | ma | ) |
destroys metafile area handle
ma | metafile area handle |
Definition at line 309 of file mfile.c.
References MFile_area_struct::dirs, mf_reset(), and mf_dir::next.
Referenced by bfs_destroy(), mf_init(), tst1(), and tst2().
MFile_area mf_init | ( | const char * | name, |
const char * | spec, | ||
const char * | base, | ||
int | only_shadow_files | ||
) |
creates a metafile area
name | of area (does not show up on disk - purely for notation) |
spec | area specification (e.g. "/a:1G dir /b:2000M" |
base | base directory (NULL for no base) |
only_shadow_files | only consider shadow files in area |
Definition at line 196 of file mfile.c.
References mf_dir::avail_bytes, part_file::bytes, cmp_part_file(), meta_file::cur_file, part_file::dir, MFile_area_struct::dirs, part_file::fd, fd, FILENAME_MAX, meta_file::files, meta_file::ma, mf_dir::max_bytes, mf_destroy(), mfile_seek, MFile_area_struct::mfiles, meta_file::mutex, mf_dir::name, meta_file::name, MFile_area_struct::name, mf_dir::next, meta_file::next, meta_file::no_files, part_file::number, O_BINARY, meta_file::open, part_file::path, scan_areadef(), and zebra_mutex_init().
Referenced by bf_cache(), bfs_create(), tst1(), and tst2().
MFile mf_open | ( | MFile_area | ma, |
const char * | name, | ||
int | block_size, | ||
int | wflag | ||
) |
opens metafile
ma | metafile area handle |
name | pseudo filename (name*.mf) |
block_size | block size for this file |
wflag | write flag, 0=read, 1=write&read |
Definition at line 353 of file mfile.c.
References mf_dir::avail_bytes, part_file::blocks, meta_file::blocksize, part_file::bytes, meta_file::cur_file, part_file::dir, MFile_area_struct::dirs, part_file::fd, FILENAME_MAX, meta_file::files, meta_file::ma, mf_dir::max_bytes, MF_MIN_BLOCKS_CREAT, MFile_area_struct::mfiles, meta_file::min_bytes_creat, meta_file::mutex, mf_dir::name, meta_file::name, mf_dir::next, meta_file::next, meta_file::no_files, part_file::number, meta_file::open, part_file::path, part_file::top, meta_file::wr, and zebra_mutex_init().
Referenced by bf_commitExec(), bf_open(), cf_open(), and tst2().
reads block from metafile
mf | metafile handle |
no | block position |
offset | offset within block |
nbytes | no of bytes to read (0 for whole block) |
buf | content (filled with data if OK) |
0 | block partially read |
1 | block fully read |
-1 | block could not be read due to error |
Definition at line 453 of file mfile.c.
References meta_file::blocksize, meta_file::cur_file, part_file::fd, file_position(), meta_file::files, meta_file::mutex, meta_file::name, part_file::path, zebra_mutex_lock(), and zebra_mutex_unlock().
Referenced by bf_read2(), cf_commit_flat(), cf_commit_hash(), cf_lookup_flat(), cf_moveto_flat(), cf_open(), cf_read(), cf_write(), get_bucket(), read_head(), and tst2().
void mf_reset | ( | MFile_area | ma, |
int | unlink_flag | ||
) |
reset all files in a metafile area (optionally delete them as well)
ma | metafile area |
unlink_flag | if unlink_flag=1 all files are removed from FS |
Definition at line 326 of file mfile.c.
References meta_file::files, MFile_area_struct::mfiles, meta_file::mutex, meta_file::next, meta_file::no_files, meta_file::open, part_file::path, and zebra_mutex_destroy().
Referenced by bf_commitClean(), bf_reset(), mf_destroy(), and tst2().
writes block to metafile
mf | metafile handle |
no | block position |
offset | offset within block |
nbytes | no of bytes to write (0 for whole block) |
buf | content to be written |
0 | block written |
-1 | error (block not written) |
Definition at line 486 of file mfile.c.
References mf_dir::avail_bytes, part_file::blocks, meta_file::blocksize, part_file::bytes, meta_file::cur_file, part_file::dir, MFile_area_struct::dirs, part_file::fd, file_position(), FILENAME_MAX, meta_file::files, meta_file::ma, mf_dir::max_bytes, meta_file::mutex, mf_dir::name, meta_file::name, mf_dir::next, meta_file::no_files, part_file::number, part_file::path, part_file::top, zebra_mutex_lock(), zebra_mutex_unlock(), and ZINT_FORMAT.
Referenced by bf_write2(), cf_close(), cf_commit_flat(), cf_commit_hash(), cf_open(), cf_write(), cf_write_flat(), flush_bucket(), tst2(), and write_head().