aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/venti/srv/zeropart.c
blob: fe75c81df9ee152941a3e16a479904cc5b373b0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "stdinc.h"
#include "dat.h"
#include "fns.h"

void
zeropart(Part *part, int blocksize)
{
	ZBlock *b;
	u64int addr;
	int w;

	fprint(2, "clearing the partition\n");
//fprint(2, "NOT!\n");
//return;
//b=alloczblock(MaxIoSize, 1, blocksize);
//freezblock(b);
	b = alloczblock(MaxIoSize, 1, blocksize);

	w = 0;
	for(addr = PartBlank; addr + MaxIoSize <= part->size; addr += MaxIoSize){
		if(writepart(part, addr, b->data, MaxIoSize) < 0)
			sysfatal("can't initialize %s, writing block %d failed: %r", part->name, w);
		w++;
	}

	for(; addr + blocksize <= part->size; addr += blocksize)
		if(writepart(part, addr, b->data, blocksize) < 0)
			sysfatal("can't initialize %s: %r", part->name);

	freezblock(b);
}