X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=osl_core.h;h=e042665ab9eda67e95f2c5773f11f1311f468805;hp=295351fecf72a8474c200dd8ded8305a07d4308e;hb=335730538150250f32c0df0b184fb494e2bb0df3;hpb=5129488b99c3d3796752a380a987c74d041dffe8;ds=sidebyside diff --git a/osl_core.h b/osl_core.h index 295351fe..e042665a 100644 --- a/osl_core.h +++ b/osl_core.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Andre Noll + * Copyright (C) 2007-2008 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -56,19 +56,23 @@ struct osl_table { unsigned num_rbtrees; /** * The number of the column that determines the name of the disk - * storage objcts. + * storage objects. */ unsigned disk_storage_name_column; /** The number of bytes of an index entry of a row. */ - unsigned index_entry_size; + unsigned row_index_size; /** Pointer to the internal representation of the columns. */ struct osl_column *columns; }; /** Internal representation of a row of an osl table */ struct osl_row { - /** The row number only present if there is at least one mapped column. */ - off_t id; + /** + * The row number. + * + * It is only used if there is at least one mapped column. + */ + off_t num; /** Array of size \a num_volatile_columns. */ struct osl_object *volatile_objects; }; @@ -76,9 +80,9 @@ struct osl_row { int read_table_desc(struct osl_object *map, struct osl_table_description *desc); int init_table_structure(const struct osl_table_description *desc, struct osl_table **table_ptr); -int row_is_invalid(struct osl_table *t, uint32_t id); +int row_is_invalid(struct osl_table *t, uint32_t row_num); int get_mapped_object(const struct osl_table *t, unsigned col_num, - uint32_t id, struct osl_object *obj); + uint32_t row_num, struct osl_object *obj); int para_truncate(const char *filename, off_t size); int unmap_table(struct osl_table *t, enum osl_close_flags flags); int init_rbtrees(struct osl_table *t); @@ -91,7 +95,7 @@ int init_rbtrees(struct osl_table *t); enum map_table_flags { /** * Check whether the entries in the table index match the entries in - * the table desctiption. + * the table description. */ MAP_TBL_FL_VERIFY_INDEX = 1, /** Do not complain even if the dirty flag is set. */ @@ -109,7 +113,7 @@ int mark_row_invalid(struct osl_table *t, uint32_t row_num); * Get the description of a column by column number * * \param d Pointer to the table description. - * \param col_num The number of the column to get the desctiption for. + * \param col_num The number of the column to get the description for. * * \return The table description. * @@ -204,7 +208,7 @@ _static_inline_ size_t index_column_description_size(const char *name) _static_inline_ unsigned table_num_rows(const struct osl_table *t) { return (t->index_map.size - t->index_header_size) - / t->index_entry_size; + / t->row_index_size; } /** @@ -243,22 +247,22 @@ _static_inline_ char *column_filename(const struct osl_table *t, unsigned col_nu * * \param t Pointer to a table which has been mapped. * \param row_num The number of the row whose index entry should be retrieved. - * \param index_entry Result is returned here. + * \param row_index Result pointer. * * \return Positive on success, \p -E_INDEX_CORRUPTION otherwise. * - * \sa get_index_entry(). + * \sa get_cell_index(). */ -_static_inline_ int get_index_entry_start(const struct osl_table *t, uint32_t row_num, - char **index_entry) +_static_inline_ int get_row_index(const struct osl_table *t, uint32_t row_num, + char **row_index) { uint32_t index_offset; - index_offset = t->index_header_size + t->index_entry_size * row_num; + index_offset = t->index_header_size + t->row_index_size * row_num; if (index_offset + 8 > t->index_map.size) { - *index_entry = NULL; + *row_index = NULL; return -E_INDEX_CORRUPTION; } - *index_entry = (char *)(t->index_map.data) + index_offset; + *row_index = (char *)(t->index_map.data) + index_offset; return 1; } @@ -268,26 +272,26 @@ _static_inline_ int get_index_entry_start(const struct osl_table *t, uint32_t ro * \param t Pointer to a table which has been mapped. * \param row_num The number of the row whose index entry should be retrieved. * \param col_num The number of the column whose index entry should be retrieved. - * \param index_entry Result pointer. + * \param cell_index Result pointer. * * \return Positive on success, \p -E_INDEX_CORRUPTION otherwise. * - * \sa get_index_entry_start(). + * \sa get_row_index(). */ -_static_inline_ int get_index_entry(const struct osl_table *t, uint32_t row_num, - uint32_t col_num, char **index_entry) +_static_inline_ int get_cell_index(const struct osl_table *t, uint32_t row_num, + uint32_t col_num, char **cell_index) { - int ret = get_index_entry_start(t, row_num, index_entry); + int ret = get_row_index(t, row_num, cell_index); if (ret < 0) return ret; - *index_entry += t->columns[col_num].index_offset; + *cell_index += t->columns[col_num].index_offset; return ret; } /** * Change an index entry of a column after object was added. * - * \param index_entry_start This determines the row. + * \param row_index Pointer to the index of the row to update. * \param col Pointer to the column. * \param map_size The new size of the data file. * \param object_size The size of the object just appended to the data file. @@ -295,13 +299,13 @@ _static_inline_ int get_index_entry(const struct osl_table *t, uint32_t row_num, * This is called right after an object was appended to the data file for a * mapped column. * - * \sa get_index_entry_start(). + * \sa get_row_index(). */ -_static_inline_ void update_index_entry(char *index_entry_start, struct osl_column *col, +_static_inline_ void update_cell_index(char *row_index, struct osl_column *col, uint32_t map_size, uint32_t object_size) { - write_u32(index_entry_start + col->index_offset, map_size - object_size - 1); - write_u32(index_entry_start + col->index_offset + 4, object_size + 1); + write_u32(row_index + col->index_offset, map_size - object_size - 1); + write_u32(row_index + col->index_offset + 4, object_size + 1); } /** @@ -435,9 +439,9 @@ _static_inline_ struct osl_row *get_row_pointer(const struct rb_node *node, * \param obj the Object to compute the hash value from. * \param hash Result is returned here. */ -static inline void hash_object(const struct osl_object *obj, HASH_TYPE *hash) +_static_inline_ void hash_object(const struct osl_object *obj, HASH_TYPE *hash) { - return hash_function(obj->data, obj->size, hash); + hash_function(obj->data, obj->size, hash); } /** @@ -456,7 +460,7 @@ static inline void hash_object(const struct osl_object *obj, HASH_TYPE *hash) * * \sa struct osl_table:disk_storage_name_column. */ -static inline char *disk_storage_name_of_hash(const struct osl_table *t, HASH_TYPE *hash) +_static_inline_ char *disk_storage_name_of_hash(const struct osl_table *t, HASH_TYPE *hash) { char asc[2 * HASH_SIZE + 2]; @@ -472,14 +476,14 @@ static inline char *disk_storage_name_of_hash(const struct osl_table *t, HASH_TY * \param old_path The source path. * \param new_path The destination path. * - * \return positive in success, \p -E_RENAME on errors. + * \return Standard. * * \sa rename(2). */ -static inline int para_rename(const char *old_path, const char *new_path) +_static_inline_ int para_rename(const char *old_path, const char *new_path) { if (rename(old_path, new_path) < 0) - return -E_RENAME; + return -ERRNO_TO_PARA_ERROR(errno); return 1; }