Skip to content

Commit

Permalink
lxfs: allocate temp data buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Sep 29, 2024
1 parent f1bab31 commit 0c85003
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions fs/lxfs/src/include/lxfs/lxfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ typedef struct Mountpoint {

uint64_t root; // root directory block
void *blockTableBuffer; // of size blockSizeBytes
void *dataBuffer; // likewise of size blockSizeBytes
} Mountpoint;

typedef struct {
Expand Down
14 changes: 13 additions & 1 deletion fs/lxfs/src/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,23 @@ void lxfsMount(MountCommand *cmd) {
return;
}

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

Mountpoint *mp = allocateMP();
if(!mp) {
cmd->header.header.status = -ENOMEM;
close(fd);
free(id);
free(buffer);
free(buffer2);
luxSendDependency(cmd);
return;
}
Expand All @@ -97,8 +108,9 @@ void lxfsMount(MountCommand *cmd) {
mp->sectorSize = sectorSize;
mp->blockSize = blockSize;
mp->blockSizeBytes = blockSizeBytes;
mp->blockTableBuffer = buffer;
mp->root = id->rootBlock;
mp->blockTableBuffer = buffer;
mp->dataBuffer = buffer2;

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 0c85003

Please sign in to comment.