add 'mtd refresh' command
SVN-Revision: 8439
This commit is contained in:
parent
4460bbca47
commit
5307d511aa
2 changed files with 33 additions and 1 deletions
|
@ -241,6 +241,25 @@ mtd_erase(const char *mtd)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
mtd_refresh(const char *mtd)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = mtd_open(mtd, O_RDWR | O_SYNC);
|
||||||
|
if(fd < 0) {
|
||||||
|
fprintf(stderr, "Could not open mtd device: %s\n", mtd);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (ioctl(fd, MTDREFRESH, NULL)) {
|
||||||
|
fprintf(stderr, "Failed to refresh the MTD device\n");
|
||||||
|
close(fd);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mtd_write(int imagefd, const char *mtd)
|
mtd_write(int imagefd, const char *mtd)
|
||||||
{
|
{
|
||||||
|
@ -318,6 +337,7 @@ void usage(void)
|
||||||
"The device is in the format of mtdX (eg: mtd4) or its label.\n"
|
"The device is in the format of mtdX (eg: mtd4) or its label.\n"
|
||||||
"mtd recognizes these commands:\n"
|
"mtd recognizes these commands:\n"
|
||||||
" unlock unlock the device\n"
|
" unlock unlock the device\n"
|
||||||
|
" refresh refresh mtd partition\n"
|
||||||
" erase erase all data on device\n"
|
" erase erase all data on device\n"
|
||||||
" write <imagefile>|- write <imagefile> (use - for stdin) to device\n"
|
" write <imagefile>|- write <imagefile> (use - for stdin) to device\n"
|
||||||
"Following options are available:\n"
|
"Following options are available:\n"
|
||||||
|
@ -338,7 +358,8 @@ int main (int argc, char **argv)
|
||||||
enum {
|
enum {
|
||||||
CMD_ERASE,
|
CMD_ERASE,
|
||||||
CMD_WRITE,
|
CMD_WRITE,
|
||||||
CMD_UNLOCK
|
CMD_UNLOCK,
|
||||||
|
CMD_REFRESH
|
||||||
} cmd;
|
} cmd;
|
||||||
|
|
||||||
erase[0] = NULL;
|
erase[0] = NULL;
|
||||||
|
@ -380,6 +401,9 @@ int main (int argc, char **argv)
|
||||||
if ((strcmp(argv[0], "unlock") == 0) && (argc == 2)) {
|
if ((strcmp(argv[0], "unlock") == 0) && (argc == 2)) {
|
||||||
cmd = CMD_UNLOCK;
|
cmd = CMD_UNLOCK;
|
||||||
device = argv[1];
|
device = argv[1];
|
||||||
|
} else if ((strcmp(argv[0], "refresh") == 0) && (argc == 2)) {
|
||||||
|
cmd = CMD_REFRESH;
|
||||||
|
device = argv[1];
|
||||||
} else if ((strcmp(argv[0], "erase") == 0) && (argc == 2)) {
|
} else if ((strcmp(argv[0], "erase") == 0) && (argc == 2)) {
|
||||||
cmd = CMD_ERASE;
|
cmd = CMD_ERASE;
|
||||||
device = argv[1];
|
device = argv[1];
|
||||||
|
@ -451,6 +475,13 @@ int main (int argc, char **argv)
|
||||||
if (quiet < 2)
|
if (quiet < 2)
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
break;
|
break;
|
||||||
|
case CMD_REFRESH:
|
||||||
|
if (quiet < 2)
|
||||||
|
fprintf(stderr, "Refreshing mtd partition %s ... ");
|
||||||
|
mtd_refresh(device);
|
||||||
|
if (quiet < 2)
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sync();
|
sync();
|
||||||
|
|
|
@ -96,6 +96,7 @@ struct region_info_user {
|
||||||
#define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user)
|
#define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user)
|
||||||
#define MEMREADDATA _IOWR('M', 9, struct mtd_oob_buf)
|
#define MEMREADDATA _IOWR('M', 9, struct mtd_oob_buf)
|
||||||
#define MEMWRITEDATA _IOWR('M', 10, struct mtd_oob_buf)
|
#define MEMWRITEDATA _IOWR('M', 10, struct mtd_oob_buf)
|
||||||
|
#define MTDREFRESH _IO('M', 23)
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
#ifndef __KERNEL__
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue