* Add new command 'nanddump' for the console shell
* Avoid dumping non-mtd files because writesize = 0 - Properly close the file when failing * Better doc/pieces documentation
This commit is contained in:
1 parent
c1d909c415
commit
3728cdea31
4 files changed
+88
-2
No files matched your search
+9
-1
@@ -124,6 +124,9 @@ int mtd_open(char *file, mtd_info_t *meminfo, int *oobinfochanged,
|
||||
|
||||
int mtd_close(int fd, struct nand_oobinfo *old_oobinfo, int oobinfochanged)
|
||||
{
|
||||
if (fd == -1)
|
||||
return 1;
|
||||
|
||||
/* reset oobinfo */
|
||||
if (oobinfochanged == 1) {
|
||||
if (ioctl (fd, MEMSETOOBSEL, &old_oobinfo) != 0) {
|
||||
@@ -264,6 +267,12 @@ int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char
|
||||
|
||||
fd = mtd_open(mtddev, &meminfo, &oobinfochanged, &old_oobinfo, &eccstats, flags);
|
||||
|
||||
if (meminfo.writesize == 0) {
|
||||
printf("What the fuck.. this is not an MTD device!\n");
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Read the real oob length */
|
||||
oob.length = meminfo.oobsize;
|
||||
fprintf(stderr, "Block size %u, page size %u, OOB size %u\n",
|
||||
@@ -271,7 +280,6 @@ int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char
|
||||
fprintf(stderr, "Size %u, flags %u, type 0x%x\n",
|
||||
meminfo.size, meminfo.flags, (int)meminfo.type);
|
||||
|
||||
|
||||
if (flags & M_OMITECC) { // (noecc)
|
||||
switch (ioctl(fd, MTDFILEMODE, (void *) MTD_MODE_RAW)) {
|
||||
case -ENOTTY:
|
||||
|
||||
Reference in new issue
Block a user