src/buffer_file.c File Reference

Buffer file operations. More...

#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include "buffer.h"
#include "buffer_options.h"
#include "buffer_internal.h"
#include "segcol_list.h"
#include "data_object.h"
#include "data_object_file.h"
#include "overlap_graph.h"
#include "list.h"
#include "buffer_util.h"
#include "debug.h"
#include "util.h"
#include "type_limits.h"
Include dependency graph for buffer_file.c:

Go to the source code of this file.

Functions

static int is_fd_resizable (int fd, int *fd_resizable)
 Checks if a file descriptor points to a resizable file.
static int reserve_disk_space (int fd, off_t size)
 Reserves disk space for writing a file.
static int create_overlap_graph (overlap_graph_t **g, segcol_t *segcol, data_object_t *fd_obj)
 Create an overlap graph for a segcol_t.
static int break_edge (segcol_t *segcol, struct edge_entry *edge, char *tmpdir)
 Break an edge of the overlap graph.
static int write_segment (int fd, segment_t *segment, off_t mapping, off_t overlap)
 Writes the data of a segment to a file.
static int write_segcol_rest (int fd, segcol_t *segcol, data_object_t *fd_obj)
 Writes the data of a segcol except those belonging to the file we are trying to write to.
static int actions_make_private_copy (bless_buffer_t *buf, data_object_t *obj, int del)
 Makes private copies of buffer (undo/redo) action data that belong to a specific data object.
static int buffer_options_new (struct buffer_options **opts)
 Creates a new buffer_options struct.
static int buffer_options_free (struct buffer_options *opts)
 Frees a buffer_options struct.
static void free_vertex_list (list_t *list)
 Frees a vertex list and its contents.
static void free_edge_list (list_t *list)
 Frees an edge list and its contents.
int bless_buffer_new (bless_buffer_t **buf)
 Creates an empty bless_buffer_t.
int bless_buffer_save (bless_buffer_t *buf, int fd, bless_progress_func *progress_func)
 Saves the contents of a bless_buffer_t to a file.
int bless_buffer_free (bless_buffer_t *buf)
 Frees a bless_buffer_t.

Detailed Description

Buffer file operations.

Definition in file buffer_file.c.


Function Documentation

static int actions_make_private_copy ( bless_buffer_t buf,
data_object_t obj,
int  del 
) [static]

Makes private copies of buffer (undo/redo) action data that belong to a specific data object.

This is done to ensure the integrity of the data in case the specified data object changes (eg a file during save).

If 'del' is non-zero and a private copy of an action can not be made, that and older actions are removed from the undo/redo list. Otherwise in case a private copy fails an error is immediately returned.

Parameters:
buf the bless_buffer_t
obj the data_object_t the data must belong to
del whether to delete any actions (and actions older than them) that we cannot make private copies of.
Returns:
the operation error code

Definition at line 338 of file buffer_file.c.

References buffer_action_free(), buffer_action_private_copy(), list_delete_chain(), list_entry, list_for_each_reverse_safe, list_for_each_safe, list_head(), and list_tail().

Referenced by bless_buffer_save().

Here is the call graph for this function:

Here is the caller graph for this function:

static int break_edge ( segcol_t segcol,
struct edge_entry edge,
char *  tmpdir 
) [static]

Break an edge of the overlap graph.

Parameters:
segcol the segcol_t containing the segments
edge the edge to break
tmpdir the directory where to store temporary files (if needed)
Returns:
the operation error code

Definition at line 185 of file buffer_file.c.

References segcol_store_in_file(), segcol_store_in_memory(), segment_get_data(), and segment_get_start().

Referenced by bless_buffer_save().

Here is the call graph for this function:

Here is the caller graph for this function:

static int buffer_options_free ( struct buffer_options opts  )  [static]

Frees a buffer_options struct.

Parameters:
opts the buffer_options struct to free
Returns:
the operation error code

Definition at line 465 of file buffer_file.c.

Referenced by bless_buffer_free(), and bless_buffer_new().

Here is the caller graph for this function:

static int buffer_options_new ( struct buffer_options **  opts  )  [static]

Creates a new buffer_options struct.

Parameters:
[out] opts the created buffer_options struct.
Returns:
the operation error code

Definition at line 429 of file buffer_file.c.

Referenced by bless_buffer_new().

Here is the caller graph for this function:

static int create_overlap_graph ( overlap_graph_t **  g,
segcol_t segcol,
data_object_t fd_obj 
) [static]

Create an overlap graph for a segcol_t.

See doc/devel/buffer_save.txt for more.

Parameters:
[out] g the created overlap graph
segcol the segcol_t to create the overlap graph for
fd_obj the file data_object_t pointing to the file to check for overlap with
Returns:
the operation error code

Definition at line 127 of file buffer_file.c.

References data_object_compare(), overlap_graph_add_segment(), overlap_graph_free(), overlap_graph_new(), segcol_iter_free(), segcol_iter_get_mapping(), segcol_iter_get_segment(), segcol_iter_is_valid(), segcol_iter_new(), segcol_iter_next(), and segment_get_data().

Referenced by bless_buffer_save().

Here is the call graph for this function:

Here is the caller graph for this function:

static void free_edge_list ( list_t list  )  [static]

Frees an edge list and its contents.

Parameters:
list the list to free

Definition at line 500 of file buffer_file.c.

References list_entry, list_for_each_safe, list_free(), and list_head().

Referenced by bless_buffer_save().

Here is the call graph for this function:

Here is the caller graph for this function:

static void free_vertex_list ( list_t list  )  [static]

Frees a vertex list and its contents.

Parameters:
list the list to free

Definition at line 480 of file buffer_file.c.

References list_entry, list_for_each_safe, list_free(), and list_head().

Referenced by bless_buffer_save().

Here is the call graph for this function:

Here is the caller graph for this function:

static int is_fd_resizable ( int  fd,
int *  fd_resizable 
) [static]

Checks if a file descriptor points to a resizable file.

Parameters:
fd the fd to check
[out] fd_resizable whether the fd is resizable
Returns:
the operation error code

Definition at line 60 of file buffer_file.c.

Referenced by bless_buffer_save().

Here is the caller graph for this function:

static int reserve_disk_space ( int  fd,
off_t  size 
) [static]

Reserves disk space for writing a file.

Parameters:
fd the file to extend
size the space to reserve
Returns:
the operation error code

Definition at line 82 of file buffer_file.c.

Referenced by bless_buffer_save().

Here is the caller graph for this function:

static int write_segcol_rest ( int  fd,
segcol_t segcol,
data_object_t fd_obj 
) [static]

Writes the data of a segcol except those belonging to the file we are trying to write to.

Parameters:
fd the file descriptor of the file to write to
segcol the segcol to write the data of
fd_obj a data_object_t pointing to fd
Returns:
the operation error code

Definition at line 276 of file buffer_file.c.

References data_object_compare(), segcol_iter_free(), segcol_iter_get_mapping(), segcol_iter_get_segment(), segcol_iter_is_valid(), segcol_iter_new(), segcol_iter_next(), segment_get_data(), and write_segment().

Referenced by bless_buffer_save().

Here is the call graph for this function:

Here is the caller graph for this function:

static int write_segment ( int  fd,
segment_t segment,
off_t  mapping,
off_t  overlap 
) [static]

Writes the data of a segment to a file.

Parameters:
fd the file desciptor of the file to write to
segment the segment to write
mapping the mapping of the segment to write
overlap the overlap of the segment with itself in bytes
Returns:
the operation error code

Definition at line 227 of file buffer_file.c.

References segment_get_data(), segment_get_size(), segment_get_start(), write_data_object(), and write_data_object_safe().

Referenced by bless_buffer_save(), and write_segcol_rest().

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Sun Nov 15 15:27:39 2009 for libbls by  doxygen 1.6.1