aboutsummaryrefslogtreecommitdiff
path: root/ubi-utils
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-01-17 12:21:40 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-01-17 12:21:40 +0200
commitd40201ebec2cc12c10874bb561fb90378d4acee9 (patch)
treef3443d4aadad1063e8e25363cba5133d16ac9cde /ubi-utils
parentf3f219527f69d581a1839e93b749c29545eb0119 (diff)
ubi-utils: update headers
Update UBI headers which requires some renameing changes. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils')
-rw-r--r--ubi-utils/src/eb_chain.c42
-rw-r--r--ubi-utils/src/libubigen.c56
-rw-r--r--ubi-utils/src/pfi2bin.c14
-rw-r--r--ubi-utils/src/ubigen.h27
-rw-r--r--ubi-utils/src/unubi.c68
-rw-r--r--ubi-utils/src/unubi_analyze.c46
6 files changed, 127 insertions, 126 deletions
diff --git a/ubi-utils/src/eb_chain.c b/ubi-utils/src/eb_chain.c
index 471efad..a018ae6 100644
--- a/ubi-utils/src/eb_chain.c
+++ b/ubi-utils/src/eb_chain.c
@@ -65,9 +65,9 @@ eb_chain_insert(struct eb_info **head, struct eb_info *new)
return 0;
}
- new_vol = ubi32_to_cpu(new->vid.vol_id);
- new_num = ubi32_to_cpu(new->vid.lnum);
- new_ver = ubi32_to_cpu(new->vid.leb_ver);
+ new_vol = __be32_to_cpu(new->vid.vol_id);
+ new_num = __be32_to_cpu(new->vid.lnum);
+ new_ver = __be32_to_cpu(new->vid.leb_ver);
/** TRAVERSE HORIZONTALY **/
@@ -75,8 +75,8 @@ eb_chain_insert(struct eb_info **head, struct eb_info *new)
prev = NULL;
/* traverse until vol_id/lnum align */
- vol = ubi32_to_cpu(cur->vid.vol_id);
- num = ubi32_to_cpu(cur->vid.lnum);
+ vol = __be32_to_cpu(cur->vid.vol_id);
+ num = __be32_to_cpu(cur->vid.lnum);
while ((new_vol > vol) || ((new_vol == vol) && (new_num > num))) {
/* insert new at end of chain */
if (cur->next == NULL) {
@@ -88,8 +88,8 @@ eb_chain_insert(struct eb_info **head, struct eb_info *new)
prev = cur;
cur = cur->next;
- vol = ubi32_to_cpu(cur->vid.vol_id);
- num = ubi32_to_cpu(cur->vid.lnum);
+ vol = __be32_to_cpu(cur->vid.vol_id);
+ num = __be32_to_cpu(cur->vid.lnum);
}
if (prev == NULL)
@@ -111,7 +111,7 @@ eb_chain_insert(struct eb_info **head, struct eb_info *new)
prev = NULL;
/* traverse until versions align */
- ver = ubi32_to_cpu(cur->vid.leb_ver);
+ ver = __be32_to_cpu(cur->vid.leb_ver);
while (new_ver < ver) {
/* insert new at bottom of history */
if (hist->older == NULL) {
@@ -124,7 +124,7 @@ eb_chain_insert(struct eb_info **head, struct eb_info *new)
prev = hist;
hist = hist->older;
- ver = ubi32_to_cpu(hist->vid.leb_ver);
+ ver = __be32_to_cpu(hist->vid.leb_ver);
}
if (prev == NULL) {
@@ -168,8 +168,8 @@ eb_chain_position(struct eb_info **head, uint32_t vol_id, uint32_t *lnum,
cur = *head;
while (cur != NULL) {
- vol = ubi32_to_cpu(cur->vid.vol_id);
- num = ubi32_to_cpu(cur->vid.lnum);
+ vol = __be32_to_cpu(cur->vid.vol_id);
+ num = __be32_to_cpu(cur->vid.lnum);
if ((vol_id == vol) && ((lnum == NULL) || (*lnum == num))) {
*pos = cur;
@@ -210,24 +210,24 @@ eb_chain_print(FILE* stream, struct eb_info *head)
struct eb_info *hist;
fprintf(stream, "%08x %-8u %08x %-4s%-4s",
- ubi32_to_cpu(cur->vid.vol_id),
- ubi32_to_cpu(cur->vid.lnum),
- ubi32_to_cpu(cur->vid.leb_ver),
+ __be32_to_cpu(cur->vid.vol_id),
+ __be32_to_cpu(cur->vid.lnum),
+ __be32_to_cpu(cur->vid.leb_ver),
cur->ec_crc_ok ? "ok":"bad",
cur->vid_crc_ok ? "ok":"bad");
if (cur->vid.vol_type == UBI_VID_STATIC)
fprintf(stream, "%-4s", cur->data_crc_ok ? "ok":"bad");
else fprintf(stream, "%-4s", cur->data_crc_ok ? "ok":"ign");
fprintf(stream, " %-4d %08x %-8u %-8llu\n", cur->phys_block,
- cur->phys_addr, ubi32_to_cpu(cur->vid.data_size),
- ubi64_to_cpu(cur->ec.ec));
+ cur->phys_addr, __be32_to_cpu(cur->vid.data_size),
+ __be64_to_cpu(cur->ec.ec));
hist = cur->older;
while (hist != NULL) {
fprintf(stream, "%08x %-8u %08x %-4s%-4s",
- ubi32_to_cpu(hist->vid.vol_id),
- ubi32_to_cpu(hist->vid.lnum),
- ubi32_to_cpu(hist->vid.leb_ver),
+ __be32_to_cpu(hist->vid.vol_id),
+ __be32_to_cpu(hist->vid.lnum),
+ __be32_to_cpu(hist->vid.leb_ver),
hist->ec_crc_ok ? "ok":"bad",
hist->vid_crc_ok ? "ok":"bad");
if (hist->vid.vol_type == UBI_VID_STATIC)
@@ -235,8 +235,8 @@ eb_chain_print(FILE* stream, struct eb_info *head)
else fprintf(stream, "%-4s", hist->data_crc_ok ? "ok":"ign");
fprintf(stream, " %-4d %08x %-8u %-8llu (*)\n",
hist->phys_block, hist->phys_addr,
- ubi32_to_cpu(hist->vid.data_size),
- ubi64_to_cpu(hist->ec.ec));
+ __be32_to_cpu(hist->vid.data_size),
+ __be64_to_cpu(hist->ec.ec));
hist = hist->older;
}
diff --git a/ubi-utils/src/libubigen.c b/ubi-utils/src/libubigen.c
index d65f055..87c8c40 100644
--- a/ubi-utils/src/libubigen.c
+++ b/ubi-utils/src/libubigen.c
@@ -78,7 +78,7 @@ validate_ubi_info(ubi_info_t u)
return EUBIGEN_INVALID_TYPE;
}
- if (ubi32_to_cpu(u->ec->vid_hdr_offset) < UBI_VID_HDR_SIZE) {
+ if (__be32_to_cpu(u->ec->vid_hdr_offset) < UBI_VID_HDR_SIZE) {
return EUBIGEN_INVALID_HDR_OFFSET;
}
@@ -142,16 +142,16 @@ add_static_info(ubi_info_t u, size_t data_size, ubigen_action_t action)
uint32_t crc = clc_crc32(crc32_table, UBI_CRC32_INIT,
u->ptr_data, data_size);
- u->v->data_size = cpu_to_ubi32(data_size);
- u->v->data_crc = cpu_to_ubi32(crc);
+ u->v->data_size = __cpu_to_be32(data_size);
+ u->v->data_crc = __cpu_to_be32(crc);
if (action & BROKEN_DATA_CRC) {
u->v->data_crc =
- cpu_to_ubi32(ubi32_to_cpu(u->v->data_crc) + 1);
+ __cpu_to_be32(__be32_to_cpu(u->v->data_crc) + 1);
}
if (action & BROKEN_DATA_SIZE) {
u->v->data_size =
- cpu_to_ubi32(ubi32_to_cpu(u->v->data_size) + 1);
+ __cpu_to_be32(__be32_to_cpu(u->v->data_size) + 1);
}
}
@@ -161,9 +161,9 @@ write_vid_hdr(ubi_info_t u, ubigen_action_t action)
uint32_t crc = clc_crc32(crc32_table, UBI_CRC32_INIT,
u->v, UBI_VID_HDR_SIZE_CRC);
/* Write VID header */
- u->v->hdr_crc = cpu_to_ubi32(crc);
+ u->v->hdr_crc = __cpu_to_be32(crc);
if (action & BROKEN_HDR_CRC) {
- u->v->hdr_crc = cpu_to_ubi32(ubi32_to_cpu(u->v->hdr_crc) + 1);
+ u->v->hdr_crc = __cpu_to_be32(__be32_to_cpu(u->v->hdr_crc) + 1);
}
memcpy(u->ptr_vid_hdr, u->v, UBI_VID_HDR_SIZE);
}
@@ -197,7 +197,7 @@ ubigen_write_leb(ubi_info_t u, ubigen_action_t action)
add_static_info(u, read, action);
}
- u->v->lnum = cpu_to_ubi32(u->blks_written);
+ u->v->lnum = __cpu_to_be32(u->blks_written);
if (action & MARK_AS_UPDATE) {
u->v->copy_flag = (u->v->copy_flag)++;
@@ -267,19 +267,19 @@ dump_info(ubi_info_t u ubi_unused)
fprintf(stderr, "ubi volume\n");
fprintf(stderr, "version : %8d\n", u->v->version);
- fprintf(stderr, "vol_id : %8d\n", ubi32_to_cpu(u->v->vol_id));
+ fprintf(stderr, "vol_id : %8d\n", __be32_to_cpu(u->v->vol_id));
fprintf(stderr, "vol_type : %8s\n",
u->v->vol_type == UBI_VID_STATIC ?
"static" : "dynamic");
fprintf(stderr, "used_ebs : %8d\n",
- ubi32_to_cpu(u->v->used_ebs));
+ __be32_to_cpu(u->v->used_ebs));
fprintf(stderr, "peb_size : 0x%08x\n", u->peb_size);
fprintf(stderr, "leb_size : 0x%08x\n", u->leb_size);
fprintf(stderr, "data_pad : 0x%08x\n",
- ubi32_to_cpu(u->v->data_pad));
+ __be32_to_cpu(u->v->data_pad));
fprintf(stderr, "leb_total : %8d\n", u->leb_total);
fprintf(stderr, "header offs : 0x%08x\n",
- ubi32_to_cpu(u->ec->vid_hdr_offset));
+ __be32_to_cpu(u->ec->vid_hdr_offset));
fprintf(stderr, "bytes_total : %8d\n", u->bytes_total);
fprintf(stderr, " + in MiB : %8.2f M\n",
((float)(u->bytes_total)) / 1024 / 1024);
@@ -372,31 +372,31 @@ ubigen_create(ubi_info_t* u, uint32_t vol_id, uint8_t vol_type,
res->fp_out = fp_out;
/* vid hdr data which doesn't change */
- res->v->magic = cpu_to_ubi32(UBI_VID_HDR_MAGIC);
+ res->v->magic = __cpu_to_be32(UBI_VID_HDR_MAGIC);
res->v->version = version ? version : UBI_VERSION;
res->v->vol_type = vol_type;
- res->v->vol_id = cpu_to_ubi32(vol_id);
+ res->v->vol_id = __cpu_to_be32(vol_id);
res->v->compat = compat_flag;
- res->v->data_pad = cpu_to_ubi32(res->data_pad);
+ res->v->data_pad = __cpu_to_be32(res->data_pad);
/* static only: used_ebs */
if (res->v->vol_type == UBI_VID_STATIC) {
- res->v->used_ebs = cpu_to_ubi32(byte_to_blk
+ res->v->used_ebs = __cpu_to_be32(byte_to_blk
(res->bytes_total,
res->leb_size));
}
/* ec hdr (fixed, doesn't change) */
- res->ec->magic = cpu_to_ubi32(UBI_EC_HDR_MAGIC);
+ res->ec->magic = __cpu_to_be32(UBI_EC_HDR_MAGIC);
res->ec->version = version ? version : UBI_VERSION;
- res->ec->ec = cpu_to_ubi64(ec);
- res->ec->vid_hdr_offset = cpu_to_ubi32(vid_hdr_offset);
+ res->ec->ec = __cpu_to_be64(ec);
+ res->ec->vid_hdr_offset = __cpu_to_be32(vid_hdr_offset);
- res->ec->data_offset = cpu_to_ubi32(data_offset);
+ res->ec->data_offset = __cpu_to_be32(data_offset);
crc = clc_crc32(crc32_table, UBI_CRC32_INIT, res->ec,
UBI_EC_HDR_SIZE_CRC);
- res->ec->hdr_crc = cpu_to_ubi32(crc);
+ res->ec->hdr_crc = __cpu_to_be32(crc);
/* prepare a read buffer */
res->buf = (uint8_t*) malloc (res->peb_size * sizeof(uint8_t));
@@ -407,8 +407,8 @@ ubigen_create(ubi_info_t* u, uint32_t vol_id, uint8_t vol_type,
/* point to distinct regions within the buffer */
res->ptr_ec_hdr = res->buf;
- res->ptr_vid_hdr = res->buf + ubi32_to_cpu(res->ec->vid_hdr_offset);
- res->ptr_data = res->buf + ubi32_to_cpu(res->ec->vid_hdr_offset)
+ res->ptr_vid_hdr = res->buf + __be32_to_cpu(res->ec->vid_hdr_offset);
+ res->ptr_data = res->buf + __be32_to_cpu(res->ec->vid_hdr_offset)
+ UBI_VID_HDR_SIZE;
rc = validate_ubi_info(res);
@@ -458,7 +458,7 @@ ubigen_get_leb_total(ubi_info_t u, size_t* total)
int
ubigen_set_lvol_rec(ubi_info_t u, size_t reserved_bytes,
- const char* vol_name, struct ubi_vol_tbl_record *lvol_rec)
+ const char* vol_name, struct ubi_vtbl_record *lvol_rec)
{
uint32_t crc;
@@ -468,19 +468,19 @@ ubigen_set_lvol_rec(ubi_info_t u, size_t reserved_bytes,
memset(lvol_rec, 0x0, UBI_VTBL_RECORD_SIZE);
lvol_rec->reserved_pebs =
- cpu_to_ubi32(byte_to_blk(reserved_bytes, u->leb_size));
- lvol_rec->alignment = cpu_to_ubi32(u->alignment);
+ __cpu_to_be32(byte_to_blk(reserved_bytes, u->leb_size));
+ lvol_rec->alignment = __cpu_to_be32(u->alignment);
lvol_rec->data_pad = u->v->data_pad;
lvol_rec->vol_type = u->v->vol_type;
lvol_rec->name_len =
- cpu_to_ubi16((uint16_t)strlen((const char*)vol_name));
+ __cpu_to_be16((uint16_t)strlen((const char*)vol_name));
memcpy(lvol_rec->name, vol_name, UBI_VOL_NAME_MAX + 1);
crc = clc_crc32(crc32_table, UBI_CRC32_INIT,
lvol_rec, UBI_VTBL_RECORD_SIZE_CRC);
- lvol_rec->crc = cpu_to_ubi32(crc);
+ lvol_rec->crc = __cpu_to_be32(crc);
return 0;
}
diff --git a/ubi-utils/src/pfi2bin.c b/ubi-utils/src/pfi2bin.c
index 35af86c..7f31938 100644
--- a/ubi-utils/src/pfi2bin.c
+++ b/ubi-utils/src/pfi2bin.c
@@ -238,7 +238,7 @@ err:
static int
convert_ubi_volume(pfi_ubi_t ubi, pdd_data_t pdd, list_t raw_pebs,
- struct ubi_vol_tbl_record *vol_tab,
+ struct ubi_vtbl_record *vol_tab,
size_t *ebs_written, io_t io)
{
int rc = 0;
@@ -336,7 +336,7 @@ my_fmemopen (void *buf, size_t size, const char *opentype)
*/
static int
write_ubi_volume_table(pdd_data_t pdd, list_t raw_pebs,
- struct ubi_vol_tbl_record *vol_tab, size_t vol_tab_size,
+ struct ubi_vtbl_record *vol_tab, size_t vol_tab_size,
size_t *ebs_written, io_t io)
{
int rc = 0;
@@ -478,15 +478,15 @@ err:
}
static int
-init_vol_tab(struct ubi_vol_tbl_record **vol_tab, size_t *vol_tab_size)
+init_vol_tab(struct ubi_vtbl_record **vol_tab, size_t *vol_tab_size)
{
uint32_t crc;
size_t i;
- struct ubi_vol_tbl_record* res = NULL;
+ struct ubi_vtbl_record* res = NULL;
*vol_tab_size = UBI_MAX_VOLUMES * UBI_VTBL_RECORD_SIZE;
- res = (struct ubi_vol_tbl_record*) calloc(1, *vol_tab_size);
+ res = (struct ubi_vtbl_record*) calloc(1, *vol_tab_size);
if (vol_tab == NULL) {
return -ENOMEM;
}
@@ -494,7 +494,7 @@ init_vol_tab(struct ubi_vol_tbl_record **vol_tab, size_t *vol_tab_size)
for (i = 0; i < UBI_MAX_VOLUMES; i++) {
crc = clc_crc32(crc32_table, UBI_CRC32_INIT,
&(res[i]), UBI_VTBL_RECORD_SIZE_CRC);
- res[i].crc = cpu_to_ubi32(crc);
+ res[i].crc = __cpu_to_be32(crc);
}
*vol_tab = res;
@@ -513,7 +513,7 @@ create_raw(io_t io)
list_t pfi_ubis = mk_empty(); /* list of ubi sections from a pfi */
list_t raw_pebs = mk_empty(); /* list of raw eraseblocks */
- struct ubi_vol_tbl_record *vol_tab = NULL;
+ struct ubi_vtbl_record *vol_tab = NULL;
pdd_data_t pdd = NULL;
rc = init_vol_tab (&vol_tab, &vol_tab_size);
diff --git a/ubi-utils/src/ubigen.h b/ubi-utils/src/ubigen.h
index 9e9e8ec..bf4b384 100644
--- a/ubi-utils/src/ubigen.h
+++ b/ubi-utils/src/ubigen.h
@@ -1,5 +1,3 @@
-#ifndef __UBIGEN_H__
-#define __UBIGEN_H__
/*
* Copyright (c) International Business Machines Corp., 2006
*
@@ -22,23 +20,26 @@
* An utility to update UBI volumes.
*/
-#include <stdio.h> /* FILE */
+#ifndef __UBIGEN_H__
+#define __UBIGEN_H__
+
+#include <stdio.h>
#include <stdint.h>
#include <mtd/ubi-header.h>
+#include <asm/byteorder.h>
#ifdef __cplusplus
extern "C" {
#endif
-#define DEFAULT_BLOCKSIZE (128 * 1024)
-#define DEFAULT_PAGESIZE (2*1024)
-
-#define EUBIGEN_INVALID_TYPE 1
-#define EUBIGEN_INVALID_HDR_OFFSET 2
-#define EUBIGEN_INVALID_ALIGNMENT 3
-#define EUBIGEN_TOO_SMALL_EB 4
-#define EUBIGEN_MAX_ERROR 5
+#define DEFAULT_BLOCKSIZE (128 * 1024)
+#define DEFAULT_PAGESIZE (2*1024)
+#define EUBIGEN_INVALID_TYPE 1
+#define EUBIGEN_INVALID_HDR_OFFSET 2
+#define EUBIGEN_INVALID_ALIGNMENT 3
+#define EUBIGEN_TOO_SMALL_EB 4
+#define EUBIGEN_MAX_ERROR 5
typedef enum action {
NO_ERROR = 0x00000000,
@@ -140,10 +141,10 @@ int ubigen_write_broken_update(ubi_info_t u, uint32_t blk);
* else Error.
*/
int ubigen_set_lvol_rec(ubi_info_t u, size_t reserved_bytes,
- const char* name, struct ubi_vol_tbl_record *lvol_rec);
+ const char* name, struct ubi_vtbl_record *lvol_rec);
#ifdef __cplusplus
}
#endif
-#endif /* __UBIGEN_H__ */
+#endif /* !__UBIGEN_H__ */
diff --git a/ubi-utils/src/unubi.c b/ubi-utils/src/unubi.c
index a50eff6..5c1d324 100644
--- a/ubi-utils/src/unubi.c
+++ b/ubi-utils/src/unubi.c
@@ -414,7 +414,7 @@ extract_itable(FILE *fpin, struct eb_info *cur, size_t bsize, size_t num,
size_t i, max;
fpos_t temp;
FILE* fpout = NULL;
- struct ubi_vol_tbl_record rec;
+ struct ubi_vtbl_record rec;
if (fpin == NULL || cur == NULL || path == NULL)
return -2;
@@ -428,10 +428,10 @@ extract_itable(FILE *fpin, struct eb_info *cur, size_t bsize, size_t num,
fsetpos(fpin, &cur->eb_top);
if (rc < 0)
return -1;
- fseek(fpin, ubi32_to_cpu(cur->ec.data_offset), SEEK_CUR);
+ fseek(fpin, __be32_to_cpu(cur->ec.data_offset), SEEK_CUR);
/* prepare output file */
- if (ubi32_to_cpu(cur->vid.vol_id) != UBI_LAYOUT_VOL_ID)
+ if (__be32_to_cpu(cur->vid.vol_id) != UBI_LAYOUT_VOL_ID)
return -2;
memset(filename, 0, MAXPATH + 1);
snprintf(filename, MAXPATH, FN_VITBL, path, num);
@@ -442,7 +442,7 @@ extract_itable(FILE *fpin, struct eb_info *cur, size_t bsize, size_t num,
/* loop through entries */
fprintf(fpout,
"index\trpebs\talign\ttype\tcrc\t\tname\n");
- max = bsize - ubi32_to_cpu(cur->ec.data_offset);
+ max = bsize - __be32_to_cpu(cur->ec.data_offset);
for (i = 0; i < (max / sizeof(rec)); i++) {
int blank = 1;
char *ptr, *base;
@@ -464,7 +464,7 @@ extract_itable(FILE *fpin, struct eb_info *cur, size_t bsize, size_t num,
/* check crc */
crc = clc_crc32(crc32_table, UBI_CRC32_INIT, &rec,
UBI_VTBL_RECORD_SIZE_CRC);
- if (crc != ubi32_to_cpu(rec.crc))
+ if (crc != __be32_to_cpu(rec.crc))
continue;
/* check for empty */
@@ -487,16 +487,16 @@ extract_itable(FILE *fpin, struct eb_info *cur, size_t bsize, size_t num,
type = "static\0";
/* prep name string */
- rec.name[ubi16_to_cpu(rec.name_len)] = '\0';
+ rec.name[__be16_to_cpu(rec.name_len)] = '\0';
sprintf(name, "%s", rec.name);
/* print record line to fpout */
fprintf(fpout, "%u\t%u\t%u\t%s\t0x%08x\t%s\n",
i,
- ubi32_to_cpu(rec.reserved_pebs),
- ubi32_to_cpu(rec.alignment),
+ __be32_to_cpu(rec.reserved_pebs),
+ __be32_to_cpu(rec.alignment),
type,
- ubi32_to_cpu(rec.crc),
+ __be32_to_cpu(rec.crc),
name);
}
@@ -534,7 +534,7 @@ rebuild_volume(FILE * fpin, uint32_t *vol_id, struct eb_info **head,
/* when vol_id is null, then do all */
if (vol_id == NULL) {
cur = *head;
- vol = ubi32_to_cpu(cur->vid.vol_id);
+ vol = __be32_to_cpu(cur->vid.vol_id);
} else {
vol = *vol_id;
eb_chain_position(head, vol, NULL, &cur);
@@ -556,7 +556,7 @@ rebuild_volume(FILE * fpin, uint32_t *vol_id, struct eb_info **head,
while (cur != NULL) {
size_t i;
- if (ubi32_to_cpu(cur->vid.vol_id) != vol) {
+ if (__be32_to_cpu(cur->vid.vol_id) != vol) {
/* close out file */
fclose(fpout);
@@ -565,7 +565,7 @@ rebuild_volume(FILE * fpin, uint32_t *vol_id, struct eb_info **head,
goto out;
/* begin with next */
- vol = ubi32_to_cpu(cur->vid.vol_id);
+ vol = __be32_to_cpu(cur->vid.vol_id);
num = 0;
snprintf(filename, MAXPATH, FN_VOLWH, path, vol);
fpout = fopen(filename, "wb");
@@ -576,7 +576,7 @@ rebuild_volume(FILE * fpin, uint32_t *vol_id, struct eb_info **head,
}
}
- while (num < ubi32_to_cpu(cur->vid.lnum)) {
+ while (num < __be32_to_cpu(cur->vid.lnum)) {
/* FIXME haver: I hope an empty block is
written out so that the binary has no holes
... */
@@ -589,13 +589,13 @@ rebuild_volume(FILE * fpin, uint32_t *vol_id, struct eb_info **head,
rc = fsetpos(fpin, &(cur->eb_top));
if (rc < 0)
goto out;
- fseek(fpin, ubi32_to_cpu(cur->ec.data_offset), SEEK_CUR);
+ fseek(fpin, __be32_to_cpu(cur->ec.data_offset), SEEK_CUR);
if (cur->vid.vol_type == UBI_VID_DYNAMIC)
/* FIXME It might be that alignment has influence */
data_size = block_size - header_size;
else
- data_size = ubi32_to_cpu(cur->vid.data_size);
+ data_size = __be32_to_cpu(cur->vid.data_size);
for (i = 0; i < data_size; i++) {
int c = fgetc(fpin);
@@ -683,7 +683,7 @@ unubi_volumes(FILE* fpin, uint32_t *vols, size_t vc, struct args *a)
}
/* check erasecounter header magic */
- if (ubi32_to_cpu(cur->ec.magic) != UBI_EC_HDR_MAGIC) {
+ if (__be32_to_cpu(cur->ec.magic) != UBI_EC_HDR_MAGIC) {
snprintf(reason, MAXPATH, ".invalid.ec_magic");
goto invalid;
}
@@ -691,7 +691,7 @@ unubi_volumes(FILE* fpin, uint32_t *vols, size_t vc, struct args *a)
/* check erasecounter header crc */
crc = clc_crc32(crc32_table, UBI_CRC32_INIT, &(cur->ec),
UBI_EC_HDR_SIZE_CRC);
- if (ubi32_to_cpu(cur->ec.hdr_crc) != crc) {
+ if (__be32_to_cpu(cur->ec.hdr_crc) != crc) {
snprintf(reason, MAXPATH, ".invalid.ec_hdr_crc");
goto invalid;
}
@@ -700,7 +700,7 @@ unubi_volumes(FILE* fpin, uint32_t *vols, size_t vc, struct args *a)
rc = fsetpos(fpin, &(cur->eb_top));
if (rc != 0)
goto err;
- fseek(fpin, ubi32_to_cpu(cur->ec.vid_hdr_offset), SEEK_CUR);
+ fseek(fpin, __be32_to_cpu(cur->ec.vid_hdr_offset), SEEK_CUR);
rc = fread(&cur->vid, 1, sizeof(cur->vid), fpin);
if (rc == 0)
goto out; /* EOF */
@@ -712,14 +712,14 @@ unubi_volumes(FILE* fpin, uint32_t *vols, size_t vc, struct args *a)
/* if the magic number is 0xFFFFFFFF, then it's very likely
* that the volume is empty */
- if (ubi32_to_cpu(cur->vid.magic) == 0xffffffff) {
+ if (__be32_to_cpu(cur->vid.magic) == 0xffffffff) {
snprintf(reason, MAXPATH, ".empty");
goto invalid;
}
/* vol_id should be in bounds */
- if ((ubi32_to_cpu(cur->vid.vol_id) >= UBI_MAX_VOLUMES) &&
- (ubi32_to_cpu(cur->vid.vol_id) <
+ if ((__be32_to_cpu(cur->vid.vol_id) >= UBI_MAX_VOLUMES) &&
+ (__be32_to_cpu(cur->vid.vol_id) <
UBI_INTERNAL_VOL_START)) {
snprintf(reason, MAXPATH, ".invalid");
goto invalid;
@@ -727,7 +727,7 @@ unubi_volumes(FILE* fpin, uint32_t *vols, size_t vc, struct args *a)
raw_path = FN_NSURE;
/* check volume id header magic */
- if (ubi32_to_cpu(cur->vid.magic) != UBI_VID_HDR_MAGIC) {
+ if (__be32_to_cpu(cur->vid.magic) != UBI_VID_HDR_MAGIC) {
snprintf(reason, MAXPATH, ".invalid.vid_magic");
goto invalid;
}
@@ -736,7 +736,7 @@ unubi_volumes(FILE* fpin, uint32_t *vols, size_t vc, struct args *a)
/* check volume id header crc */
crc = clc_crc32(crc32_table, UBI_CRC32_INIT, &(cur->vid),
UBI_VID_HDR_SIZE_CRC);
- if (ubi32_to_cpu(cur->vid.hdr_crc) != crc) {
+ if (__be32_to_cpu(cur->vid.hdr_crc) != crc) {
snprintf(reason, MAXPATH, ".invalid.vid_hdr_crc");
goto invalid;
}
@@ -744,11 +744,11 @@ unubi_volumes(FILE* fpin, uint32_t *vols, size_t vc, struct args *a)
/* check data crc, but only for a static volume */
if (cur->vid.vol_type == UBI_VID_STATIC) {
- rc = data_crc(fpin, ubi32_to_cpu(cur->vid.data_size),
+ rc = data_crc(fpin, __be32_to_cpu(cur->vid.data_size),
&crc);
if (rc < 0)
goto err;
- if (ubi32_to_cpu(cur->vid.data_crc) != crc) {
+ if (__be32_to_cpu(cur->vid.data_crc) != crc) {
snprintf(reason, MAXPATH, ".invalid.data_crc");
goto invalid;
}
@@ -771,7 +771,7 @@ unubi_volumes(FILE* fpin, uint32_t *vols, size_t vc, struct args *a)
/* extract info-table */
if (a->itable &&
- (ubi32_to_cpu(cur->vid.vol_id) == UBI_LAYOUT_VOL_ID)) {
+ (__be32_to_cpu(cur->vid.vol_id) == UBI_LAYOUT_VOL_ID)) {
extract_itable(fpin, cur, a->bsize,
itable_num, a->odir_path);
itable_num++;
@@ -799,10 +799,10 @@ unubi_volumes(FILE* fpin, uint32_t *vols, size_t vc, struct args *a)
always right ... */
size = a->bsize - a->hsize;
} else
- size = ubi32_to_cpu(cur->vid.data_size);
+ size = __be32_to_cpu(cur->vid.data_size);
fseek(fpin,
- ubi32_to_cpu(cur->ec.data_offset),
+ __be32_to_cpu(cur->ec.data_offset),
SEEK_CUR);
}
else if (a->vol_split == SPLIT_RAW)
@@ -811,9 +811,9 @@ unubi_volumes(FILE* fpin, uint32_t *vols, size_t vc, struct args *a)
snprintf(filename, MAXPATH, FN_VOLSP,
a->odir_path,
- ubi32_to_cpu(cur->vid.vol_id),
- ubi32_to_cpu(cur->vid.lnum),
- ubi32_to_cpu(cur->vid.leb_ver), count);
+ __be32_to_cpu(cur->vid.vol_id),
+ __be32_to_cpu(cur->vid.lnum),
+ __be32_to_cpu(cur->vid.leb_ver), count);
rc = extract_data(fpin, size, filename);
if (rc < 0)
goto err;
@@ -834,9 +834,9 @@ unubi_volumes(FILE* fpin, uint32_t *vols, size_t vc, struct args *a)
snprintf(filename, MAXPATH, raw_path,
a->odir_path,
count,
- ubi32_to_cpu(cur->vid.vol_id),
- ubi32_to_cpu(cur->vid.lnum),
- ubi32_to_cpu(cur->vid.leb_ver),
+ __be32_to_cpu(cur->vid.vol_id),
+ __be32_to_cpu(cur->vid.lnum),
+ __be32_to_cpu(cur->vid.leb_ver),
reason);
rc = extract_data(fpin, a->bsize, filename);
diff --git a/ubi-utils/src/unubi_analyze.c b/ubi-utils/src/unubi_analyze.c
index c2fbe47..2ab3b87 100644
--- a/ubi-utils/src/unubi_analyze.c
+++ b/ubi-utils/src/unubi_analyze.c
@@ -151,7 +151,7 @@ unubi_analyze_ec_hdr(struct eb_info *first, const char *path)
count = 0;
cur = first;
while (cur != NULL) {
- erase_counts[count] = ubi64_to_cpu(cur->ec.ec);
+ erase_counts[count] = __be64_to_cpu(cur->ec.ec);
cur = cur->next;
count++;
}
@@ -167,21 +167,21 @@ unubi_analyze_ec_hdr(struct eb_info *first, const char *path)
crc = clc_crc32(crc32_table, UBI_CRC32_INIT, &cur->ec,
UBI_EC_HDR_SIZE_CRC);
- if ((ubi32_to_cpu(cur->ec.magic) != UBI_EC_HDR_MAGIC) ||
- (crc != ubi32_to_cpu(cur->ec.hdr_crc)))
+ if ((__be32_to_cpu(cur->ec.magic) != UBI_EC_HDR_MAGIC) ||
+ (crc != __be32_to_cpu(cur->ec.hdr_crc)))
fprintf(fpdata, "# ");
fprintf(fpdata, "%u %llu %llu", count,
- ubi64_to_cpu(cur->ec.ec),
+ __be64_to_cpu(cur->ec.ec),
erase_counts[count]);
- if (ubi32_to_cpu(cur->ec.magic) != UBI_EC_HDR_MAGIC)
+ if (__be32_to_cpu(cur->ec.magic) != UBI_EC_HDR_MAGIC)
fprintf(fpdata, " ## bad magic: %08x",
- ubi32_to_cpu(cur->ec.magic));
+ __be32_to_cpu(cur->ec.magic));
- if (crc != ubi32_to_cpu(cur->ec.hdr_crc))
+ if (crc != __be32_to_cpu(cur->ec.hdr_crc))
fprintf(fpdata, " ## CRC mismatch: given=%08x, "
- "calc=%08x", ubi32_to_cpu(cur->ec.hdr_crc),
+ "calc=%08x", __be32_to_cpu(cur->ec.hdr_crc),
crc);
fprintf(fpdata, "\n");
@@ -303,8 +303,8 @@ unubi_analyze_vid_hdr(struct eb_info **head, const char *path)
count = 0;
cur = *head;
while (cur != NULL) {
- leb_versions[count] = ubi32_to_cpu(cur->vid.leb_ver);
- data_sizes[count] = ubi32_to_cpu(cur->vid.data_size);
+ leb_versions[count] = __be32_to_cpu(cur->vid.leb_ver);
+ data_sizes[count] = __be32_to_cpu(cur->vid.data_size);
cur = cur->next;
count++;
}
@@ -317,9 +317,9 @@ unubi_analyze_vid_hdr(struct eb_info **head, const char *path)
fprintf(fpdata, "# x_axis vol_id lnum y1_axis leb_ver "
"y2_axis data_size\n");
while (cur != NULL) {
- y1 = norm_index(ubi32_to_cpu(cur->vid.leb_ver), leb_versions,
+ y1 = norm_index(__be32_to_cpu(cur->vid.leb_ver), leb_versions,
breadth);
- y2 = norm_index(ubi32_to_cpu(cur->vid.data_size), data_sizes,
+ y2 = norm_index(__be32_to_cpu(cur->vid.data_size), data_sizes,
breadth);
if ((y1 == -1) || (y2 == -1)) {
@@ -329,12 +329,12 @@ unubi_analyze_vid_hdr(struct eb_info **head, const char *path)
fprintf(fpdata, "%u %u %u %u %u %u %u\n",
count,
- ubi32_to_cpu(cur->vid.vol_id),
- ubi32_to_cpu(cur->vid.lnum),
+ __be32_to_cpu(cur->vid.vol_id),
+ __be32_to_cpu(cur->vid.lnum),
y1,
- ubi32_to_cpu(cur->vid.leb_ver),
+ __be32_to_cpu(cur->vid.leb_ver),
y2,
- ubi32_to_cpu(cur->vid.data_size));
+ __be32_to_cpu(cur->vid.data_size));
cur = cur->next;
count++;
}
@@ -350,13 +350,13 @@ unubi_analyze_vid_hdr(struct eb_info **head, const char *path)
while (cur != NULL) {
if (count > 0)
fprintf(fpplot, ", ");
- if (step != ubi32_to_cpu(cur->vid.vol_id)) {
- step = ubi32_to_cpu(cur->vid.vol_id);
+ if (step != __be32_to_cpu(cur->vid.vol_id)) {
+ step = __be32_to_cpu(cur->vid.vol_id);
fprintf(fpplot, "\"%d\" %d 0", step, count);
}
else
fprintf(fpplot, "\"%d\" %d 1",
- ubi32_to_cpu(cur->vid.lnum), count);
+ __be32_to_cpu(cur->vid.lnum), count);
cur = cur->next;
count++;
}
@@ -369,7 +369,7 @@ unubi_analyze_vid_hdr(struct eb_info **head, const char *path)
fprintf(fpplot, "set ylabel \"leb version\"\n");
fprintf(fpplot, "set ytics (");
while (cur->next != NULL) {
- y1 = norm_index(ubi32_to_cpu(cur->vid.leb_ver), leb_versions,
+ y1 = norm_index(__be32_to_cpu(cur->vid.leb_ver), leb_versions,
breadth);
if (y1 == -1) {
@@ -380,7 +380,7 @@ unubi_analyze_vid_hdr(struct eb_info **head, const char *path)
if (count > 0)
fprintf(fpplot, ", ");
- fprintf(fpplot, "\"%u\" %u", ubi32_to_cpu(cur->vid.leb_ver),
+ fprintf(fpplot, "\"%u\" %u", __be32_to_cpu(cur->vid.leb_ver),
y1);
cur = cur->next;
@@ -394,7 +394,7 @@ unubi_analyze_vid_hdr(struct eb_info **head, const char *path)
fprintf(fpplot, "set y2label \"data size\"\n");
fprintf(fpplot, "set y2tics (");
while (cur != NULL) {
- y2 = norm_index(ubi32_to_cpu(cur->vid.data_size),
+ y2 = norm_index(__be32_to_cpu(cur->vid.data_size),
data_sizes, breadth);
if (y2 == -1) {
@@ -405,7 +405,7 @@ unubi_analyze_vid_hdr(struct eb_info **head, const char *path)
if (count > 0)
fprintf(fpplot, ", ");
- fprintf(fpplot, "\"%u\" %u", ubi32_to_cpu(cur->vid.data_size),
+ fprintf(fpplot, "\"%u\" %u", __be32_to_cpu(cur->vid.data_size),
y2);
cur = cur->next;