diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
| commit | 37da2899f40661e3e9631e497da8dc59b971cbd0 (patch) | |
| tree | cbc6d4680e347d906f5fa7fca73214418741df72 /libnandfs/formatblock.c | |
| parent | 54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff) | |
20060303a
Diffstat (limited to 'libnandfs/formatblock.c')
| -rw-r--r-- | libnandfs/formatblock.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/libnandfs/formatblock.c b/libnandfs/formatblock.c new file mode 100644 index 00000000..8f37e2c9 --- /dev/null +++ b/libnandfs/formatblock.c @@ -0,0 +1,57 @@ +#include "lib9.h" +#include "logfs.h" +#include "nandfs.h" +#include "local.h" + +char * +nandfsformatblock(Nandfs *nandfs, long absblock, uchar tag, ulong path, long baseblock, long sizeinblocks, int xcount, long *xdata, void *llsave, int *markedbad) +{ + int page; + char *rv; + NandfsTags t; + int ppb; + + if (markedbad) + *markedbad = 0; + + t.tag = tag; + t.magic = LogfsMagic; + t.nerase = *(ulong *)llsave < NandfsNeraseMask ? *(ulong *)llsave + 1 : 1; + + ppb = 1 << nandfs->ll.l2pagesperblock; + for (page = 0, rv = nil; rv == nil && page < ppb; page++) { + if (tag == LogfsTboot && page > 0 && page < xcount + 3) { + switch (page) { + case 1: + t.path = baseblock; + break; + case 2: + t.path = sizeinblocks; + break; + default: + t.path = xdata[page - 3]; + break; + } + } + else + t.path = path; + rv = nandfswritepageauxiliary(nandfs, &t, absblock, page); + if (rv) + break; + } + + if (rv) { + if (strcmp(rv, Eio) != 0) + return rv; + if (markedbad) { + *markedbad = 1; + rv = nandfsmarkabsblockbad(nandfs, absblock); + if (strcmp(rv, Eio) != 0) + return rv; + return nil; + } + return rv; + } + + return nil; +} |
