xref: /inferno-os/module/diskblocks.m (revision 46439007cf417cbd9ac8049bb4122c890097a0fa)
1Diskblocks: module {
2	PATH: con "/dis/lib/diskblocks.dis";
3
4	Block: adt {
5		addr:	big;	# address on file
6		n:	int;	# size in bytes
7	};
8
9	Disk: adt {
10		fd: ref Sys->FD;
11		addr: big;		# length of temp file
12		free: array of list of ref Block;
13		maxblock:	int;
14		gran:	int;
15		lock:	chan of int;
16
17		init:	fn(fd: ref Sys->FD, gran: int, maxblock: int): ref Disk;
18		new:	fn(d: self ref Disk, n: int): ref Block;
19		release:	fn(d: self ref Disk, b: ref Block);
20		read:	fn(d: self ref Disk, b: ref Block, a: array of byte, n: int): int;
21		write:	fn(d: self ref Disk, b: ref Block, a: array of byte, n: int): ref Block;
22	};
23
24	init: fn();
25	tempfile: fn(): ref Sys->FD;
26};
27