Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
filedescriptorregistry.c File Reference

Go to the source code of this file.

Description

Implementation of a registry to manage used filedescriptors.

Todo:
development in this area is stalled since 2010

Definition in file filedescriptorregistry.c.

#include "include/logging.h"
#include "lib/safeclib.h"
#include "lib/mutex.h"
#include "lib/psplay.h"
#include "backend/file.h"
#include "backend/filedescriptor.h"
#include "backend/filedescriptorregistry.h"

Functions

static int cmp_fn (const void *keya, const void *keyb)
 
static void delete_fn (PSplaynode node)
 
static const void * key_fn (const PSplaynode node)
 
void lumiera_filedescriptorregistry_destroy (void)
 Destroy and free the global file descriptor registry. More...
 
LumieraFiledescriptor lumiera_filedescriptorregistry_ensure (LumieraFiledescriptor template)
 Ensures that a filedescriptor is in the registry. More...
 
void lumiera_filedescriptorregistry_init (void)
 Initialise the global file descriptor registry. More...
 
void lumiera_filedescriptorregistry_remove (LumieraFiledescriptor self)
 Removes a file descriptor from the registry. More...
 

Variables

static PSplay filedescriptorregistry
 the global registry for file descriptors. More...
 
static lumiera_mutex filedescriptorregistry_mutex
 

Function Documentation

static int cmp_fn ( const void *  keya,
const void *  keyb 
)
static

Definition at line 48 of file filedescriptorregistry.c.

References LUMIERA_FILE_MASK.

Referenced by lumiera_filedescriptorregistry_init().

+ Here is the caller graph for this function:

static void delete_fn ( PSplaynode  node)
static

Definition at line 73 of file filedescriptorregistry.c.

References lumiera_filedescriptor_delete(), and NULL.

Referenced by lumiera_filedescriptorregistry_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static const void* key_fn ( const PSplaynode  node)
static

Definition at line 81 of file filedescriptorregistry.c.

Referenced by lumiera_filedescriptorregistry_init().

+ Here is the caller graph for this function:

void lumiera_filedescriptorregistry_init ( void  )

Initialise the global file descriptor registry.

Opening hard linked files will be targeted to the same file descriptor. This function never fails but dies on error.

Todo:
proper backend/subsystem failure

Definition at line 89 of file filedescriptorregistry.c.

References cmp_fn(), delete_fn(), filedescriptorregistry, filedescriptorregistry_mutex, key_fn(), LUMIERA_DIE, lumiera_mutex_init(), psplay_new(), and TRACE().

Referenced by lumiera_backend_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lumiera_filedescriptorregistry_destroy ( void  )

Destroy and free the global file descriptor registry.

Never fails.

Definition at line 102 of file filedescriptorregistry.c.

References filedescriptorregistry, filedescriptorregistry_mutex, lumiera_mutex_destroy(), NULL, psplay_delete(), psplay_nelements(), and TRACE().

Referenced by lumiera_backend_destroy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

LumieraFiledescriptor lumiera_filedescriptorregistry_ensure ( LumieraFiledescriptor  template)

Ensures that a filedescriptor is in the registry.

Looks template up and if not found, create a new one from template.

Returns
filedescriptor from registry

Definition at line 117 of file filedescriptorregistry.c.

References filedescriptorregistry, filedescriptorregistry_mutex, lumiera_filedescriptor_new(), LUMIERA_MUTEX_SECTION, NULL, psplay_find(), and psplay_insert().

Referenced by lumiera_filedescriptor_acquire().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void lumiera_filedescriptorregistry_remove ( LumieraFiledescriptor  self)

Removes a file descriptor from the registry.

Definition at line 146 of file filedescriptorregistry.c.

References filedescriptorregistry, filedescriptorregistry_mutex, LUMIERA_MUTEX_SECTION, and psplay_remove().

Referenced by lumiera_filedescriptor_delete().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

PSplay filedescriptorregistry
static