diff options
author | pancake <pancake@dazo> | 2007-06-16 05:52:46 +0200 |
---|---|---|
committer | pancake <pancake@dazo> | 2007-06-16 05:52:46 +0200 |
commit | 3728cdea3130c62f3d766df040d2cb85f1e6caa4 (patch) | |
tree | e1e683eb758edf0638578c75195c04ec1d35e562 /src/dump.c | |
parent | c1d909c41587eb0f4b0581c5be9b70b2b72aefdb (diff) | |
download | 0xFFFF-3728cdea3130c62f3d766df040d2cb85f1e6caa4.tar.bz2 |
* 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
Diffstat (limited to 'src/dump.c')
-rw-r--r-- | src/dump.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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: |