2 * inftlmount.c -- INFTL mount code with extensive checks.
4 * Author: Greg Ungerer (gerg@snapgear.com)
5 * Copyright © 2002-2003, Greg Ungerer (gerg@snapgear.com)
7 * Based heavily on the nftlmount.c code which is:
8 * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
9 * Copyright © 2000 Netgem S.A.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/kernel.h>
27 #include <linux/module.h>
28 #include <asm/errno.h>
30 #include <asm/uaccess.h>
31 #include <linux/delay.h>
32 #include <linux/slab.h>
33 #include <linux/init.h>
34 #include <linux/mtd/mtd.h>
35 #include <linux/mtd/nftl.h>
36 #include <linux/mtd/inftl.h>
39 * find_boot_record: Find the INFTL Media Header and its Spare copy which
40 * contains the various device information of the INFTL partition and
41 * Bad Unit Table. Update the PUtable[] table according to the Bad
42 * Unit Table. PUtable[] is used for management of Erase Unit in
43 * other routines in inftlcore.c and inftlmount.c.
45 static int find_boot_record(struct INFTLrecord *inftl)
47 struct inftl_unittail h1;
48 //struct inftl_oob oob;
49 unsigned int i, block;
51 struct INFTLMediaHeader *mh = &inftl->MediaHdr;
52 struct mtd_info *mtd = inftl->mbd.mtd;
53 struct INFTLPartition *ip;
56 pr_debug("INFTL: find_boot_record(inftl=%p)\n", inftl);
59 * Assume logical EraseSize == physical erasesize for starting the
60 * scan. We'll sort it out later if we find a MediaHeader which says
63 inftl->EraseSize = inftl->mbd.mtd->erasesize;
64 inftl->nb_blocks = (u32)inftl->mbd.mtd->size / inftl->EraseSize;
66 inftl->MediaUnit = BLOCK_NIL;
68 /* Search for a valid boot record */
69 for (block = 0; block < inftl->nb_blocks; block++) {
73 * Check for BNAND header first. Then whinge if it's found
74 * but later checks fail.
76 ret = mtd->read(mtd, block * inftl->EraseSize,
77 SECTORSIZE, &retlen, buf);
78 /* We ignore ret in case the ECC of the MediaHeader is invalid
79 (which is apparently acceptable) */
80 if (retlen != SECTORSIZE) {
81 static int warncount = 5;
84 printk(KERN_WARNING "INFTL: block read at 0x%x "
85 "of mtd%d failed: %d\n",
86 block * inftl->EraseSize,
87 inftl->mbd.mtd->index, ret);
89 printk(KERN_WARNING "INFTL: further "
90 "failures for this block will "
96 if (retlen < 6 || memcmp(buf, "BNAND", 6)) {
97 /* BNAND\0 not found. Continue */
101 /* To be safer with BIOS, also use erase mark as discriminant */
102 ret = inftl_read_oob(mtd,
103 block * inftl->EraseSize + SECTORSIZE + 8,
104 8, &retlen,(char *)&h1);
106 printk(KERN_WARNING "INFTL: ANAND header found at "
107 "0x%x in mtd%d, but OOB data read failed "
108 "(err %d)\n", block * inftl->EraseSize,
109 inftl->mbd.mtd->index, ret);
115 * This is the first we've seen.
116 * Copy the media header structure into place.
118 memcpy(mh, buf, sizeof(struct INFTLMediaHeader));
120 /* Read the spare media header at offset 4096 */
121 mtd->read(mtd, block * inftl->EraseSize + 4096,
122 SECTORSIZE, &retlen, buf);
123 if (retlen != SECTORSIZE) {
124 printk(KERN_WARNING "INFTL: Unable to read spare "
128 /* Check if this one is the same as the first one we found. */
129 if (memcmp(mh, buf, sizeof(struct INFTLMediaHeader))) {
130 printk(KERN_WARNING "INFTL: Primary and spare Media "
131 "Headers disagree.\n");
135 mh->NoOfBootImageBlocks = le32_to_cpu(mh->NoOfBootImageBlocks);
136 mh->NoOfBinaryPartitions = le32_to_cpu(mh->NoOfBinaryPartitions);
137 mh->NoOfBDTLPartitions = le32_to_cpu(mh->NoOfBDTLPartitions);
138 mh->BlockMultiplierBits = le32_to_cpu(mh->BlockMultiplierBits);
139 mh->FormatFlags = le32_to_cpu(mh->FormatFlags);
140 mh->PercentUsed = le32_to_cpu(mh->PercentUsed);
142 pr_debug("INFTL: Media Header ->\n"
143 " bootRecordID = %s\n"
144 " NoOfBootImageBlocks = %d\n"
145 " NoOfBinaryPartitions = %d\n"
146 " NoOfBDTLPartitions = %d\n"
147 " BlockMultiplerBits = %d\n"
149 " OsakVersion = 0x%x\n"
150 " PercentUsed = %d\n",
151 mh->bootRecordID, mh->NoOfBootImageBlocks,
152 mh->NoOfBinaryPartitions,
153 mh->NoOfBDTLPartitions,
154 mh->BlockMultiplierBits, mh->FormatFlags,
155 mh->OsakVersion, mh->PercentUsed);
157 if (mh->NoOfBDTLPartitions == 0) {
158 printk(KERN_WARNING "INFTL: Media Header sanity check "
159 "failed: NoOfBDTLPartitions (%d) == 0, "
160 "must be at least 1\n", mh->NoOfBDTLPartitions);
164 if ((mh->NoOfBDTLPartitions + mh->NoOfBinaryPartitions) > 4) {
165 printk(KERN_WARNING "INFTL: Media Header sanity check "
166 "failed: Total Partitions (%d) > 4, "
167 "BDTL=%d Binary=%d\n", mh->NoOfBDTLPartitions +
168 mh->NoOfBinaryPartitions,
169 mh->NoOfBDTLPartitions,
170 mh->NoOfBinaryPartitions);
174 if (mh->BlockMultiplierBits > 1) {
175 printk(KERN_WARNING "INFTL: sorry, we don't support "
176 "UnitSizeFactor 0x%02x\n",
177 mh->BlockMultiplierBits);
179 } else if (mh->BlockMultiplierBits == 1) {
180 printk(KERN_WARNING "INFTL: support for INFTL with "
181 "UnitSizeFactor 0x%02x is experimental\n",
182 mh->BlockMultiplierBits);
183 inftl->EraseSize = inftl->mbd.mtd->erasesize <<
184 mh->BlockMultiplierBits;
185 inftl->nb_blocks = (u32)inftl->mbd.mtd->size / inftl->EraseSize;
186 block >>= mh->BlockMultiplierBits;
189 /* Scan the partitions */
190 for (i = 0; (i < 4); i++) {
191 ip = &mh->Partitions[i];
192 ip->virtualUnits = le32_to_cpu(ip->virtualUnits);
193 ip->firstUnit = le32_to_cpu(ip->firstUnit);
194 ip->lastUnit = le32_to_cpu(ip->lastUnit);
195 ip->flags = le32_to_cpu(ip->flags);
196 ip->spareUnits = le32_to_cpu(ip->spareUnits);
197 ip->Reserved0 = le32_to_cpu(ip->Reserved0);
199 pr_debug(" PARTITION[%d] ->\n"
200 " virtualUnits = %d\n"
204 " spareUnits = %d\n",
205 i, ip->virtualUnits, ip->firstUnit,
206 ip->lastUnit, ip->flags,
209 if (ip->Reserved0 != ip->firstUnit) {
210 struct erase_info *instr = &inftl->instr;
212 instr->mtd = inftl->mbd.mtd;
215 * Most likely this is using the
216 * undocumented qiuck mount feature.
217 * We don't support that, we will need
218 * to erase the hidden block for full
221 instr->addr = ip->Reserved0 * inftl->EraseSize;
222 instr->len = inftl->EraseSize;
223 mtd->erase(mtd, instr);
225 if ((ip->lastUnit - ip->firstUnit + 1) < ip->virtualUnits) {
226 printk(KERN_WARNING "INFTL: Media Header "
227 "Partition %d sanity check failed\n"
228 " firstUnit %d : lastUnit %d > "
229 "virtualUnits %d\n", i, ip->lastUnit,
230 ip->firstUnit, ip->Reserved0);
233 if (ip->Reserved1 != 0) {
234 printk(KERN_WARNING "INFTL: Media Header "
235 "Partition %d sanity check failed: "
236 "Reserved1 %d != 0\n",
241 if (ip->flags & INFTL_BDTL)
246 printk(KERN_WARNING "INFTL: Media Header Partition "
247 "sanity check failed:\n No partition "
248 "marked as Disk Partition\n");
252 inftl->nb_boot_blocks = ip->firstUnit;
253 inftl->numvunits = ip->virtualUnits;
254 if (inftl->numvunits > (inftl->nb_blocks -
255 inftl->nb_boot_blocks - 2)) {
256 printk(KERN_WARNING "INFTL: Media Header sanity check "
257 "failed:\n numvunits (%d) > nb_blocks "
258 "(%d) - nb_boot_blocks(%d) - 2\n",
259 inftl->numvunits, inftl->nb_blocks,
260 inftl->nb_boot_blocks);
264 inftl->mbd.size = inftl->numvunits *
265 (inftl->EraseSize / SECTORSIZE);
268 * Block count is set to last used EUN (we won't need to keep
269 * any meta-data past that point).
271 inftl->firstEUN = ip->firstUnit;
272 inftl->lastEUN = ip->lastUnit;
273 inftl->nb_blocks = ip->lastUnit + 1;
276 inftl->PUtable = kmalloc(inftl->nb_blocks * sizeof(u16), GFP_KERNEL);
277 if (!inftl->PUtable) {
278 printk(KERN_WARNING "INFTL: allocation of PUtable "
279 "failed (%zd bytes)\n",
280 inftl->nb_blocks * sizeof(u16));
284 inftl->VUtable = kmalloc(inftl->nb_blocks * sizeof(u16), GFP_KERNEL);
285 if (!inftl->VUtable) {
286 kfree(inftl->PUtable);
287 printk(KERN_WARNING "INFTL: allocation of VUtable "
288 "failed (%zd bytes)\n",
289 inftl->nb_blocks * sizeof(u16));
293 /* Mark the blocks before INFTL MediaHeader as reserved */
294 for (i = 0; i < inftl->nb_boot_blocks; i++)
295 inftl->PUtable[i] = BLOCK_RESERVED;
296 /* Mark all remaining blocks as potentially containing data */
297 for (; i < inftl->nb_blocks; i++)
298 inftl->PUtable[i] = BLOCK_NOTEXPLORED;
300 /* Mark this boot record (NFTL MediaHeader) block as reserved */
301 inftl->PUtable[block] = BLOCK_RESERVED;
303 /* Read Bad Erase Unit Table and modify PUtable[] accordingly */
304 for (i = 0; i < inftl->nb_blocks; i++) {
306 /* If any of the physical eraseblocks are bad, don't
308 for (physblock = 0; physblock < inftl->EraseSize; physblock += inftl->mbd.mtd->erasesize) {
309 if (inftl->mbd.mtd->block_isbad(inftl->mbd.mtd, i * inftl->EraseSize + physblock))
310 inftl->PUtable[i] = BLOCK_RESERVED;
314 inftl->MediaUnit = block;
322 static int memcmpb(void *a, int c, int n)
325 for (i = 0; i < n; i++) {
326 if (c != ((unsigned char *)a)[i])
333 * check_free_sector: check if a free sector is actually FREE,
334 * i.e. All 0xff in data and oob area.
336 static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
337 int len, int check_oob)
339 u8 buf[SECTORSIZE + inftl->mbd.mtd->oobsize];
340 struct mtd_info *mtd = inftl->mbd.mtd;
344 for (i = 0; i < len; i += SECTORSIZE) {
345 if (mtd->read(mtd, address, SECTORSIZE, &retlen, buf))
347 if (memcmpb(buf, 0xff, SECTORSIZE) != 0)
351 if(inftl_read_oob(mtd, address, mtd->oobsize,
352 &retlen, &buf[SECTORSIZE]) < 0)
354 if (memcmpb(buf + SECTORSIZE, 0xff, mtd->oobsize) != 0)
357 address += SECTORSIZE;
364 * INFTL_format: format a Erase Unit by erasing ALL Erase Zones in the Erase
365 * Unit and Update INFTL metadata. Each erase operation is
366 * checked with check_free_sectors.
368 * Return: 0 when succeed, -1 on error.
370 * ToDo: 1. Is it necessary to check_free_sector after erasing ??
372 int INFTL_formatblock(struct INFTLrecord *inftl, int block)
375 struct inftl_unittail uci;
376 struct erase_info *instr = &inftl->instr;
377 struct mtd_info *mtd = inftl->mbd.mtd;
380 pr_debug("INFTL: INFTL_formatblock(inftl=%p,block=%d)\n", inftl, block);
382 memset(instr, 0, sizeof(struct erase_info));
384 /* FIXME: Shouldn't we be setting the 'discarded' flag to zero
387 /* Use async erase interface, test return code */
388 instr->mtd = inftl->mbd.mtd;
389 instr->addr = block * inftl->EraseSize;
390 instr->len = inftl->mbd.mtd->erasesize;
391 /* Erase one physical eraseblock at a time, even though the NAND api
392 allows us to group them. This way we if we have a failure, we can
393 mark only the failed block in the bbt. */
394 for (physblock = 0; physblock < inftl->EraseSize;
395 physblock += instr->len, instr->addr += instr->len) {
396 mtd->erase(inftl->mbd.mtd, instr);
398 if (instr->state == MTD_ERASE_FAILED) {
399 printk(KERN_WARNING "INFTL: error while formatting block %d\n",
405 * Check the "freeness" of Erase Unit before updating metadata.
406 * FixMe: is this check really necessary? Since we have check
407 * the return code after the erase operation.
409 if (check_free_sectors(inftl, instr->addr, instr->len, 1) != 0)
413 uci.EraseMark = cpu_to_le16(ERASE_MARK);
414 uci.EraseMark1 = cpu_to_le16(ERASE_MARK);
419 instr->addr = block * inftl->EraseSize + SECTORSIZE * 2;
420 if (inftl_write_oob(mtd, instr->addr + 8, 8, &retlen, (char *)&uci) < 0)
424 /* could not format, update the bad block table (caller is responsible
425 for setting the PUtable to BLOCK_RESERVED on failure) */
426 inftl->mbd.mtd->block_markbad(inftl->mbd.mtd, instr->addr);
431 * format_chain: Format an invalid Virtual Unit chain. It frees all the Erase
432 * Units in a Virtual Unit Chain, i.e. all the units are disconnected.
434 * Since the chain is invalid then we will have to erase it from its
435 * head (normally for INFTL we go from the oldest). But if it has a
436 * loop then there is no oldest...
438 static void format_chain(struct INFTLrecord *inftl, unsigned int first_block)
440 unsigned int block = first_block, block1;
442 printk(KERN_WARNING "INFTL: formatting chain at block %d\n",
446 block1 = inftl->PUtable[block];
448 printk(KERN_WARNING "INFTL: formatting block %d\n", block);
449 if (INFTL_formatblock(inftl, block) < 0) {
451 * Cannot format !!!! Mark it as Bad Unit,
453 inftl->PUtable[block] = BLOCK_RESERVED;
455 inftl->PUtable[block] = BLOCK_FREE;
458 /* Goto next block on the chain */
461 if (block == BLOCK_NIL || block >= inftl->lastEUN)
466 void INFTL_dumptables(struct INFTLrecord *s)
470 pr_debug("-------------------------------------------"
471 "----------------------------------\n");
473 pr_debug("VUtable[%d] ->", s->nb_blocks);
474 for (i = 0; i < s->nb_blocks; i++) {
476 pr_debug("\n%04x: ", i);
477 pr_debug("%04x ", s->VUtable[i]);
480 pr_debug("\n-------------------------------------------"
481 "----------------------------------\n");
483 pr_debug("PUtable[%d-%d=%d] ->", s->firstEUN, s->lastEUN, s->nb_blocks);
484 for (i = 0; i <= s->lastEUN; i++) {
486 pr_debug("\n%04x: ", i);
487 pr_debug("%04x ", s->PUtable[i]);
490 pr_debug("\n-------------------------------------------"
491 "----------------------------------\n");
493 pr_debug("INFTL ->\n"
495 " h/s/c = %d/%d/%d\n"
499 " numfreeEUNs = %d\n"
500 " LastFreeEUN = %d\n"
502 " nb_boot_blocks = %d",
503 s->EraseSize, s->heads, s->sectors, s->cylinders,
504 s->numvunits, s->firstEUN, s->lastEUN, s->numfreeEUNs,
505 s->LastFreeEUN, s->nb_blocks, s->nb_boot_blocks);
507 pr_debug("\n-------------------------------------------"
508 "----------------------------------\n");
511 void INFTL_dumpVUchains(struct INFTLrecord *s)
513 int logical, block, i;
515 pr_debug("-------------------------------------------"
516 "----------------------------------\n");
518 pr_debug("INFTL Virtual Unit Chains:\n");
519 for (logical = 0; logical < s->nb_blocks; logical++) {
520 block = s->VUtable[logical];
521 if (block > s->nb_blocks)
523 pr_debug(" LOGICAL %d --> %d ", logical, block);
524 for (i = 0; i < s->nb_blocks; i++) {
525 if (s->PUtable[block] == BLOCK_NIL)
527 block = s->PUtable[block];
528 pr_debug("%d ", block);
533 pr_debug("-------------------------------------------"
534 "----------------------------------\n");
537 int INFTL_mount(struct INFTLrecord *s)
539 struct mtd_info *mtd = s->mbd.mtd;
540 unsigned int block, first_block, prev_block, last_block;
541 unsigned int first_logical_block, logical_block, erase_mark;
542 int chain_length, do_format_chain;
543 struct inftl_unithead1 h0;
544 struct inftl_unittail h1;
549 pr_debug("INFTL: INFTL_mount(inftl=%p)\n", s);
551 /* Search for INFTL MediaHeader and Spare INFTL Media Header */
552 if (find_boot_record(s) < 0) {
553 printk(KERN_WARNING "INFTL: could not find valid boot record?\n");
557 /* Init the logical to physical table */
558 for (i = 0; i < s->nb_blocks; i++)
559 s->VUtable[i] = BLOCK_NIL;
561 logical_block = block = BLOCK_NIL;
563 /* Temporary buffer to store ANAC numbers. */
564 ANACtable = kcalloc(s->nb_blocks, sizeof(u8), GFP_KERNEL);
566 printk(KERN_WARNING "INFTL: allocation of ANACtable "
567 "failed (%zd bytes)\n",
568 s->nb_blocks * sizeof(u8));
573 * First pass is to explore each physical unit, and construct the
574 * virtual chains that exist (newest physical unit goes into VUtable).
575 * Any block that is in any way invalid will be left in the
576 * NOTEXPLORED state. Then at the end we will try to format it and
579 pr_debug("INFTL: pass 1, explore each unit\n");
580 for (first_block = s->firstEUN; first_block <= s->lastEUN; first_block++) {
581 if (s->PUtable[first_block] != BLOCK_NOTEXPLORED)
585 first_logical_block = BLOCK_NIL;
586 last_block = BLOCK_NIL;
589 for (chain_length = 0; ; chain_length++) {
591 if ((chain_length == 0) &&
592 (s->PUtable[block] != BLOCK_NOTEXPLORED)) {
593 /* Nothing to do here, onto next block */
597 if (inftl_read_oob(mtd, block * s->EraseSize + 8,
598 8, &retlen, (char *)&h0) < 0 ||
599 inftl_read_oob(mtd, block * s->EraseSize +
600 2 * SECTORSIZE + 8, 8, &retlen,
602 /* Should never happen? */
607 logical_block = le16_to_cpu(h0.virtualUnitNo);
608 prev_block = le16_to_cpu(h0.prevUnitNo);
609 erase_mark = le16_to_cpu((h1.EraseMark | h1.EraseMark1));
610 ANACtable[block] = h0.ANAC;
612 /* Previous block is relative to start of Partition */
613 if (prev_block < s->nb_blocks)
614 prev_block += s->firstEUN;
616 /* Already explored partial chain? */
617 if (s->PUtable[block] != BLOCK_NOTEXPLORED) {
618 /* Check if chain for this logical */
619 if (logical_block == first_logical_block) {
620 if (last_block != BLOCK_NIL)
621 s->PUtable[last_block] = block;
626 /* Check for invalid block */
627 if (erase_mark != ERASE_MARK) {
628 printk(KERN_WARNING "INFTL: corrupt block %d "
629 "in chain %d, chain length %d, erase "
630 "mark 0x%x?\n", block, first_block,
631 chain_length, erase_mark);
633 * Assume end of chain, probably incomplete
636 if (chain_length == 0)
641 /* Check for it being free already then... */
642 if ((logical_block == BLOCK_FREE) ||
643 (logical_block == BLOCK_NIL)) {
644 s->PUtable[block] = BLOCK_FREE;
648 /* Sanity checks on block numbers */
649 if ((logical_block >= s->nb_blocks) ||
650 ((prev_block >= s->nb_blocks) &&
651 (prev_block != BLOCK_NIL))) {
652 if (chain_length > 0) {
653 printk(KERN_WARNING "INFTL: corrupt "
654 "block %d in chain %d?\n",
661 if (first_logical_block == BLOCK_NIL) {
662 first_logical_block = logical_block;
664 if (first_logical_block != logical_block) {
665 /* Normal for folded chain... */
671 * Current block is valid, so if we followed a virtual
672 * chain to get here then we can set the previous
673 * block pointer in our PUtable now. Then move onto
674 * the previous block in the chain.
676 s->PUtable[block] = BLOCK_NIL;
677 if (last_block != BLOCK_NIL)
678 s->PUtable[last_block] = block;
682 /* Check for end of chain */
683 if (block == BLOCK_NIL)
686 /* Validate next block before following it... */
687 if (block > s->lastEUN) {
688 printk(KERN_WARNING "INFTL: invalid previous "
689 "block %d in chain %d?\n", block,
696 if (do_format_chain) {
697 format_chain(s, first_block);
702 * Looks like a valid chain then. It may not really be the
703 * newest block in the chain, but it is the newest we have
704 * found so far. We might update it in later iterations of
705 * this loop if we find something newer.
707 s->VUtable[first_logical_block] = first_block;
708 logical_block = BLOCK_NIL;
714 * Second pass, check for infinite loops in chains. These are
715 * possible because we don't update the previous pointers when
716 * we fold chains. No big deal, just fix them up in PUtable.
718 pr_debug("INFTL: pass 2, validate virtual chains\n");
719 for (logical_block = 0; logical_block < s->numvunits; logical_block++) {
720 block = s->VUtable[logical_block];
721 last_block = BLOCK_NIL;
723 /* Check for free/reserved/nil */
724 if (block >= BLOCK_RESERVED)
727 ANAC = ANACtable[block];
728 for (i = 0; i < s->numvunits; i++) {
729 if (s->PUtable[block] == BLOCK_NIL)
731 if (s->PUtable[block] > s->lastEUN) {
732 printk(KERN_WARNING "INFTL: invalid prev %d, "
733 "in virtual chain %d\n",
734 s->PUtable[block], logical_block);
735 s->PUtable[block] = BLOCK_NIL;
738 if (ANACtable[block] != ANAC) {
740 * Chain must point back to itself. This is ok,
741 * but we will need adjust the tables with this
742 * newest block and oldest block.
744 s->VUtable[logical_block] = block;
745 s->PUtable[last_block] = BLOCK_NIL;
751 block = s->PUtable[block];
754 if (i >= s->nb_blocks) {
756 * Uhoo, infinite chain with valid ANACS!
757 * Format whole chain...
759 format_chain(s, first_block);
764 INFTL_dumpVUchains(s);
767 * Third pass, format unreferenced blocks and init free block count.
770 s->LastFreeEUN = BLOCK_NIL;
772 pr_debug("INFTL: pass 3, format unused blocks\n");
773 for (block = s->firstEUN; block <= s->lastEUN; block++) {
774 if (s->PUtable[block] == BLOCK_NOTEXPLORED) {
775 printk("INFTL: unreferenced block %d, formatting it\n",
777 if (INFTL_formatblock(s, block) < 0)
778 s->PUtable[block] = BLOCK_RESERVED;
780 s->PUtable[block] = BLOCK_FREE;
782 if (s->PUtable[block] == BLOCK_FREE) {
784 if (s->LastFreeEUN == BLOCK_NIL)
785 s->LastFreeEUN = block;