summaryrefslogtreecommitdiff
path: root/ubi-utils/src/unubi_analyze.c
diff options
context:
space:
mode:
authorFrank Haverkamp <haver@vnet.ibm.com>2007-11-24 11:04:51 +0100
committerFrank Haverkamp <haver@vnet.ibm.com>2007-11-24 11:04:51 +0100
commit26c965bc654d67881fc54f4b24a552600752dadd (patch)
treeec8033e92872dd7a594063a893bd6cd4b708e0c4 /ubi-utils/src/unubi_analyze.c
parent0d2d0f43b9aa9b08f610169b412fd24a15dea154 (diff)
ubi-utils: various fixes in unubi
The extraction of data from blocks used for dynamic volumes was totally broken. The data size was calculated wrong. This fix is not perfect, the alignment is still ignored. The parameter "header-size" is very misleading. It does not reflect the vid hdr offset properly. I assume therefor that it only works for the layout I am using where the vid hdr is at the _end_ of the 1st NAND page (2048). I added the generation of a textfile with information about the blocks which are going into the internal graph representation. Instead of a graph I think that a simple array will simplify the code very much. The array must than be sorted properly to cope with older and newer block-copies but that should not be a problem. discussed the tool with my coleage Andreas Arnez and we found that it might be a good idea to replace it even with a perl program for the same purpose since that would offer the flexibility to change it on the fly when needed. The tool is mainly used for crash analysis so it could be an advantage to change it without needing a C-compiler. Signed-off-by: Frank Haverkamp <haver@vnet.ibm.com>
Diffstat (limited to 'ubi-utils/src/unubi_analyze.c')
-rw-r--r--ubi-utils/src/unubi_analyze.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/ubi-utils/src/unubi_analyze.c b/ubi-utils/src/unubi_analyze.c
index e5bbb23..c2fbe47 100644
--- a/ubi-utils/src/unubi_analyze.c
+++ b/ubi-utils/src/unubi_analyze.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) International Business Machines Corp., 2006
+ * Copyright (c) International Business Machines Corp., 2006, 2007
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -32,22 +32,15 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include "eb_chain.h"
+#include "unubi_analyze.h"
#include "crc32.h"
-#define MAXPATH 1024
#define EC_X_INT 50
-#define FN_STATS "analysis_stats.txt"
-#define FN_EH_DATA "analysis_ec_hdr.data"
-#define FN_EH_PLOT "analysis_ec_hdr.plot"
-#define FN_VH_DATA "analysis_vid_hdr.data"
-#define FN_VH_PLOT "analysis_vid_hdr.plot"
-
-
/**
* intcmp - function needed by qsort to order integers
**/
@@ -103,15 +96,15 @@ norm_index(uint32_t item, uint32_t *array, size_t length)
* display of the data file;
**/
int
-unubi_analyze_ec_hdr(eb_info_t first, const char *path)
+unubi_analyze_ec_hdr(struct eb_info *first, const char *path)
{
- char filename[MAXPATH + 1];
+ char filename[PATH_MAX + 1];
size_t count, eraseblocks;
uint32_t crc, crc32_table[256];
uint64_t *erase_counts;
FILE* fpdata;
FILE* fpplot;
- eb_info_t cur;
+ struct eb_info *cur;
if (first == NULL)
return -1;
@@ -120,14 +113,14 @@ unubi_analyze_ec_hdr(eb_info_t first, const char *path)
init_crc32_table(crc32_table);
/* prepare output files */
- memset(filename, 0, MAXPATH + 1);
- snprintf(filename, MAXPATH, "%s/%s", path, FN_EH_DATA);
+ memset(filename, 0, PATH_MAX + 1);
+ snprintf(filename, PATH_MAX, "%s/%s", path, FN_EH_DATA);
fpdata = fopen(filename, "w");
if (fpdata == NULL)
return -1;
- memset(filename, 0, MAXPATH + 1);
- snprintf(filename, MAXPATH, "%s/%s", path, FN_EH_PLOT);
+ memset(filename, 0, PATH_MAX + 1);
+ snprintf(filename, PATH_MAX, "%s/%s", path, FN_EH_PLOT);
fpplot = fopen(filename, "w");
if (fpplot == NULL) {
fclose(fpdata);
@@ -147,6 +140,11 @@ unubi_analyze_ec_hdr(eb_info_t first, const char *path)
eraseblocks = count;
erase_counts = malloc(eraseblocks * sizeof(*erase_counts));
+ if (!erase_counts) {
+ perror("out of memory");
+ exit(EXIT_FAILURE);
+ }
+
memset(erase_counts, 0, eraseblocks * sizeof(*erase_counts));
/* second run: populate array to sort */
@@ -239,15 +237,15 @@ unubi_analyze_ec_hdr(eb_info_t first, const char *path)
* display of the data file;
**/
int
-unubi_analyze_vid_hdr(eb_info_t *head, const char *path)
+unubi_analyze_vid_hdr(struct eb_info **head, const char *path)
{
- char filename[MAXPATH + 1];
+ char filename[PATH_MAX + 1];
int rc, y1, y2;
size_t count, step, breadth;
uint32_t *leb_versions, *data_sizes;
FILE* fpdata;
FILE* fpplot;
- eb_info_t cur;
+ struct eb_info *cur;
if (head == NULL || *head == NULL)
return -1;
@@ -259,16 +257,16 @@ unubi_analyze_vid_hdr(eb_info_t *head, const char *path)
leb_versions = NULL;
/* prepare output files */
- memset(filename, 0, MAXPATH + 1);
- snprintf(filename, MAXPATH, "%s/%s", path, FN_VH_DATA);
+ memset(filename, 0, PATH_MAX + 1);
+ snprintf(filename, PATH_MAX, "%s/%s", path, FN_VH_DATA);
fpdata = fopen(filename, "w");
if (fpdata == NULL) {
rc = -1;
goto exit;
}
- memset(filename, 0, MAXPATH + 1);
- snprintf(filename, MAXPATH, "%s/%s", path, FN_VH_PLOT);
+ memset(filename, 0, PATH_MAX + 1);
+ snprintf(filename, PATH_MAX, "%s/%s", path, FN_VH_PLOT);
fpplot = fopen(filename, "w");
if (fpplot == NULL) {
rc = -1;
@@ -448,7 +446,7 @@ unubi_analyze_vid_hdr(eb_info_t *head, const char *path)
* returns 0 upon successful completion, or -1 otherwise
**/
int
-unubi_analyze(eb_info_t *head, eb_info_t first, const char *path)
+unubi_analyze(struct eb_info **head, struct eb_info *first, const char *path)
{
int ec_rc, vid_rc;