db_manage.c File Reference

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"
Include dependency graph for db_manage.c:

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

Detailed Description

Management of a DB file.

Remarks:
Copyright 2002 OProfile authors
Read the file COPYING
Author:
Philippe Elie

Define Documentation

#define _GNU_SOURCE
#define DEFAULT_NODE_NR ( offset_node   )     128

Referenced by odb_open().

#define FILES_HASH_SIZE   512

Function Documentation

void odb_close ( odb_t odb  ) 
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_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

Parameters:
odb the DB file to init

References odb_t::data.

Referenced by operf_sfile_dup(), and sfile_dup().

int odb_open ( odb_t odb,
char const *  filename,
enum odb_rw  rw,
size_t  sizeof_header 
)
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.

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.


Generated on 29 Jul 2013 for oprofile by  doxygen 1.6.1