From 37da2899f40661e3e9631e497da8dc59b971cbd0 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Fri, 22 Dec 2006 17:07:39 +0000 Subject: 20060303a --- libnandfs/formatblock.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 libnandfs/formatblock.c (limited to 'libnandfs/formatblock.c') 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; +} -- cgit v1.2.3