mtd/util rfdformat.c,1.1,1.2 rfddump.c,1.1,1.2
sean at infradead.org
sean at infradead.org
Thu Jun 23 10:50:16 EDT 2005
Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv5598/util
Modified Files:
rfdformat.c rfddump.c
Log Message:
Proper cylinder/sectors and ignore writes of blank sectors
Signed-off-by: Sean Young <sean at mess.org>
Index: rfdformat.c
===================================================================
RCS file: /home/cvs/mtd/util/rfdformat.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- rfdformat.c 19 Jun 2005 16:43:02 -0000 1.1
+++ rfdformat.c 23 Jun 2005 14:50:13 -0000 1.2
@@ -111,13 +111,27 @@
}
if (mtd_info.type != MTD_NORFLASH) {
- fprintf(stderr, "%s: wrong type of flash\n", mtd_filename);
+ fprintf(stderr, "%s: not NOR flash\n", mtd_filename);
+ close(fd);
+ return 2;
+ }
+
+ if (mtd_info.size > 32*1024*1024) {
+ fprintf(stderr, "%s: flash larger than 32MiB not supported\n",
+ mtd_filename);
close(fd);
return 2;
}
block_count = mtd_info.size / mtd_info.erasesize;
+ if (block_count < 2) {
+ fprintf(stderr, "%s: at least two erase units required\n",
+ mtd_filename);
+ close(fd);
+ return 2;
+ }
+
for (i=0; i<block_count; i++) {
struct erase_info_user erase_info;
Index: rfddump.c
===================================================================
RCS file: /home/cvs/mtd/util/rfddump.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- rfddump.c 19 Jun 2005 16:43:02 -0000 1.1
+++ rfddump.c 23 Jun 2005 14:50:13 -0000 1.2
@@ -36,6 +36,8 @@
#define SECTOR_SIZE 512
+#define SECTORS_PER_TRACK 63
+
struct rfd {
int block_size;
@@ -183,7 +185,7 @@
int i, blocks_found;
int out_fd = 0;
__u8 sector[512];
- int blank, rc;
+ int blank, rc, cylinders;
process_options(argc, argv, &rfd);
@@ -222,7 +224,7 @@
if (st.st_size % SECTOR_SIZE)
fprintf(stderr, "%s: warning: not a multiple of sectors (512 bytes)\n", rfd.mtd_filename);
- sectors_per_block = st.st_size / SECTOR_SIZE;
+ sectors_per_block = rfd.block_size / SECTOR_SIZE;
if (st.st_size % rfd.block_size)
fprintf(stderr, "%s: warning: not a multiple of block size\n", rfd.mtd_filename);
@@ -240,7 +242,9 @@
((HEADER_MAP_OFFSET + sectors_per_block) *
sizeof(__u16) + SECTOR_SIZE - 1) / SECTOR_SIZE;
rfd.data_sectors = sectors_per_block - rfd.header_sectors;
- rfd.sector_count = (rfd.block_count - 1) * rfd.data_sectors;
+ cylinders = ((rfd.block_count - 1) * rfd.data_sectors - 1)
+ / SECTORS_PER_TRACK;
+ rfd.sector_count = cylinders * SECTORS_PER_TRACK;
rfd.header_size =
(HEADER_MAP_OFFSET + rfd.data_sectors) * sizeof(__u16);
@@ -276,10 +280,12 @@
goto err;
}
- for (; rfd.sector_count && rfd.sector_map[rfd.sector_count - 1] == -1;
- rfd.sector_count--);
+ for (i=0; i<rfd.sector_count; i++) {
+ if (rfd.sector_map[i] != -1)
+ break;
+ }
- if (!rfd.sector_count) {
+ if (i == rfd.sector_count) {
fprintf(stderr, "%s: no sectors found\n", rfd.mtd_filename);
goto err;
}
More information about the linux-mtd-cvs
mailing list