summaryrefslogtreecommitdiff
path: root/ubi-utils/src
diff options
context:
space:
mode:
Diffstat (limited to 'ubi-utils/src')
-rw-r--r--ubi-utils/src/libmtd.c142
-rw-r--r--ubi-utils/src/libmtd_legacy.c38
-rw-r--r--ubi-utils/src/mtdinfo.c16
-rw-r--r--ubi-utils/src/ubiformat.c12
4 files changed, 104 insertions, 104 deletions
diff --git a/ubi-utils/src/libmtd.c b/ubi-utils/src/libmtd.c
index 011327d..3ff031c 100644
--- a/ubi-utils/src/libmtd.c
+++ b/ubi-utils/src/libmtd.c
@@ -157,35 +157,35 @@ static int read_major(const char *file, int *major, int *minor)
/**
* dev_get_major - get major and minor numbers of an MTD device.
* @lib: libmtd descriptor
- * @dev_num: MTD device number
+ * @mtd_num: MTD device number
* @major: major number is returned here
* @minor: minor number is returned here
*
* This function returns zero in case of success and %-1 in case of failure.
*/
-static int dev_get_major(struct libmtd *lib, int dev_num, int *major, int *minor)
+static int dev_get_major(struct libmtd *lib, int mtd_num, int *major, int *minor)
{
char file[strlen(lib->mtd_dev) + 50];
- sprintf(file, lib->mtd_dev, dev_num);
+ sprintf(file, lib->mtd_dev, mtd_num);
return read_major(file, major, minor);
}
/**
* dev_read_data - read data from an MTD device's sysfs file.
* @patt: file pattern to read from
- * @dev_num: MTD device number
+ * @mtd_num: MTD device number
* @buf: buffer to read to
* @buf_len: buffer length
*
* This function returns number of read bytes in case of success and %-1 in
* case of failure.
*/
-static int dev_read_data(const char *patt, int dev_num, void *buf, int buf_len)
+static int dev_read_data(const char *patt, int mtd_num, void *buf, int buf_len)
{
char file[strlen(patt) + 100];
- sprintf(file, patt, dev_num);
+ sprintf(file, patt, mtd_num);
return read_data(file, buf, buf_len);
}
@@ -349,48 +349,48 @@ static int read_pos_int(const char *file, int *value)
/**
* dev_read_hex_int - read an hex 'int' value from an MTD device sysfs file.
* @patt: file pattern to read from
- * @dev_num: MTD device number
+ * @mtd_num: MTD device number
* @value: the result is stored here
*
* This function returns %0 in case of success and %-1 in case of failure.
*/
-static int dev_read_hex_int(const char *patt, int dev_num, int *value)
+static int dev_read_hex_int(const char *patt, int mtd_num, int *value)
{
char file[strlen(patt) + 50];
- sprintf(file, patt, dev_num);
+ sprintf(file, patt, mtd_num);
return read_hex_int(file, value);
}
/**
* dev_read_pos_int - read a positive 'int' value from an MTD device sysfs file.
* @patt: file pattern to read from
- * @dev_num: MTD device number
+ * @mtd_num: MTD device number
* @value: the result is stored here
*
* This function returns %0 in case of success and %-1 in case of failure.
*/
-static int dev_read_pos_int(const char *patt, int dev_num, int *value)
+static int dev_read_pos_int(const char *patt, int mtd_num, int *value)
{
char file[strlen(patt) + 50];
- sprintf(file, patt, dev_num);
+ sprintf(file, patt, mtd_num);
return read_pos_int(file, value);
}
/**
* dev_read_pos_ll - read a positive 'long long' value from an MTD device sysfs file.
* @patt: file pattern to read from
- * @dev_num: MTD device number
+ * @mtd_num: MTD device number
* @value: the result is stored here
*
* This function returns %0 in case of success and %-1 in case of failure.
*/
-static int dev_read_pos_ll(const char *patt, int dev_num, long long *value)
+static int dev_read_pos_ll(const char *patt, int mtd_num, long long *value)
{
char file[strlen(patt) + 50];
- sprintf(file, patt, dev_num);
+ sprintf(file, patt, mtd_num);
return read_pos_ll(file, value);
}
@@ -424,11 +424,11 @@ static int type_str2int(const char *str)
* dev_node2num - find UBI device number by its character device node.
* @lib: MTD library descriptor
* @node: name of the MTD device node
- * @dev_num: MTD device number is returned here
+ * @mtd_num: MTD device number is returned here
*
* This function returns %0 in case of success and %-1 in case of failure.
*/
-static int dev_node2num(struct libmtd *lib, const char *node, int *dev_num)
+static int dev_node2num(struct libmtd *lib, const char *node, int *mtd_num)
{
struct stat st;
int i, major, minor;
@@ -449,7 +449,7 @@ static int dev_node2num(struct libmtd *lib, const char *node, int *dev_num)
if (mtd_get_info((libmtd_t *)lib, &info))
return -1;
- for (i = info.lowest_dev_num; i <= info.highest_dev_num; i++) {
+ for (i = info.lowest_mtd_num; i <= info.highest_mtd_num; i++) {
int major1, minor1, ret;
ret = dev_get_major(lib, i, &major1, &minor1);
@@ -463,7 +463,7 @@ static int dev_node2num(struct libmtd *lib, const char *node, int *dev_num)
if (major1 == major && minor1 == minor) {
errno = 0;
- *dev_num = i;
+ *mtd_num = i;
return 0;
}
}
@@ -508,7 +508,7 @@ static int sysfs_is_supported(struct libmtd *lib)
* may be, for example, mtd1 but no mtd0.
*/
while (1) {
- int ret, dev_num;
+ int ret, mtd_num;
char tmp_buf[256];
struct dirent *dirent;
@@ -525,9 +525,9 @@ static int sysfs_is_supported(struct libmtd *lib)
}
ret = sscanf(dirent->d_name, MTD_NAME_PATT"%s",
- &dev_num, tmp_buf);
+ &mtd_num, tmp_buf);
if (ret == 1) {
- num = dev_num;
+ num = mtd_num;
break;
}
}
@@ -669,9 +669,9 @@ int mtd_get_info(libmtd_t desc, struct mtd_info *info)
return sys_errmsg("cannot open \"%s\"", lib->sysfs_mtd);
}
- info->lowest_dev_num = INT_MAX;
+ info->lowest_mtd_num = INT_MAX;
while (1) {
- int dev_num, ret;
+ int mtd_num, ret;
char tmp_buf[256];
errno = 0;
@@ -687,13 +687,13 @@ int mtd_get_info(libmtd_t desc, struct mtd_info *info)
}
ret = sscanf(dirent->d_name, MTD_NAME_PATT"%s",
- &dev_num, tmp_buf);
+ &mtd_num, tmp_buf);
if (ret == 1) {
- info->dev_count += 1;
- if (dev_num > info->highest_dev_num)
- info->highest_dev_num = dev_num;
- if (dev_num < info->lowest_dev_num)
- info->lowest_dev_num = dev_num;
+ info->mtd_dev_cnt += 1;
+ if (mtd_num > info->highest_mtd_num)
+ info->highest_mtd_num = mtd_num;
+ if (mtd_num < info->lowest_mtd_num)
+ info->lowest_mtd_num = mtd_num;
}
}
@@ -705,8 +705,8 @@ int mtd_get_info(libmtd_t desc, struct mtd_info *info)
if (closedir(sysfs_mtd))
return sys_errmsg("closedir failed on \"%s\"", lib->sysfs_mtd);
- if (info->lowest_dev_num == INT_MAX)
- info->lowest_dev_num = 0;
+ if (info->lowest_mtd_num == INT_MAX)
+ info->lowest_mtd_num = 0;
return 0;
@@ -715,21 +715,21 @@ out_close:
return -1;
}
-int mtd_get_dev_info1(libmtd_t desc, int dev_num, struct mtd_dev_info *mtd)
+int mtd_get_dev_info1(libmtd_t desc, int mtd_num, struct mtd_dev_info *mtd)
{
int ret;
struct stat st;
struct libmtd *lib = (struct libmtd *)desc;
memset(mtd, 0, sizeof(struct mtd_dev_info));
- mtd->dev_num = dev_num;
+ mtd->mtd_num = mtd_num;
if (!lib->sysfs_supported)
- return legacy_get_dev_info1(dev_num, mtd);
+ return legacy_get_dev_info1(mtd_num, mtd);
else {
char file[strlen(lib->mtd) + 10];
- sprintf(file, lib->mtd, dev_num);
+ sprintf(file, lib->mtd, mtd_num);
if (stat(file, &st)) {
if (errno == ENOENT)
errno = ENODEV;
@@ -737,34 +737,34 @@ int mtd_get_dev_info1(libmtd_t desc, int dev_num, struct mtd_dev_info *mtd)
}
}
- if (dev_get_major(lib, dev_num, &mtd->major, &mtd->minor))
+ if (dev_get_major(lib, mtd_num, &mtd->major, &mtd->minor))
return -1;
- ret = dev_read_data(lib->mtd_name, dev_num, &mtd->name,
+ ret = dev_read_data(lib->mtd_name, mtd_num, &mtd->name,
MTD_NAME_MAX + 1);
if (ret < 0)
return -1;
((char *)mtd->name)[ret - 1] = '\0';
- ret = dev_read_data(lib->mtd_type, dev_num, &mtd->type_str,
+ ret = dev_read_data(lib->mtd_type, mtd_num, &mtd->type_str,
MTD_TYPE_MAX + 1);
if (ret < 0)
return -1;
((char *)mtd->type_str)[ret - 1] = '\0';
- if (dev_read_pos_int(lib->mtd_eb_size, dev_num, &mtd->eb_size))
+ if (dev_read_pos_int(lib->mtd_eb_size, mtd_num, &mtd->eb_size))
return -1;
- if (dev_read_pos_ll(lib->mtd_size, dev_num, &mtd->size))
+ if (dev_read_pos_ll(lib->mtd_size, mtd_num, &mtd->size))
return -1;
- if (dev_read_pos_int(lib->mtd_min_io_size, dev_num, &mtd->min_io_size))
+ if (dev_read_pos_int(lib->mtd_min_io_size, mtd_num, &mtd->min_io_size))
return -1;
- if (dev_read_pos_int(lib->mtd_subpage_size, dev_num, &mtd->subpage_size))
+ if (dev_read_pos_int(lib->mtd_subpage_size, mtd_num, &mtd->subpage_size))
return -1;
- if (dev_read_pos_int(lib->mtd_oob_size, dev_num, &mtd->oob_size))
+ if (dev_read_pos_int(lib->mtd_oob_size, mtd_num, &mtd->oob_size))
return -1;
- if (dev_read_pos_int(lib->mtd_region_cnt, dev_num, &mtd->region_cnt))
+ if (dev_read_pos_int(lib->mtd_region_cnt, mtd_num, &mtd->region_cnt))
return -1;
- if (dev_read_hex_int(lib->mtd_flags, dev_num, &ret))
+ if (dev_read_hex_int(lib->mtd_flags, mtd_num, &ret))
return -1;
mtd->writable = !!(ret & MTD_WRITEABLE);
@@ -777,16 +777,16 @@ int mtd_get_dev_info1(libmtd_t desc, int dev_num, struct mtd_dev_info *mtd)
int mtd_get_dev_info(libmtd_t desc, const char *node, struct mtd_dev_info *mtd)
{
- int dev_num;
+ int mtd_num;
struct libmtd *lib = (struct libmtd *)desc;
if (!lib->sysfs_supported)
return legacy_get_dev_info(node, mtd);
- if (dev_node2num(lib, node, &dev_num))
+ if (dev_node2num(lib, node, &mtd_num))
return -1;
- return mtd_get_dev_info1(desc, dev_num, mtd);
+ return mtd_get_dev_info1(desc, mtd_num, mtd);
}
int mtd_erase(const struct mtd_dev_info *mtd, int fd, int eb)
@@ -886,7 +886,7 @@ int mtd_is_bad(const struct mtd_dev_info *mtd, int fd, int eb)
if (eb < 0 || eb >= mtd->eb_cnt) {
errmsg("bad eraseblock number %d, mtd%d has %d eraseblocks",
- eb, mtd->dev_num, mtd->eb_cnt);
+ eb, mtd->mtd_num, mtd->eb_cnt);
errno = EINVAL;
return -1;
}
@@ -898,7 +898,7 @@ int mtd_is_bad(const struct mtd_dev_info *mtd, int fd, int eb)
ret = ioctl(fd, MEMGETBADBLOCK, &seek);
if (ret == -1)
return sys_errmsg("MEMGETBADBLOCK ioctl failed for "
- "eraseblock %d (mtd%d)", eb, mtd->dev_num);
+ "eraseblock %d (mtd%d)", eb, mtd->mtd_num);
return ret;
}
@@ -914,7 +914,7 @@ int mtd_mark_bad(const struct mtd_dev_info *mtd, int fd, int eb)
if (eb < 0 || eb >= mtd->eb_cnt) {
errmsg("bad eraseblock number %d, mtd%d has %d eraseblocks",
- eb, mtd->dev_num, mtd->eb_cnt);
+ eb, mtd->mtd_num, mtd->eb_cnt);
errno = EINVAL;
return -1;
}
@@ -923,7 +923,7 @@ int mtd_mark_bad(const struct mtd_dev_info *mtd, int fd, int eb)
ret = ioctl(fd, MEMSETBADBLOCK, &seek);
if (ret == -1)
return sys_errmsg("MEMSETBADBLOCK ioctl failed for "
- "eraseblock %d (mtd%d)", eb, mtd->dev_num);
+ "eraseblock %d (mtd%d)", eb, mtd->mtd_num);
return 0;
}
@@ -935,13 +935,13 @@ int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
if (eb < 0 || eb >= mtd->eb_cnt) {
errmsg("bad eraseblock number %d, mtd%d has %d eraseblocks",
- eb, mtd->dev_num, mtd->eb_cnt);
+ eb, mtd->mtd_num, mtd->eb_cnt);
errno = EINVAL;
return -1;
}
if (offs < 0 || offs + len > mtd->eb_size) {
errmsg("bad offset %d or length %d, mtd%d eraseblock size is %d",
- offs, len, mtd->dev_num, mtd->eb_size);
+ offs, len, mtd->mtd_num, mtd->eb_size);
errno = EINVAL;
return -1;
}
@@ -950,13 +950,13 @@ int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
seek = (off_t)eb * mtd->eb_size + offs;
if (lseek(fd, seek, SEEK_SET) != seek)
return sys_errmsg("cannot seek mtd%d to offset %llu",
- mtd->dev_num, (unsigned long long)seek);
+ mtd->mtd_num, (unsigned long long)seek);
while (rd < len) {
ret = read(fd, buf, len);
if (ret < 0)
return sys_errmsg("cannot read %d bytes from mtd%d (eraseblock %d, offset %d)",
- len, mtd->dev_num, eb, offs);
+ len, mtd->mtd_num, eb, offs);
rd += ret;
}
@@ -971,25 +971,25 @@ int mtd_write(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
if (eb < 0 || eb >= mtd->eb_cnt) {
errmsg("bad eraseblock number %d, mtd%d has %d eraseblocks",
- eb, mtd->dev_num, mtd->eb_cnt);
+ eb, mtd->mtd_num, mtd->eb_cnt);
errno = EINVAL;
return -1;
}
if (offs < 0 || offs + len > mtd->eb_size) {
errmsg("bad offset %d or length %d, mtd%d eraseblock size is %d",
- offs, len, mtd->dev_num, mtd->eb_size);
+ offs, len, mtd->mtd_num, mtd->eb_size);
errno = EINVAL;
return -1;
}
if (offs % mtd->subpage_size) {
errmsg("write offset %d is not aligned to mtd%d min. I/O size %d",
- offs, mtd->dev_num, mtd->subpage_size);
+ offs, mtd->mtd_num, mtd->subpage_size);
errno = EINVAL;
return -1;
}
if (len % mtd->subpage_size) {
errmsg("write length %d is not aligned to mtd%d min. I/O size %d",
- len, mtd->dev_num, mtd->subpage_size);
+ len, mtd->mtd_num, mtd->subpage_size);
errno = EINVAL;
return -1;
}
@@ -998,12 +998,12 @@ int mtd_write(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
seek = (off_t)eb * mtd->eb_size + offs;
if (lseek(fd, seek, SEEK_SET) != seek)
return sys_errmsg("cannot seek mtd%d to offset %llu",
- mtd->dev_num, (unsigned long long)seek);
+ mtd->mtd_num, (unsigned long long)seek);
ret = write(fd, buf, len);
if (ret != len)
return sys_errmsg("cannot write %d bytes to mtd%d (eraseblock %d, offset %d)",
- len, mtd->dev_num, eb, offs);
+ len, mtd->mtd_num, eb, offs);
return 0;
}
@@ -1018,19 +1018,19 @@ int mtd_write_img(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
if (eb < 0 || eb >= mtd->eb_cnt) {
errmsg("bad eraseblock number %d, mtd%d has %d eraseblocks",
- eb, mtd->dev_num, mtd->eb_cnt);
+ eb, mtd->mtd_num, mtd->eb_cnt);
errno = EINVAL;
return -1;
}
if (offs < 0 || offs >= mtd->eb_size) {
errmsg("bad offset %d, mtd%d eraseblock size is %d",
- offs, mtd->dev_num, mtd->eb_size);
+ offs, mtd->mtd_num, mtd->eb_size);
errno = EINVAL;
return -1;
}
if (offs % mtd->subpage_size) {
errmsg("write offset %d is not aligned to mtd%d min. I/O size %d",
- offs, mtd->dev_num, mtd->subpage_size);
+ offs, mtd->mtd_num, mtd->subpage_size);
errno = EINVAL;
return -1;
}
@@ -1047,7 +1047,7 @@ int mtd_write_img(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
len = st.st_size;
if (len % mtd->subpage_size) {
errmsg("size of \"%s\" is %d byte, which is not aligned to "
- "mtd%d min. I/O size %d", img_name, len, mtd->dev_num,
+ "mtd%d min. I/O size %d", img_name, len, mtd->mtd_num,
mtd->subpage_size);
errno = EINVAL;
goto out_close;
@@ -1057,7 +1057,7 @@ int mtd_write_img(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
errmsg("\"%s\" image size is %d bytes, mtd%d size is %d "
"eraseblocks, the image does not fit if we write it "
"starting from eraseblock %d, offset %d",
- img_name, len, mtd->dev_num, mtd->eb_cnt, eb, offs);
+ img_name, len, mtd->mtd_num, mtd->eb_cnt, eb, offs);
errno = EINVAL;
goto out_close;
}
@@ -1066,7 +1066,7 @@ int mtd_write_img(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
seek = (off_t)eb * mtd->eb_size + offs;
if (lseek(fd, seek, SEEK_SET) != seek) {
sys_errmsg("cannot seek mtd%d to offset %llu",
- mtd->dev_num, (unsigned long long)seek);
+ mtd->mtd_num, (unsigned long long)seek);
goto out_close;
}
@@ -1091,7 +1091,7 @@ int mtd_write_img(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
ret = write(fd, buf, rd);
if (ret != rd) {
sys_errmsg("cannot write %d bytes to mtd%d (eraseblock %d, offset %d)",
- len, mtd->dev_num, eb, offs);
+ len, mtd->mtd_num, eb, offs);
goto out_free;
}
@@ -1136,7 +1136,7 @@ int mtd_probe_node(libmtd_t desc, const char *node)
if (!lib->sysfs_supported)
return 0;
- for (i = info.lowest_dev_num; i <= info.highest_dev_num; i++) {
+ for (i = info.lowest_mtd_num; i <= info.highest_mtd_num; i++) {
int major1, minor1, ret;
ret = dev_get_major(lib, i, &major1, &minor1);
diff --git a/ubi-utils/src/libmtd_legacy.c b/ubi-utils/src/libmtd_legacy.c
index b477a4f..27fb3f8 100644
--- a/ubi-utils/src/libmtd_legacy.c
+++ b/ubi-utils/src/libmtd_legacy.c
@@ -48,7 +48,7 @@
/**
* struct proc_parse_info - /proc/mtd parsing information.
- * @dev_num: MTD device number
+ * @mtd_num: MTD device number
* @size: device size
* @eb_size: eraseblock size
* @name: device name
@@ -58,7 +58,7 @@
*/
struct proc_parse_info
{
- int dev_num;
+ int mtd_num;
long long size;
char name[MTD_NAME_MAX + 1];
int eb_size;
@@ -118,7 +118,7 @@ static int proc_parse_next(struct proc_parse_info *pi)
return 0;
}
- ret = sscanf(pi->next, PROC_MTD_PATT, &pi->dev_num, &pi->size,
+ ret = sscanf(pi->next, PROC_MTD_PATT, &pi->mtd_num, &pi->size,
&pi->eb_size);
if (ret != 3)
return errmsg("\"%s\" pattern not found", PROC_MTD_PATT);
@@ -140,7 +140,7 @@ static int proc_parse_next(struct proc_parse_info *pi)
len = p1 - p;
if (len > MTD_NAME_MAX)
- return errmsg("too long mtd%d device name", pi->dev_num);
+ return errmsg("too long mtd%d device name", pi->mtd_num);
memcpy(pi->name, p, len);
pi->name[len] = '\0';
@@ -190,13 +190,13 @@ int legacy_mtd_get_info(struct mtd_info *info)
if (ret)
return -1;
- info->lowest_dev_num = INT_MAX;
+ info->lowest_mtd_num = INT_MAX;
while (proc_parse_next(&pi)) {
- info->dev_count += 1;
- if (pi.dev_num > info->highest_dev_num)
- info->highest_dev_num = pi.dev_num;
- if (pi.dev_num < info->lowest_dev_num)
- info->lowest_dev_num = pi.dev_num;
+ info->mtd_dev_cnt += 1;
+ if (pi.mtd_num > info->highest_mtd_num)
+ info->highest_mtd_num = pi.mtd_num;
+ if (pi.mtd_num < info->lowest_mtd_num)
+ info->lowest_mtd_num = pi.mtd_num;
}
return 0;
@@ -241,7 +241,7 @@ int legacy_get_dev_info(const char *node, struct mtd_dev_info *mtd)
"major %d", node, mtd->major, MTD_DEV_MAJOR);
}
- mtd->dev_num = mtd->minor / 2;
+ mtd->mtd_num = mtd->minor / 2;
fd = open(node, O_RDWR);
if (fd == -1)
@@ -270,17 +270,17 @@ int legacy_get_dev_info(const char *node, struct mtd_dev_info *mtd)
if (mtd->min_io_size <= 0) {
errmsg("mtd%d (%s) has insane min. I/O unit size %d",
- mtd->dev_num, node, mtd->min_io_size);
+ mtd->mtd_num, node, mtd->min_io_size);
goto out_close;
}
if (mtd->eb_size <= 0 || mtd->eb_size < mtd->min_io_size) {
errmsg("mtd%d (%s) has insane eraseblock size %d",
- mtd->dev_num, node, mtd->eb_size);
+ mtd->mtd_num, node, mtd->eb_size);
goto out_close;
}
if (mtd->size <= 0 || mtd->size < mtd->eb_size) {
errmsg("mtd%d (%s) has insane size %lld",
- mtd->dev_num, node, mtd->size);
+ mtd->mtd_num, node, mtd->size);
goto out_close;
}
mtd->eb_cnt = mtd->size / mtd->eb_size;
@@ -288,7 +288,7 @@ int legacy_get_dev_info(const char *node, struct mtd_dev_info *mtd)
switch(mtd->type) {
case MTD_ABSENT:
errmsg("mtd%d (%s) is removable and is not present",
- mtd->dev_num, node);
+ mtd->mtd_num, node);
goto out_close;
case MTD_RAM:
strcpy((char *)mtd->type_str, "ram");
@@ -327,13 +327,13 @@ int legacy_get_dev_info(const char *node, struct mtd_dev_info *mtd)
return -1;
while (proc_parse_next(&pi)) {
- if (pi.dev_num == mtd->dev_num) {
+ if (pi.mtd_num == mtd->mtd_num) {
strcpy((char *)mtd->name, pi.name);
return 0;
}
}
- errmsg("mtd%d not found in \"%s\"", mtd->dev_num, MTD_PROC_FILE);
+ errmsg("mtd%d not found in \"%s\"", mtd->mtd_num, MTD_PROC_FILE);
errno = ENOENT;
return -1;
@@ -350,10 +350,10 @@ out_close:
* This function is similar to 'mtd_get_dev_info1()' and has the same
* conventions.
*/
-int legacy_get_dev_info1(int dev_num, struct mtd_dev_info *mtd)
+int legacy_get_dev_info1(int mtd_num, struct mtd_dev_info *mtd)
{
char node[sizeof(MTD_DEV_PATT) + 20];
- sprintf(node, MTD_DEV_PATT, dev_num);
+ sprintf(node, MTD_DEV_PATT, mtd_num);
return legacy_get_dev_info(node, mtd);
}
diff --git a/ubi-utils/src/mtdinfo.c b/ubi-utils/src/mtdinfo.c
index be8b1ff..11f309e 100644
--- a/ubi-utils/src/mtdinfo.c
+++ b/ubi-utils/src/mtdinfo.c
@@ -155,7 +155,7 @@ static int translate_dev(libmtd_t libmtd, const char *node)
"device \"%s\"", node);
}
- args.mtdn = mtd.dev_num;
+ args.mtdn = mtd.mtd_num;
return 0;
}
@@ -174,7 +174,7 @@ static int print_dev_info(libmtd_t libmtd, const struct mtd_info *mtd_info, int
mtdn);
}
- printf("mtd%d\n", mtd.dev_num);
+ printf("mtd%d\n", mtd.mtd_num);
printf("Name: %s\n", mtd.name);
printf("Type: %s\n", mtd.type_str);
printf("Eraseblock size: ");
@@ -234,12 +234,12 @@ static int print_general_info(libmtd_t libmtd, const struct mtd_info *mtd_info,
int i, err, first = 1;
struct mtd_dev_info mtd;
- printf("Count of MTD devices: %d\n", mtd_info->dev_count);
- if (mtd_info->dev_count == 0)
+ printf("Count of MTD devices: %d\n", mtd_info->mtd_dev_cnt);
+ if (mtd_info->mtd_dev_cnt == 0)
return 0;
- for (i = mtd_info->lowest_dev_num;
- i <= mtd_info->highest_dev_num; i++) {
+ for (i = mtd_info->lowest_mtd_num;
+ i <= mtd_info->highest_mtd_num; i++) {
err = mtd_get_dev_info1(libmtd, i, &mtd);
if (err == -1) {
if (errno == ENODEV)
@@ -265,8 +265,8 @@ static int print_general_info(libmtd_t libmtd, const struct mtd_info *mtd_info,
first = 1;
printf("\n");
- for (i = mtd_info->lowest_dev_num;
- i <= mtd_info->highest_dev_num; i++) {
+ for (i = mtd_info->lowest_mtd_num;
+ i <= mtd_info->highest_mtd_num; i++) {
err = print_dev_info(libmtd, mtd_info, i);
if (err)
return err;
diff --git a/ubi-utils/src/ubiformat.c b/ubi-utils/src/ubiformat.c
index 8ad5051..8487fd5 100644
--- a/ubi-utils/src/ubiformat.c
+++ b/ubi-utils/src/ubiformat.c
@@ -784,7 +784,7 @@ int main(int argc, char * const argv[])
}
if (!mtd.writable) {
- errmsg("mtd%d (%s) is a read-only device", mtd.dev_num, args.node);
+ errmsg("mtd%d (%s) is a read-only device", mtd.mtd_num, args.node);
goto out_close;
}
@@ -793,17 +793,17 @@ int main(int argc, char * const argv[])
if (libubi) {
int ubi_dev_num;
- err = mtd_num2ubi_dev(libubi, mtd.dev_num, &ubi_dev_num);
+ err = mtd_num2ubi_dev(libubi, mtd.mtd_num, &ubi_dev_num);
libubi_close(libubi);
if (!err) {
errmsg("please, first detach mtd%d (%s) from ubi%d",
- mtd.dev_num, args.node, ubi_dev_num);
+ mtd.mtd_num, args.node, ubi_dev_num);
goto out_close;
}
}
if (!args.quiet) {
- normsg_cont("mtd%d (%s), size ", mtd.dev_num, mtd.type_str);
+ normsg_cont("mtd%d (%s), size ", mtd.mtd_num, mtd.type_str);
ubiutils_print_bytes(mtd.size, 1);
printf(", %d eraseblocks of ", mtd.eb_cnt);
ubiutils_print_bytes(mtd.eb_size, 1);
@@ -818,7 +818,7 @@ int main(int argc, char * const argv[])
verbose = 1;
err = ubi_scan(&mtd, args.node_fd, &si, verbose);
if (err) {
- errmsg("failed to scan mtd%d (%s)", mtd.dev_num, args.node);
+ errmsg("failed to scan mtd%d (%s)", mtd.mtd_num, args.node);
goto out_close;
}
@@ -829,7 +829,7 @@ int main(int argc, char * const argv[])
if (si->good_cnt < 2 && (!args.novtbl || args.image)) {
errmsg("too few non-bad eraseblocks (%d) on mtd%d",
- si->good_cnt, mtd.dev_num);
+ si->good_cnt, mtd.mtd_num);
goto out_free;
}