Management of a DB file. More...
#include <stdlib.h>#include <sys/fcntl.h>#include <sys/mman.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <errno.h>#include <string.h>#include <stdio.h>#include "odb.h"#include "op_string.h"#include "op_libiberty.h"
Defines | |
| #define | _GNU_SOURCE |
| #define | DEFAULT_NODE_NR(offset_node) 128 |
| #define | FILES_HASH_SIZE 512 |
Functions | |
| int | odb_grow_hashtable (odb_data_t *data) |
| grow the hashtable in such way current_size is the index of the first free node. | |
| void | odb_init (odb_t *odb) |
| odb_init - initialize a DB file | |
| int | odb_open (odb_t *odb, char const *filename, enum odb_rw rw, size_t sizeof_header) |
| void | odb_close (odb_t *odb) |
| Close the given ODB file. | |
| int | odb_open_count (odb_t const *odb) |
| return the number of times this sample file is open | |
| void * | odb_get_data (odb_t *odb) |
| return the start of the mapped data | |
| void | odb_sync (odb_t const *odb) |
| issue a msync on the used size of the mmaped file | |
Management of a DB file.
| #define _GNU_SOURCE |
| #define DEFAULT_NODE_NR | ( | offset_node | ) | 128 |
Referenced by odb_open().
| #define FILES_HASH_SIZE 512 |
| void odb_close | ( | odb_t * | odb | ) |
Close the given ODB file.
References odb_data::base_memory, odb_t::data, odb_data::descr, odb_data::fd, odb_data::filename, odb_data::list, odb_data::ref_count, and odb_descr_t::size.
Referenced by main(), and opd_close_image_samples_files().
| void* odb_get_data | ( | odb_t * | odb | ) |
return the start of the mapped data
References odb_data::base_memory, and odb_t::data.
Referenced by import_from_abi(), main(), opd_open_24_sample_file(), opd_open_sample_file(), and operf_open_sample_file().
| int odb_grow_hashtable | ( | odb_data_t * | data | ) |
grow the hashtable in such way current_size is the index of the first free node.
Take care all node pointer can be invalidated by this call.
Node allocation is done in a two step way 1st) ensure a free node exist eventually, caller can setup it, 2nd) commit the node allocation with odb_commit_reservation(). This is done in this way to ensure node setup is visible from another process like pp tools in an atomic way.
returns 0 on success, non zero on failure in this case this function do nothing and errno is set by the first libc call failure allowing to retry after cleanup some program resource.
References odb_data::base_memory, BUCKET_FACTOR, odb_descr_t::current_size, odb_data::descr, odb_data::fd, odb_data::hash_base, odb_data::hash_mask, odb_node_t::key, odb_node_t::next, odb_data::node_base, and odb_descr_t::size.
| void odb_init | ( | odb_t * | odb | ) |
odb_init - initialize a DB file
| odb | the DB file to init |
References odb_t::data.
Referenced by opd_open_24_sample_file(), operf_sfile_dup(), and sfile_dup().
References odb_data::base_memory, BUCKET_FACTOR, odb_descr_t::current_size, odb_t::data, DEFAULT_NODE_NR, odb_data::descr, odb_data::fd, odb_data::filename, odb_data::hash_base, odb_data::hash_mask, odb_data::list, odb_data::node_base, ODB_RDONLY, ODB_RDWR, odb_data::offset_node, op_hash_string(), odb_data::ref_count, odb_descr_t::size, and odb_data::sizeof_header.
Referenced by main(), opd_open_24_sample_file(), opd_open_sample_file(), and operf_open_sample_file().
| int odb_open_count | ( | odb_t const * | odb | ) |
return the number of times this sample file is open
References odb_t::data, and odb_data::ref_count.
Referenced by opd_put_image_sample().
| void odb_sync | ( | odb_t const * | odb | ) |
issue a msync on the used size of the mmaped file
References odb_data::base_memory, odb_t::data, odb_data::descr, and odb_descr_t::size.
Referenced by opd_sync_samples_files().
1.6.1