diff options
| author | bhgv <bhgv.empire@gmail.com> | 2018-03-01 16:54:45 +0200 |
|---|---|---|
| committer | bhgv <bhgv.empire@gmail.com> | 2018-03-01 16:54:45 +0200 |
| commit | b786f20bbab5a59046aa78a2c6c2a11536497202 (patch) | |
| tree | 0851ecdec889eb9b7ba3751cc04d4f0b474e4a9e /libnandfs/formatblock.c | |
inferno-os tree was separated from the inferno-os-android (separated from the Android driver)
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 0000000..146449b --- /dev/null +++ b/libnandfs/formatblock.c @@ -0,0 +1,57 @@ +#include "logfsos.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; +} |
