X-Git-Url: http://git.tuebingen.mpg.de/?p=osl.git;a=blobdiff_plain;f=fsck.c;h=f700e9f9624c6437b33c04d0418767c364da79e3;hp=00f14f320597f3dc324041f57ae9cb4c3f044a61;hb=e1afea4830d00c57e30d5b84b3b5ffcc8501af86;hpb=2dba3a38dcfe721842404f01e9b2adb59c302604 diff --git a/fsck.c b/fsck.c index 00f14f3..f700e9f 100644 --- a/fsck.c +++ b/fsck.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 Andre Noll + * Copyright (C) 2007-2009 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -20,7 +20,7 @@ /** version text used by various commands if -V switch was given */ #define VERSION_TEXT(prefix) "osl_" prefix " " VERSION " " "\n" \ - "Copyright (C) 2008 Andre Noll\n" \ + "Copyright (C) 2008-2009 Andre Noll\n" \ "This is free software with ABSOLUTELY NO WARRANTY." \ " See COPYING for details.\n" \ "Written by Andre Noll.\n" \ @@ -167,7 +167,7 @@ __must_check __malloc static void *fsck_calloc(size_t size) } /** - * Paraslash's version of strdup(). + * Save version of strdup(). * * \param s The string to be duplicated. * @@ -399,15 +399,13 @@ static int check_index_ranges(struct osl_table *t) //DEBUG_LOG("%d rows. %d columns\n", t->num_rows, t->desc->num_columns); t->num_invalid_rows = 0; for (i = 0; i < t->num_rows; i++) { + const struct osl_column_description *cd; + if (row_is_invalid(t, i)) { t->num_invalid_rows++; continue; } - for (j = 0; j < t->desc->num_columns; j++) { /* FXIME */ - const struct osl_column_description *cd = - get_column_description(t->desc, j); - if (cd->storage_type != OSL_MAPPED_STORAGE) - continue; + FOR_EACH_MAPPED_COLUMN(j, t, cd) { ret = check_range(t, i, j); if (ret < 0) { if (ret != -E_FSCK_RANGE_VIOLATION) @@ -512,6 +510,8 @@ static int check_for_invalid_objects(struct osl_table *t, uint32_t **lost_bytes) /* first count used bytes */ FOR_EACH_MAPPED_COLUMN(i, t, cd) { loss[i] = t->columns[i].data_map.size; + DEBUG_LOG("column %i data map: %u bytes\n", i, + t->columns[i].data_map.size); for (j = 0; j < t->num_rows; j++) { struct osl_object obj; ret = get_mapped_object(t, i, j, &obj); @@ -553,10 +553,10 @@ static int prune_mapped_column(struct osl_table *t, uint32_t col_num, int fd) ret = get_mapped_object(t, col_num, i, &obj); if (ret < 0) return ret; - ret = _write_all(fd, (char *)(obj.data) - 1, obj.size + 1); + ret = _write_all(fd, (char *)(obj.data), obj.size); if (ret < 0) return ret; - written += obj.size + 1; + written += obj.size; ret = get_row_index(t, i, &index_entry); if (ret < 0) return ret; @@ -577,7 +577,8 @@ static int prune_objects(struct osl_table *t, uint32_t *lost_bytes) NOTICE_LOG("removing unreferenced objects from data files\n"); /* first make a copy of the index */ - ret = osl_open(old_idx_filename, O_WRONLY | O_CREAT | O_EXCL, 0644); + DEBUG_LOG("opening %s\n", old_idx_filename); + ret = osl_open(old_idx_filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (ret < 0) goto out_free; fd = ret; @@ -884,8 +885,11 @@ static int fsck_init(struct osl_table_description *desc, struct osl_table **t) ret = map_table(*t, (MAP_TBL_FL_IGNORE_DIRTY)); else ret = map_table(*t, 0); - if (ret >= 0) + if (ret >= 0) { (*t)->num_rows = table_num_rows(*t); + DEBUG_LOG("index header size: %d\n", (*t)->index_header_size); + DEBUG_LOG("row index size: %d\n", (*t)->row_index_size); + } out: return ret; } @@ -1169,7 +1173,8 @@ static int check_table(char *db_dir, char *table_name) ret = dump_table(conf.dump_dir_arg, &desc); out: if (ret < 0) - ERROR_LOG("failed to check table %s\n", table_name); + ERROR_LOG("failed to check table %s: %s\n", table_name, + fsck_strerror(-ret)); else NOTICE_LOG("successfully checked table %s\n", table_name); return ret;