Skip to content

Commit

Permalink
lxfs: allocate metadata buffer for each mountpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Sep 30, 2024
1 parent cbd9d85 commit 5483202
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/lxfs/src/include/lxfs/lxfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ typedef struct Mountpoint {

uint64_t root; // root directory block
void *blockTableBuffer; // of size blockSizeBytes
void *dataBuffer; // likewise of size blockSizeBytes
void *dataBuffer; // of size 2 * blockSizeBytes
void *meta; // metadata buffer, blockSizeBytes
} Mountpoint;

typedef struct {
Expand Down
12 changes: 12 additions & 0 deletions fs/lxfs/src/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ void lxfsMount(MountCommand *cmd) {
return;
}

void *meta = malloc(blockSizeBytes);
if(!meta) {
cmd->header.header.status = -ENOMEM;
close(fd);
free(id);
free(buffer);
free(buffer2);
luxSendDependency(cmd);
return;
}

Mountpoint *mp = allocateMP();
if(!mp) {
cmd->header.header.status = -ENOMEM;
Expand All @@ -123,6 +134,7 @@ void lxfsMount(MountCommand *cmd) {
mp->root = id->rootBlock;
mp->blockTableBuffer = buffer;
mp->dataBuffer = buffer2;
mp->meta = meta;

luxLogf(KPRINT_LEVEL_DEBUG, "- %d bytes per sector, %d sectors per block\n", mp->sectorSize, mp->blockSize);
luxLogf(KPRINT_LEVEL_DEBUG, "- root directory at block %d\n", mp->root);
Expand Down

0 comments on commit 5483202

Please sign in to comment.