/* * Initialize the free block bitmap. */ static void initfreemap(uint32_t fsblocks) { uint32_t freemapbits = SFS_FREEMAPBITS(fsblocks); uint32_t freemapblocks = SFS_FREEMAPBLOCKS(fsblocks); uint32_t i; if (freemapblocks > MAXFREEMAPBLOCKS) { errx(1, "Filesystem too large -- " "increase MAXFREEMAPBLOCKS and recompile"); } /* mark the superblock and root inode in use */ allocblock(SFS_SUPER_BLOCK); allocblock(SFS_ROOTDIR_INO); /* the freemap blocks must be in use */ for (i=0; i<freemapblocks; i++) { allocblock(SFS_FREEMAP_START + i); } /* all blocks in the freemap but past the volume end are "in use" */ for (i=fsblocks; i<freemapbits; i++) { allocblock(i); } }
/* Create a string in the heap. */ long newstring(avm* vm, char* s) { objheader* obj; heap* hp = &vm->hp; long size = strlen(s)+1; long offset = allocblock(vm, size); obj = (objheader*)getobj(hp->heap, offset); obj->type = TSTRING; obj->size = size; obj->offset = (long)sizeof(mblock)+offset; strcpy(getdata(hp->heap, offset), (const char*)s); return offset; }