ref: 8a918ea16f8f8c248311d292a8aac56cf89e219b
parent: 0a0dc432673d0c5f0902b0d053e08c8fe41a0eea
author: Noam Preil <noam@pixelhero.dev>
date: Sun Dec 24 19:07:35 EST 2023
cleanup
--- a/disk.c
+++ b/disk.c
@@ -61,9 +61,9 @@
{
u8int *buf;
u16int bentries;
- u64int bucket = U32GET(score) / index.div;
u16int entry;
u64int aindex;
+ u64int bucket = U32GET(score) / index.div;
VtISect sect = isectforbucket(bucket);
bucket -= sect.start;
buf = malloc(sect.blocksize);
@@ -73,7 +73,7 @@
sysfatal("Failed to read bucket");
bentries = U16GET(buf);
if(sect.bucketmagic && U32GET(buf + 2) != sect.bucketmagic)
- sysfatal("index is corrupt: invalid bucket magic: sect %lux, buck %lux", sect.bucketmagic, U32GET(buf + 2));
+ sysfatal("index is corrupt: invalid bucket magic: sect %ux, buck %ux", sect.bucketmagic, U32GET(buf + 2));
if(!bucketlookup(buf + 6, bentries, score, &entry))
sysfatal("entry not found in bucket");
*addr = U64GET((buf + 6 + (entry * IEntrySize) + 26));
@@ -122,7 +122,6 @@
readclump(uchar *dst, VtArena arena, u64int addr, u8int blocks)
{
uchar *buf = malloc(blocks << ABlockLog);
- u32int magic;
u16int size;
size = blocks<<ABlockLog;
vtreadarena(arena, addr, buf, &size);
@@ -194,20 +193,16 @@
static void
loadarena(VtArena *arena)
{
- u32int magic, version;
+ u32int version;
char *buf = malloc(arena->blocksize);
u8int *p = (void*)buf;
if(pread(arena->fd, buf, arena->blocksize, arena->base + arena->size) != arena->blocksize)
sysfatal("failed to pread");
- magic = U32GET(p);
version = U32GET(p + 4);
if(strncmp(arena->name, buf + 8, strlen(arena->name)) != 0)
sysfatal("arena name mismatch: %s vs %s, ver %d", arena->name, buf + 8, version);
-
}
-// FIXME see initarenapart and initarena/loadarena in venti/venti
-
static void
initarena(VtArena *arena, int fd, MapEntry entry, u32int blocksize)
{
@@ -221,7 +216,7 @@
}
static void
-readarenatable(int fd, u32int tabbase, u32int tabsize, char *path, u32int blocksize)
+readarenatable(int fd, u32int tabbase, u32int tabsize, u32int blocksize)
{
Biobufhdr bio;
char *buf;
@@ -247,11 +242,8 @@
initarenapart(char *path)
{
u32int version, magic, blocksize, arenabase, tabbase, tabsize;
- u64int size;
char buf[HeadSize];
u8int *p = (void*)buf;
- MapEntry *map;
- u32int nmap;
int fd;
if((fd = open(path, OREAD)) < 0)
@@ -273,9 +265,7 @@
if(tabbase >= arenabase)
sysfatal("arena partition table overlaps with storage");
tabsize = arenabase - tabbase;
- size = partlen(fd, path) & ~(u64int)(blocksize - 1);
-
- readarenatable(fd, tabbase, tabsize, path, blocksize);
+ readarenatable(fd, tabbase, tabsize, blocksize);
}
void