]> www.infradead.org Git - mtd-utils.git/commitdiff
ubi-utils: some renames
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sat, 22 Dec 2007 16:02:43 +0000 (18:02 +0200)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sat, 22 Dec 2007 16:02:43 +0000 (18:02 +0200)
Since there is often confusion what "eb" is - physical or logical
eraseblock. Fix libubi and change "eb" to "leb".

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/inc/libubi.h
ubi-utils/src/libubi.c
ubi-utils/src/libubigen.c
ubi-utils/src/peb.c
ubi-utils/src/ubimkvol.c
ubi-utils/src/ubinfo.c
ubi-utils/src/ubiupdate.c

index 21be68a0f3f7de8523e7089a862e350b76fdc480..b83f6c6f6e59686ef59b91fc3e0815c9d0f4e850 100644 (file)
@@ -82,13 +82,13 @@ struct ubi_info
  * @highest_vol_num: highest volume number
  * @major: major number of corresponding character device
  * @minor: minor number of corresponding character device
- * @total_ebs: total number of logical eraseblocks on this UBI device
- * @avail_ebs: how many logical eraseblocks are not used and available for new
+ * @total_lebs: total number of logical eraseblocks on this UBI device
+ * @avail_lebs: how many logical eraseblocks are not used and available for new
  *             volumes
- * @total_bytes: @total_ebs * @eb_size
- * @avail_bytes: @avail_ebs * @eb_size
+ * @total_bytes: @total_lebs * @leb_size
+ * @avail_bytes: @avail_lebs * @leb_size
  * @bad_count: count of bad physical eraseblocks
- * @eb_size: logical eraseblock size
+ * @leb_size: logical eraseblock size
  * @max_ec: current highest erase counter value
  * @bad_rsvd: how many physical eraseblocks of the underlying flash device are
  *            reserved for bad eraseblocks handling
@@ -103,12 +103,12 @@ struct ubi_dev_info
        int highest_vol_num;
        int major;
        int minor;
-       int total_ebs;
-       int avail_ebs;
+       int total_lebs;
+       int avail_lebs;
        long long total_bytes;
        long long avail_bytes;
        int bad_count;
-       int eb_size;
+       int leb_size;
        long long max_ec;
        int bad_rsvd;
        int max_vol_count;
@@ -128,8 +128,8 @@ struct ubi_dev_info
  * @data_bytes: how many data bytes are stored on this volume (equivalent to
  *              @rsvd_bytes for dynamic volumes)
  * @rsvd_bytes: how many bytes are reserved for this volume
- * @rsvd_ebs: how many logical eraseblocks are reserved for this volume
- * @eb_size: logical eraseblock size of this volume (may be less then
+ * @rsvd_lebs: how many logical eraseblocks are reserved for this volume
+ * @leb_size: logical eraseblock size of this volume (may be less then
  *           device's logical eraseblock size due to alignment)
  * @corrupted: non-zero if the volume is corrupted
  * @name: volume name (null-terminated)
@@ -146,8 +146,8 @@ struct ubi_vol_info
        int alignment;
        long long data_bytes;
        long long rsvd_bytes;
-       int rsvd_ebs;
-       int eb_size;
+       int rsvd_lebs;
+       int leb_size;
        int corrupted;
        char name[UBI_VOL_NAME_MAX + 1];
 };
index a9c4a99235f8b766070b2340706b7ccf13bfbf8f..e754747d6bd6aa2f4f30274dd84c27b3af229de1 100644 (file)
@@ -940,13 +940,13 @@ int ubi_get_dev_info1(libubi_t desc, int dev_num, struct ubi_dev_info *info)
        if (dev_get_major(lib, dev_num, &info->major, &info->minor))
                return -1;
 
-       if (dev_read_int(lib->dev_avail_ebs, dev_num, &info->avail_ebs))
+       if (dev_read_int(lib->dev_avail_ebs, dev_num, &info->avail_lebs))
                return -1;
-       if (dev_read_int(lib->dev_total_ebs, dev_num, &info->total_ebs))
+       if (dev_read_int(lib->dev_total_ebs, dev_num, &info->total_lebs))
                return -1;
        if (dev_read_int(lib->dev_bad_count, dev_num, &info->bad_count))
                return -1;
-       if (dev_read_int(lib->dev_eb_size, dev_num, &info->eb_size))
+       if (dev_read_int(lib->dev_eb_size, dev_num, &info->leb_size))
                return -1;
        if (dev_read_int(lib->dev_bad_rsvd, dev_num, &info->bad_rsvd))
                return -1;
@@ -957,8 +957,8 @@ int ubi_get_dev_info1(libubi_t desc, int dev_num, struct ubi_dev_info *info)
        if (dev_read_int(lib->dev_min_io_size, dev_num, &info->min_io_size))
                return -1;
 
-       info->avail_bytes = info->avail_ebs * info->eb_size;
-       info->total_bytes = info->total_ebs * info->eb_size;
+       info->avail_bytes = info->avail_lebs * info->leb_size;
+       info->total_bytes = info->total_lebs * info->leb_size;
 
        return 0;
 
@@ -1016,17 +1016,17 @@ int ubi_get_vol_info1(libubi_t desc, int dev_num, int vol_id,
                          &info->data_bytes);
        if (ret)
                return -1;
-       ret = vol_read_int(lib->vol_rsvd_ebs, dev_num, vol_id, &info->rsvd_ebs);
+       ret = vol_read_int(lib->vol_rsvd_ebs, dev_num, vol_id, &info->rsvd_lebs);
        if (ret)
                return -1;
-       ret = vol_read_int(lib->vol_eb_size, dev_num, vol_id, &info->eb_size);
+       ret = vol_read_int(lib->vol_eb_size, dev_num, vol_id, &info->leb_size);
        if (ret)
                return -1;
        ret = vol_read_int(lib->vol_corrupted, dev_num, vol_id,
                           &info->corrupted);
        if (ret)
                return -1;
-       info->rsvd_bytes = info->eb_size * info->rsvd_ebs;
+       info->rsvd_bytes = info->leb_size * info->rsvd_lebs;
 
        ret = vol_read_data(lib->vol_name, dev_num, vol_id, &info->name,
                            UBI_VOL_NAME_MAX + 2);
index 238c6fa047add98cae1d95f437bb6ecd4afa7180..d65f0557411c8a273ece1ae7c3913ca0f36709b0 100644 (file)
@@ -44,7 +44,7 @@ struct ubi_info {
        FILE* fp_in;            /* Input Stream */
        FILE* fp_out;           /* Output stream */
 
-       size_t eb_size;         /* Physical EB size in bytes */
+       size_t peb_size;        /* Physical EB size in bytes */
        size_t leb_size;        /* Size of a logical EB in a physical EB */
        size_t leb_total;       /* Total input size in logical EB */
        size_t alignment;       /* Block alignment */
@@ -63,11 +63,11 @@ struct ubi_info {
 
 
 static uint32_t
-byte_to_blk(uint64_t byte, uint32_t eb_size)
+byte_to_blk(uint64_t byte, uint32_t peb_size)
 {
-       return (byte % eb_size) == 0
-               ? (byte / eb_size)
-               : (byte / eb_size) + 1;
+       return (byte % peb_size) == 0
+               ? (byte / peb_size)
+               : (byte / peb_size) + 1;
 }
 
 static int
@@ -111,7 +111,7 @@ skip_blks(ubi_info_t u, uint32_t blks)
 static void
 clear_buf(ubi_info_t u)
 {
-       memset(u->buf, 0xff, u->eb_size);
+       memset(u->buf, 0xff, u->peb_size);
 }
 
 static void
@@ -173,8 +173,8 @@ write_to_output_stream(ubi_info_t u)
 {
        size_t written;
 
-       written = fwrite(u->buf, 1, u->eb_size, u->fp_out);
-       if (written != u->eb_size) {
+       written = fwrite(u->buf, 1, u->peb_size, u->fp_out);
+       if (written != u->peb_size) {
                return -EIO;
        }
        return 0;
@@ -273,7 +273,7 @@ dump_info(ubi_info_t u ubi_unused)
                "static" : "dynamic");
        fprintf(stderr, "used_ebs     :   %8d\n",
                ubi32_to_cpu(u->v->used_ebs));
-       fprintf(stderr, "eb_size      : 0x%08x\n", u->eb_size);
+       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));
@@ -318,7 +318,7 @@ ubigen_init(void)
 
 int
 ubigen_create(ubi_info_t* u, uint32_t vol_id, uint8_t vol_type,
-             uint32_t eb_size, uint64_t ec, uint32_t alignment,
+             uint32_t peb_size, uint64_t ec, uint32_t alignment,
              uint8_t version, uint32_t vid_hdr_offset, uint8_t compat_flag,
              size_t data_size, FILE* fp_in, FILE* fp_out)
 {
@@ -358,13 +358,13 @@ ubigen_create(ubi_info_t* u, uint32_t vol_id, uint8_t vol_type,
        vid_hdr_offset = vid_hdr_offset ? vid_hdr_offset : DEFAULT_VID_OFFSET;
        data_offset = vid_hdr_offset + UBI_VID_HDR_SIZE;
        res->bytes_total = data_size;
-       res->eb_size = eb_size ? eb_size : DEFAULT_BLOCKSIZE;
-       res->data_pad = (res->eb_size - data_offset) % alignment;
-       res->leb_size = res->eb_size - data_offset - res->data_pad;
+       res->peb_size = peb_size ? peb_size : DEFAULT_BLOCKSIZE;
+       res->data_pad = (res->peb_size - data_offset) % alignment;
+       res->leb_size = res->peb_size - data_offset - res->data_pad;
        res->leb_total = byte_to_blk(data_size, res->leb_size);
        res->alignment = alignment;
 
-       if ((res->eb_size < (vid_hdr_offset + UBI_VID_HDR_SIZE))) {
+       if ((res->peb_size < (vid_hdr_offset + UBI_VID_HDR_SIZE))) {
                rc = EUBIGEN_TOO_SMALL_EB;
                goto ubigen_create_err;
        }
@@ -399,7 +399,7 @@ ubigen_create(ubi_info_t* u, uint32_t vol_id, uint8_t vol_type,
        res->ec->hdr_crc = cpu_to_ubi32(crc);
 
        /* prepare a read buffer */
-       res->buf = (uint8_t*) malloc (res->eb_size * sizeof(uint8_t));
+       res->buf = (uint8_t*) malloc (res->peb_size * sizeof(uint8_t));
        if (res->buf == NULL) {
                rc = -ENOMEM;
                goto ubigen_create_err;
index 08b770f43019474d47dce1b31b5a6416d87cf38f..160a46342d68e9151a8a562d87c18b083b886042 100644 (file)
@@ -36,7 +36,7 @@ peb_cmp(peb_t eb_1, peb_t eb_2)
 }
 
 int
-peb_new(uint32_t eb_num, uint32_t eb_size, peb_t *peb)
+peb_new(uint32_t eb_num, uint32_t peb_size, peb_t *peb)
 {
        int rc = 0;
 
@@ -47,7 +47,7 @@ peb_new(uint32_t eb_num, uint32_t eb_size, peb_t *peb)
        }
 
        res->num  = eb_num;
-       res->size = eb_size;
+       res->size = peb_size;
        res->data = (uint8_t*) malloc(res->size * sizeof(uint8_t));
        if (!res->data) {
                rc = -ENOMEM;
index c2868e2fdcf8a0739b81599685990e10e4bedeb7..4173e7849c40a285f51aedd7b8cc3f18988d66dc 100644 (file)
@@ -291,8 +291,8 @@ int main(int argc, char * const argv[])
        }
 
        if (myargs.lebs != -1) {
-               myargs.bytes = dev_info.eb_size;
-               myargs.bytes -= dev_info.eb_size % myargs.alignment;
+               myargs.bytes = dev_info.leb_size;
+               myargs.bytes -= dev_info.leb_size % myargs.alignment;
                myargs.bytes *= myargs.lebs;
        }
 
@@ -319,10 +319,10 @@ int main(int argc, char * const argv[])
                goto out_libubi;
        }
 
-       printf("Volume ID %d, size %d LEBs (", vol_info.vol_id, vol_info.rsvd_ebs);
+       printf("Volume ID %d, size %d LEBs (", vol_info.vol_id, vol_info.rsvd_lebs);
        ubiutils_print_bytes(vol_info.rsvd_bytes, 0);
        printf("), LEB size ");
-       ubiutils_print_bytes(vol_info.eb_size, 1);
+       ubiutils_print_bytes(vol_info.leb_size, 1);
        printf(", %s volume, name \"%s\", alignment %d\n",
               req.vol_type == UBI_DYNAMIC_VOLUME ? "dynamic" : "static",
               vol_info.name, vol_info.alignment);
index 6451bda3a3cca9fae80c55f079cbc9171302e851..a0bbbec1591a70a9f63273c8aca41ac8575cb4b4 100644 (file)
@@ -215,7 +215,7 @@ static int print_vol_info(libubi_t libubi, int dev_num, int vol_id)
               vol_info.type == UBI_DYNAMIC_VOLUME ?  "dynamic" : "static");
        printf("Alignment:   %d\n", vol_info.alignment);
 
-       printf("Size:        %d LEBs (", vol_info.rsvd_ebs);
+       printf("Size:        %d LEBs (", vol_info.rsvd_lebs);
        ubiutils_print_bytes(vol_info.rsvd_bytes, 0);
        printf(")\n");
 
@@ -246,13 +246,13 @@ static int print_dev_info(libubi_t libubi, int dev_num, int all)
 
        printf("ubi%d:\n", dev_info.dev_num);
        printf("Volumes count:                           %d\n", dev_info.vol_count);
-       printf("Logical eraseblock size:                 %d\n", dev_info.eb_size);
+       printf("Logical eraseblock size:                 %d\n", dev_info.leb_size);
 
-       printf("Total amount of logical eraseblocks:     %d (", dev_info.total_ebs);
+       printf("Total amount of logical eraseblocks:     %d (", dev_info.total_lebs);
        ubiutils_print_bytes(dev_info.total_bytes, 0);
        printf(")\n");
 
-       printf("Amount of available logical eraseblocks: %d", dev_info.avail_ebs);
+       printf("Amount of available logical eraseblocks: %d", dev_info.avail_lebs);
        ubiutils_print_bytes(dev_info.avail_bytes, 0);
        printf(")\n");
 
index 413319401828e2b0643f91456c4020d5b239d579..19caf5ae02c1ab27feae2632de866d91038ef319 100644 (file)
@@ -171,9 +171,9 @@ static int update_volume(libubi_t libubi, struct ubi_vol_info *vol_info)
        struct stat st;
        char *buf;
 
-       buf = malloc(vol_info->eb_size);
+       buf = malloc(vol_info->leb_size);
        if (!buf) {
-               errmsg("cannot allocate %d bytes of memory", vol_info->eb_size);
+               errmsg("cannot allocate %d bytes of memory", vol_info->leb_size);
                return -1;
        }
 
@@ -212,7 +212,7 @@ static int update_volume(libubi_t libubi, struct ubi_vol_info *vol_info)
        }
 
        while (bytes) {
-               int tocopy = vol_info->eb_size;
+               int tocopy = vol_info->leb_size;
 
                if (tocopy > bytes)
                        tocopy = bytes;