code: 9ferno

ref: 600bbfe4aaa9ad0f73d8d73eef1b7670e5f7d3a3
dir: /libnandfs/reformatblock.c/

View raw version
#include "logfsos.h"
#include "logfs.h"
#include "nandfs.h"
#include "local.h"

char *
nandfsreformatblock(Nandfs *nandfs, long block, uchar tag, ulong path, int xcount, long *xdata, void *llsave, int *markedbad)
{
	int bad;
	char *errmsg;
	NandfsBlockData *d;
	long nerase;

	if (nandfs->blockdata == nil)
		return Eperm;

	nerase = *(ulong *)llsave;

	errmsg = nandfsformatblock(nandfs, block, tag, path,
		nandfs->baseblock, nandfs->limitblock - nandfs->baseblock, xcount, xdata, &nerase, &bad);

	if (markedbad)
		*markedbad = bad;
	if (errmsg)
		return errmsg;

	d = &nandfs->blockdata[block];
	d->tag = bad ? LogfsTbad : tag;
	d->path = path;
	d->nerase = nerase;
	d->partial = 0;

	return nil;
}