*name = disk_storage_name_of_object(t, &obj);
if (*name)
return 1;
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
}
static void column_name_hash(const char *col_name, HASH_TYPE *hash)
{
const struct osl_column_description *cd;
struct osl_table *t = calloc(1, sizeof(*t));
- int i, ret = -ERRNO_TO_ERROR(ENOMEM), have_disk_storage_name_column = 0;
+ int i, ret = -E_OSL_NOMEM, have_disk_storage_name_column = 0;
if (!t)
return ret;
ret = -E_OSL_NO_COLUMNS;
if (!desc->num_columns)
goto err;
- ret = -ERRNO_TO_ERROR(ENOMEM);
+ ret = -E_OSL_NOMEM;
t->columns = calloc(desc->num_columns, sizeof(struct osl_column));
if (!t->columns)
goto err;
desc->column_descriptions = calloc(desc->num_columns,
sizeof(struct osl_column_description));
if (!desc->column_descriptions)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
offset = IDX_COLUMN_DESCRIPTIONS;
FOR_EACH_COLUMN(i, desc, cd) {
char *null_byte;
ret = -E_OSL_INDEX_CORRUPTION;
if (!null_byte)
goto err;
- ret = -ERRNO_TO_ERROR(ENOMEM);
+ ret = -E_OSL_NOMEM;
cd->name = strdup(buf + offset + IDX_CD_NAME);
if (!cd->name)
goto err;
struct osl_column_description *cd;
unsigned diff = t->desc->num_columns - desc.num_columns;
INFO_LOG("extending table by %u volatile columns\n", diff);
- ret = -ERRNO_TO_ERROR(ENOMEM);
+ ret = -E_OSL_NOMEM;
desc.column_descriptions = realloc(desc.column_descriptions,
t->desc->num_columns * sizeof(struct osl_column_description));
if (!desc.column_descriptions)
t->desc->name);
buf = calloc(1, size);
if (!buf)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
sprintf(buf + IDX_PARA_MAGIC, "%s", PARA_MAGIC);
write_u8(buf + IDX_TABLE_FLAGS, t->desc->flags);
write_u8(buf + IDX_DIRTY_FLAG, 0);
if (filename)
ret = write_file(filename, buf, size);
else
- ret = -ERRNO_TO_ERROR(ENOMEM);
+ ret = -E_OSL_NOMEM;
free(buf);
free(filename);
return ret;
goto out;
table_dir = make_message("%s/%s", desc->dir,
desc->name);
- ret = -ERRNO_TO_ERROR(ENOMEM);
+ ret = -E_OSL_NOMEM;
if (!table_dir)
goto out;
ret = osl_mkdir(table_dir, 0777);
if (ret < 0)
goto out;
}
- ret = -ERRNO_TO_ERROR(ENOMEM);
+ ret = -E_OSL_NOMEM;
filename = column_filename(t, i);
if (!filename)
goto out;
int ret;
if (!filename)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
ret = osl_stat(filename, &statbuf);
if (ret < 0) {
free(filename);
return -E_OSL_ALREADY_MAPPED;
filename = index_filename(t->desc);
if (!filename)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
INFO_LOG("mapping table '%s' (index: %s)\n", t->desc->name, filename);
ret = mmap_full_file(filename, flags & MAP_TBL_FL_MAP_RDONLY?
O_RDONLY : O_RDWR, &t->index_map.data, &t->index_map.size, NULL);
const struct osl_column_description *cd;
if (!row)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
row->num = row_num;
row->volatile_objects = volatile_objs;
FOR_EACH_RBTREE_COLUMN(i, t, cd) {
struct stat statbuf;
char *dirname = column_filename(t, i);
- ret = -ERRNO_TO_ERROR(ENOMEM);
+ ret = -E_OSL_NOMEM;
if (!dirname)
goto err;
/* check if directory exists */
return 1;
dirname = disk_storage_dirname(t, col_num, ds_name);
if (!dirname)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
ret = osl_mkdir(dirname, 0777);
free(dirname);
if (ret < 0 && !is_errno(-ret, EEXIST))
return ret;
filename = disk_storage_path(t, col_num, ds_name);
if (!filename)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
ret = write_file(filename, obj->data, obj->size);
free(filename);
return ret;
int ret;
if (!filename)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
ret = append_file(filename, obj->data, obj->size, new_size);
free(filename);
return ret;
return 1;
filename = index_filename(t->desc);
if (!filename)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
ret = append_file(filename, row_index, t->row_index_size, NULL);
free(filename);
return ret;
char *filename = column_filename(t, col_num);
if (!filename)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
ret = truncate_file(filename, size);
free(filename);
return ret;
int ret, err;
if (!filename)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
ret = unlink(filename);
err = errno;
free(filename);
return 1;
dirname = disk_storage_dirname(t, col_num, ds_name);
if (!dirname)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
rmdir(dirname);
free(dirname);
return 1;
return -E_OSL_BAD_TABLE;
rb_parents = malloc(t->num_rbtrees * sizeof(struct rn_node*));
if (!rb_parents)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
rb_links = malloc(t->num_rbtrees * sizeof(struct rn_node**));
if (!rb_links) {
free(rb_parents);
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
}
if (t->num_mapped_columns) {
new_row_index = malloc(t->row_index_size);
if (!new_row_index) {
free(rb_links);
free(rb_parents);
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
}
}
/* pass 1: sanity checks */
if (t->num_disk_storage_columns) {
ds_name = disk_storage_name_of_object(t,
&objects[t->disk_storage_name_column]);
- ret = -ERRNO_TO_ERROR(ENOMEM);
+ ret = -E_OSL_NOMEM;
if (!ds_name)
goto out;
}
}
/* pass 3: add entry to rbtrees */
if (t->num_volatile_columns) {
- ret = -ERRNO_TO_ERROR(ENOMEM);
+ ret = -E_OSL_NOMEM;
volatile_objs = calloc(t->num_volatile_columns,
sizeof(struct osl_object));
if (!volatile_objs)
return 1; /* object did not change */
old_ds_name = disk_storage_name_of_object(t, old_obj);
new_ds_name = disk_storage_name_of_object(t, new_obj);
- ret = -ERRNO_TO_ERROR(ENOMEM);
+ ret = -E_OSL_NOMEM;
if (!old_ds_name || ! new_ds_name)
goto out;
old_filename = disk_storage_path(t, i, old_ds_name);
new_filename = disk_storage_path(t, i, new_ds_name);
if (!old_filename || !new_filename)
- ret = -ERRNO_TO_ERROR(ENOMEM);
+ ret = -E_OSL_NOMEM;
else
ret = osl_rename(old_filename, new_filename);
free(old_filename);
filename = disk_storage_path(t, col_num, ds_name);
free(ds_name);
if (!filename)
- return -ERRNO_TO_ERROR(ENOMEM);
+ return -E_OSL_NOMEM;
DEBUG_LOG("filename: %s\n", filename);
ret = mmap_full_file(filename, O_RDONLY, &obj->data, &obj->size, NULL);
free(filename);