X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=osl.c;h=7f6ffdb9094a4b4deb12c49a876f6118a05473e5;hp=f49785cd8574add659f44650c71a40644154fa8a;hb=5f05aea3182a80a625c3ce15380136e682497be2;hpb=70de5747997ee637dba6f817abccc56ec1340875 diff --git a/osl.c b/osl.c index f49785cd..7f6ffdb9 100644 --- a/osl.c +++ b/osl.c @@ -12,9 +12,6 @@ #include /* readdir() */ #include -//#define FMT_OFF_T "%li" - - /** * A wrapper for lseek(2). * @@ -41,7 +38,7 @@ int para_lseek(int fd, off_t *offset, int whence) } /** - * Waraper for the write system call. + * Wrapper for the write system call. * * \param fd The file descriptor to write to. * \param buf The buffer to write. @@ -270,7 +267,6 @@ int for_each_file_in_dir(const char *dirname, * and calling chdir() afterwards (see man 3 getcwd). */ int cwd_fd = open(".", O_RDONLY); - struct stat s; int ret = -1; // PARA_DEBUG_LOG("dirname: %s\n", dirname); @@ -287,6 +283,7 @@ int for_each_file_in_dir(const char *dirname, while ((entry = readdir(dir))) { mode_t m; char *tmp; + struct stat s; if (!strcmp(entry->d_name, ".")) continue; @@ -337,7 +334,7 @@ int para_mkdir(const char *path, mode_t mode) return -E_MKDIR; } -static int verify_basename(const char *name) +static int verify_name(const char *name) { if (!name) return -E_BAD_NAME; @@ -432,7 +429,7 @@ static int init_column_descriptions(struct osl_table *t) const struct osl_column_description *cd; ret = -E_BAD_TABLE_DESC; - ret = verify_basename(t->desc->name); + ret = verify_name(t->desc->name); if (ret < 0) goto err; ret = -E_BAD_DB_DIR; @@ -451,7 +448,7 @@ static int init_column_descriptions(struct osl_table *t) ret = -E_NO_COLUMN_NAME; if (!cd->name || !cd->name[0]) goto err; - ret = verify_basename(cd->name); + ret = verify_name(cd->name); if (ret < 0) goto err; t->index_header_size += index_column_description_size(cd->name); @@ -991,7 +988,7 @@ static int search_rbtree(const struct osl_object *obj, struct osl_object this_obj; parent = *new; if (st == OSL_MAPPED_STORAGE) { - ret = get_mapped_object(t, col_num, this_row->id, + ret = get_mapped_object(t, col_num, this_row->num, &this_obj); if (ret < 0) return ret; @@ -1061,7 +1058,7 @@ static void remove_rb_node(struct osl_table *t, unsigned col_num, rb_erase(victim, &col->rbtree); } -static int add_row_to_rbtrees(struct osl_table *t, uint32_t id, +static int add_row_to_rbtrees(struct osl_table *t, uint32_t row_num, struct osl_object *volatile_objs, struct osl_row **row_ptr) { unsigned i; @@ -1069,12 +1066,12 @@ static int add_row_to_rbtrees(struct osl_table *t, uint32_t id, struct osl_row *row = allocate_row(t->num_rbtrees); const struct osl_column_description *cd; - row->id = id; + row->num = row_num; row->volatile_objects = volatile_objs; FOR_EACH_RBTREE_COLUMN(i, t, cd) { if (cd->storage_type == OSL_MAPPED_STORAGE) { struct osl_object obj; - ret = get_mapped_object(t, i, id, &obj); + ret = get_mapped_object(t, i, row_num, &obj); if (ret < 0) goto err; ret = insert_rbtree(t, i, row, &obj); @@ -1637,18 +1634,18 @@ int osl_get_object(const struct osl_table *t, const struct osl_row *r, if (cd->storage_type == OSL_DISK_STORAGE) return -E_BAD_STORAGE_TYPE; if (cd->storage_type == OSL_MAPPED_STORAGE) - return get_mapped_object(t, col_num, r->id, object); + return get_mapped_object(t, col_num, r->num, object); /* volatile */ *object = r->volatile_objects[t->columns[col_num].volatile_num]; return 1; } -static int mark_mapped_object_invalid(const struct osl_table *t, uint32_t id, - unsigned col_num) +static int mark_mapped_object_invalid(const struct osl_table *t, + uint32_t row_num, unsigned col_num) { struct osl_object obj; char *p; - int ret = get_mapped_object(t, col_num, id, &obj); + int ret = get_mapped_object(t, col_num, row_num, &obj); if (ret < 0) return ret; @@ -1696,14 +1693,14 @@ int osl_del_row(struct osl_table *t, struct osl_row *row) enum osl_storage_type st = cd->storage_type; remove_rb_node(t, i, r); if (st == OSL_MAPPED_STORAGE) { - mark_mapped_object_invalid(t, r->id, i); + mark_mapped_object_invalid(t, r->num, i); continue; } if (st == OSL_NO_STORAGE) free(r->volatile_objects[col->volatile_num].data); } if (t->num_mapped_columns) { - ret = mark_row_invalid(t, r->id); + ret = mark_row_invalid(t, r->num); if (ret < 0) goto out; t->num_invalid_rows++; @@ -1952,7 +1949,7 @@ int osl_update_object(struct osl_table *t, const struct osl_row *r, return ret; } else { /* mapped storage */ struct osl_object old_obj; - ret = get_mapped_object(t, col_num, r->id, &old_obj); + ret = get_mapped_object(t, col_num, r->num, &old_obj); if (ret < 0) return ret; /* @@ -1970,10 +1967,10 @@ int osl_update_object(struct osl_table *t, const struct osl_row *r, else { /* TODO: if the size doesn't change, use old space */ uint32_t new_data_map_size; char *row_index; - ret = get_row_index(t, r->id, &row_index); + ret = get_row_index(t, r->num, &row_index); if (ret < 0) return ret; - ret = mark_mapped_object_invalid(t, r->id, col_num); + ret = mark_mapped_object_invalid(t, r->num, col_num); if (ret < 0) return ret; unmap_column(t, col_num);