extract fs into library
This commit is contained in:
parent
e28d9d9749
commit
a4a0332846
@ -33,6 +33,11 @@ target_link_libraries(emu PRIVATE opts isa SDL3::SDL3)
|
||||
add_executable(asm asm.c)
|
||||
target_link_libraries(asm PRIVATE opts isa)
|
||||
|
||||
add_executable(fs fs.c)
|
||||
add_library(fs STATIC fs.c)
|
||||
target_link_libraries(fs PRIVATE opts)
|
||||
|
||||
add_executable(fscli fscli.c)
|
||||
target_link_libraries(fscli PRIVATE opts fs)
|
||||
|
||||
|
||||
|
||||
|
||||
240
src/fs.c
240
src/fs.c
@ -1,3 +1,4 @@
|
||||
#include "fs.h"
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@ -5,16 +6,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
constexpr size_t block_size = 512;
|
||||
typedef uint16_t Block[block_size];
|
||||
|
||||
constexpr size_t size_of_block = sizeof(Block) / sizeof(uint16_t);
|
||||
|
||||
typedef struct {
|
||||
Block *blocks;
|
||||
size_t blocks_count;
|
||||
} Disk;
|
||||
|
||||
void disk_read(Disk *d, Block block, uint16_t id)
|
||||
{
|
||||
assert(id < d->blocks_count);
|
||||
@ -28,33 +19,16 @@ void disk_write(Disk *d, const Block block, uint16_t id)
|
||||
}
|
||||
|
||||
constexpr size_t blocks_cap = block_size * 16;
|
||||
constexpr size_t inode_size = 16;
|
||||
constexpr size_t direentry_max_size = 64;
|
||||
constexpr size_t inodes_per_block = block_size / inode_size;
|
||||
constexpr size_t inodeblocks_cap = 32;
|
||||
constexpr size_t inodes_cap = inodeblocks_cap * inodes_per_block;
|
||||
constexpr size_t inodebitmap_size = inodes_cap / 16;
|
||||
|
||||
constexpr size_t inode_blocks_cap = 12;
|
||||
constexpr size_t inode_ndir_blocks_count = inode_blocks_cap - 1;
|
||||
constexpr size_t inode_ind_block_idx = inode_ndir_blocks_count;
|
||||
constexpr size_t inode_name_cap = 61;
|
||||
|
||||
typedef enum : uint16_t {
|
||||
INode_File,
|
||||
INode_Dir,
|
||||
} INodeTy;
|
||||
|
||||
typedef struct {
|
||||
uint16_t id;
|
||||
uint16_t mode;
|
||||
uint16_t blocks_count;
|
||||
uint16_t last_block_size;
|
||||
uint16_t blocks[inode_blocks_cap];
|
||||
} INode;
|
||||
|
||||
static_assert(sizeof(INode) / sizeof(uint16_t) == inode_size);
|
||||
|
||||
typedef struct {
|
||||
uint16_t inode;
|
||||
uint16_t next;
|
||||
@ -64,15 +38,6 @@ typedef struct {
|
||||
|
||||
static_assert(sizeof(DirEntry) / sizeof(uint16_t) == direentry_max_size);
|
||||
|
||||
typedef struct {
|
||||
uint16_t blocks_count;
|
||||
uint16_t inodeblocks_count;
|
||||
uint16_t inodeblocks[inodeblocks_cap];
|
||||
uint16_t inodebitmap[inodebitmap_size];
|
||||
} Superblock;
|
||||
|
||||
static_assert(sizeof(Superblock) <= sizeof(Block));
|
||||
|
||||
static size_t direntry_size(const DirEntry *entry)
|
||||
{
|
||||
return (sizeof(entry->inode) + sizeof(entry->next) + sizeof(entry->name_len)
|
||||
@ -80,16 +45,6 @@ static size_t direntry_size(const DirEntry *entry)
|
||||
/ sizeof(uint16_t);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
Disk *disk;
|
||||
uint16_t block_offset;
|
||||
uint16_t blocks_count;
|
||||
Block *superblock;
|
||||
Superblock *sb;
|
||||
Block *block_bitmap;
|
||||
bool out_of_sync;
|
||||
} Fs;
|
||||
|
||||
static void bitmap_set(uint16_t bitmap[], uint16_t id, bool v)
|
||||
{
|
||||
uint16_t *row = &bitmap[id / 16];
|
||||
@ -526,11 +481,6 @@ void fs_remove(Fs *fs, INode *inode, INode *parent)
|
||||
deallocate_inode(fs, inode->id);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
uint16_t inode;
|
||||
char name[inode_name_cap + 1];
|
||||
} ListEntry;
|
||||
|
||||
struct list_block_entries_fn_args {
|
||||
Fs *fs;
|
||||
ListEntry *entries;
|
||||
@ -699,6 +649,37 @@ void fs_dump_block_dec(Fs *fs, uint16_t block_id)
|
||||
}
|
||||
}
|
||||
|
||||
void fs_dump_block_char(Fs *fs, uint16_t block_id)
|
||||
{
|
||||
Block block;
|
||||
read_block(fs, block, block_id);
|
||||
|
||||
char conversions[256] = {
|
||||
['\0'] = '0',
|
||||
['\t'] = 't',
|
||||
['\n'] = 'n',
|
||||
['\f'] = 'f',
|
||||
['\b'] = 'b',
|
||||
};
|
||||
|
||||
constexpr size_t values_per_row = 16;
|
||||
for (size_t i = 0; i < block_size; i += values_per_row) {
|
||||
for (size_t j = 0; j < values_per_row; ++j) {
|
||||
char ch = block[i + j];
|
||||
printf("%s", j ? " " : "");
|
||||
if (ch == ' ')
|
||||
printf("' '");
|
||||
else if (ch > ' ')
|
||||
printf("%2c ", ch);
|
||||
else if (conversions[(size_t)ch])
|
||||
printf("\\%-2c", conversions[(size_t)ch]);
|
||||
else
|
||||
printf("\\x%-2x", ch);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void fs_dump_direntry_block(Fs *fs, uint16_t block_id)
|
||||
{
|
||||
Block block;
|
||||
@ -721,160 +702,3 @@ void fs_dump_direntry_block(Fs *fs, uint16_t block_id)
|
||||
i += 1;
|
||||
} while (entry.next != 0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
(void)argc, (void)argv;
|
||||
// assert(argc >= 2);
|
||||
// const char *output_filename = argv[1];
|
||||
|
||||
constexpr size_t amount_of_blocks = 128;
|
||||
|
||||
Disk disk = {
|
||||
.blocks = calloc(amount_of_blocks, sizeof(Block)),
|
||||
.blocks_count = amount_of_blocks,
|
||||
};
|
||||
|
||||
Fs fs_val;
|
||||
Fs *fs = &fs_val;
|
||||
|
||||
fs_init(fs, &disk, 0, amount_of_blocks);
|
||||
fs_sync(fs);
|
||||
|
||||
while (true) {
|
||||
char command[32];
|
||||
printf("> ");
|
||||
if (scanf(" %31s", command) != 1)
|
||||
break;
|
||||
|
||||
if (strcmp(command, "q") == 0) {
|
||||
break;
|
||||
} else if (strcmp(command, "h") == 0) {
|
||||
printf("h help\n"
|
||||
"fs print fs info\n"
|
||||
"sb print superblock\n"
|
||||
"bm print block bitmap\n"
|
||||
"in i print inode[i]\n"
|
||||
"bh i print block[i] as hex\n"
|
||||
"bd i print block[i] as decimal\n"
|
||||
"deb i print block[i] as dir entry\n"
|
||||
"root print root inode id\n"
|
||||
"mkdir i n make dir with name n in inode[i]\n"
|
||||
"touch i n make file with name n in inode[i]\n"
|
||||
"rm p i remove inode[i] from dir inode[p]\n"
|
||||
"ls i list entries in inode[i]\n"
|
||||
"w i write to inode[i]\n"
|
||||
"r i read from inode[i]\n"
|
||||
"");
|
||||
} else if (strcmp(command, "fs") == 0) {
|
||||
fs_dump_info(fs);
|
||||
} else if (strcmp(command, "sb") == 0) {
|
||||
fs_dump_superblock(fs);
|
||||
} else if (strcmp(command, "bm") == 0) {
|
||||
fs_dump_block_bitmap(fs);
|
||||
} else if (strcmp(command, "in") == 0) {
|
||||
uint16_t inode_id;
|
||||
if (scanf(" %hu", &inode_id) != 1)
|
||||
goto malformed_command;
|
||||
fs_dump_inode(fs, inode_id);
|
||||
} else if (strcmp(command, "bh") == 0) {
|
||||
uint16_t block_id;
|
||||
if (scanf(" %hu", &block_id) != 1)
|
||||
goto malformed_command;
|
||||
fs_dump_block_hex(fs, block_id);
|
||||
} else if (strcmp(command, "bd") == 0) {
|
||||
uint16_t block_id;
|
||||
if (scanf(" %hu", &block_id) != 1)
|
||||
goto malformed_command;
|
||||
fs_dump_block_dec(fs, block_id);
|
||||
} else if (strcmp(command, "deb") == 0) {
|
||||
uint16_t block_id;
|
||||
if (scanf(" %hu", &block_id) != 1)
|
||||
goto malformed_command;
|
||||
fs_dump_direntry_block(fs, block_id);
|
||||
} else if (strcmp(command, "root") == 0) {
|
||||
INode root;
|
||||
fs_root(fs, &root);
|
||||
printf("id = %u\n", root.id);
|
||||
} else if (strcmp(command, "mkdir") == 0) {
|
||||
uint16_t parent_id;
|
||||
char name[62];
|
||||
if (scanf(" %hu %61s", &parent_id, name) != 2)
|
||||
goto malformed_command;
|
||||
INode parent;
|
||||
fs_inode(fs, &parent, parent_id);
|
||||
INode inode;
|
||||
fs_make_dir(fs, &inode, &parent, name);
|
||||
fs_sync(fs);
|
||||
printf("id = %u\n", inode.id);
|
||||
} else if (strcmp(command, "touch") == 0) {
|
||||
uint16_t parent_id;
|
||||
char name[62];
|
||||
if (scanf(" %hu %61s", &parent_id, name) != 2)
|
||||
goto malformed_command;
|
||||
INode parent;
|
||||
fs_inode(fs, &parent, parent_id);
|
||||
INode inode;
|
||||
fs_make_file(fs, &inode, &parent, name);
|
||||
fs_sync(fs);
|
||||
printf("id = %u\n", inode.id);
|
||||
} else if (strcmp(command, "rm") == 0) {
|
||||
uint16_t parent_id;
|
||||
uint16_t inode_id;
|
||||
if (scanf(" %hu %hu", &parent_id, &inode_id) != 2)
|
||||
goto malformed_command;
|
||||
INode parent;
|
||||
fs_inode(fs, &parent, parent_id);
|
||||
INode inode;
|
||||
fs_inode(fs, &inode, inode_id);
|
||||
fs_remove(fs, &inode, &parent);
|
||||
fs_sync(fs);
|
||||
} else if (strcmp(command, "ls") == 0) {
|
||||
uint16_t inode_id;
|
||||
if (scanf(" %hu", &inode_id) != 1)
|
||||
goto malformed_command;
|
||||
INode inode;
|
||||
fs_inode(fs, &inode, inode_id);
|
||||
ListEntry entries[32];
|
||||
size_t entries_size = fs_list(
|
||||
fs, entries, sizeof(entries) / sizeof(entries[0]), &inode);
|
||||
fs_sync(fs);
|
||||
for (size_t i = 0; i < entries_size; ++i)
|
||||
printf("%s\n", entries[i].name);
|
||||
} else if (strcmp(command, "w") == 0) {
|
||||
uint16_t inode_id;
|
||||
if (scanf(" %hu", &inode_id) != 1)
|
||||
goto malformed_command;
|
||||
INode inode;
|
||||
fs_inode(fs, &inode, inode_id);
|
||||
uint16_t buffer[64] = { 0 };
|
||||
size_t i = 0;
|
||||
fgetc(stdin);
|
||||
int ch;
|
||||
while ((ch = fgetc(stdin)) != EOF)
|
||||
buffer[i++] = ch;
|
||||
clearerr(stdin);
|
||||
fs_write(fs, &inode, buffer, i);
|
||||
fs_sync(fs);
|
||||
} else if (strcmp(command, "r") == 0) {
|
||||
uint16_t inode_id;
|
||||
if (scanf(" %hu", &inode_id) != 1)
|
||||
goto malformed_command;
|
||||
INode inode;
|
||||
fs_inode(fs, &inode, inode_id);
|
||||
uint16_t buffer[64] = { 0 };
|
||||
size_t buffer_size = fs_read(fs, &inode, buffer, 64, 0);
|
||||
for (size_t i = 0; i < buffer_size; ++i)
|
||||
fputc(buffer[i], stdout);
|
||||
} else {
|
||||
printf("error: unknown command '%s'\n", command);
|
||||
}
|
||||
|
||||
continue;
|
||||
malformed_command:
|
||||
printf("error: malformed '%s' command\n", command);
|
||||
}
|
||||
|
||||
fs_destroy(fs);
|
||||
free(disk.blocks);
|
||||
}
|
||||
|
||||
88
src/fs.h
Normal file
88
src/fs.h
Normal file
@ -0,0 +1,88 @@
|
||||
#ifndef FS_H
|
||||
#define FS_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
constexpr size_t block_size = 512;
|
||||
typedef uint16_t Block[block_size];
|
||||
constexpr size_t size_of_block = sizeof(Block) / sizeof(uint16_t);
|
||||
|
||||
typedef struct {
|
||||
Block *blocks;
|
||||
size_t blocks_count;
|
||||
} Disk;
|
||||
|
||||
constexpr size_t inode_size = 16;
|
||||
constexpr size_t inode_blocks_cap = 12;
|
||||
|
||||
constexpr size_t inodes_per_block = block_size / inode_size;
|
||||
constexpr size_t inodeblocks_cap = 32;
|
||||
constexpr size_t inodes_cap = inodeblocks_cap * inodes_per_block;
|
||||
constexpr size_t inodebitmap_size = inodes_cap / 16;
|
||||
constexpr size_t inode_name_cap = 61;
|
||||
|
||||
typedef struct {
|
||||
uint16_t id;
|
||||
uint16_t mode;
|
||||
uint16_t blocks_count;
|
||||
uint16_t last_block_size;
|
||||
uint16_t blocks[inode_blocks_cap];
|
||||
} INode;
|
||||
|
||||
static_assert(sizeof(INode) / sizeof(uint16_t) == inode_size);
|
||||
|
||||
typedef struct {
|
||||
uint16_t blocks_count;
|
||||
uint16_t inodeblocks_count;
|
||||
uint16_t inodeblocks[inodeblocks_cap];
|
||||
uint16_t inodebitmap[inodebitmap_size];
|
||||
} Superblock;
|
||||
|
||||
static_assert(sizeof(Superblock) <= sizeof(Block));
|
||||
|
||||
typedef struct {
|
||||
Disk *disk;
|
||||
uint16_t block_offset;
|
||||
uint16_t blocks_count;
|
||||
Block *superblock;
|
||||
Superblock *sb;
|
||||
Block *block_bitmap;
|
||||
bool out_of_sync;
|
||||
} Fs;
|
||||
|
||||
void fs_init(Fs *fs, Disk *disk, uint16_t block_offset, uint16_t blocks_count);
|
||||
void fs_destroy(Fs *fs);
|
||||
void fs_sync(Fs *fs);
|
||||
void fs_root(Fs *fs, INode *out_inode);
|
||||
void fs_inode(Fs *fs, INode *out_inode, uint16_t inode_id);
|
||||
void fs_make_dir(Fs *fs, INode *out_inode, INode *parent, const char *name);
|
||||
void fs_make_file(Fs *fs, INode *out_inode, INode *parent, const char *name);
|
||||
void fs_remove(Fs *fs, INode *inode, INode *parent);
|
||||
|
||||
typedef struct {
|
||||
uint16_t inode;
|
||||
char name[inode_name_cap + 1];
|
||||
} ListEntry;
|
||||
|
||||
size_t fs_list(
|
||||
Fs *fs, ListEntry *entries, size_t entries_cap, const INode *inode);
|
||||
|
||||
uint16_t fs_write(
|
||||
Fs *fs, INode *inode, const uint16_t *buffer, uint16_t buffer_size);
|
||||
uint16_t fs_read(Fs *fs,
|
||||
INode *inode,
|
||||
uint16_t *buffer,
|
||||
uint16_t buffer_size,
|
||||
uint16_t offset);
|
||||
|
||||
void fs_dump_info(Fs *fs);
|
||||
void fs_dump_superblock(Fs *fs);
|
||||
void fs_dump_block_bitmap(Fs *fs);
|
||||
void fs_dump_inode(Fs *fs, uint16_t inode_id);
|
||||
void fs_dump_block_hex(Fs *fs, uint16_t block_id);
|
||||
void fs_dump_block_dec(Fs *fs, uint16_t block_id);
|
||||
void fs_dump_block_char(Fs *fs, uint16_t block_id);
|
||||
void fs_dump_direntry_block(Fs *fs, uint16_t block_id);
|
||||
|
||||
#endif
|
||||
167
src/fscli.c
Normal file
167
src/fscli.c
Normal file
@ -0,0 +1,167 @@
|
||||
#include "fs.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
(void)argc, (void)argv;
|
||||
// assert(argc >= 2);
|
||||
// const char *output_filename = argv[1];
|
||||
|
||||
constexpr size_t amount_of_blocks = 128;
|
||||
|
||||
Disk disk = {
|
||||
.blocks = calloc(amount_of_blocks, sizeof(Block)),
|
||||
.blocks_count = amount_of_blocks,
|
||||
};
|
||||
|
||||
Fs fs_val;
|
||||
Fs *fs = &fs_val;
|
||||
|
||||
fs_init(fs, &disk, 0, amount_of_blocks);
|
||||
fs_sync(fs);
|
||||
|
||||
while (true) {
|
||||
char command[32];
|
||||
printf("> ");
|
||||
if (scanf(" %31s", command) != 1)
|
||||
break;
|
||||
|
||||
if (strcmp(command, "q") == 0) {
|
||||
break;
|
||||
} else if (strcmp(command, "h") == 0) {
|
||||
printf("h help\n"
|
||||
"fs print fs info\n"
|
||||
"sb print superblock\n"
|
||||
"bm print block bitmap\n"
|
||||
"in i print inode[i]\n"
|
||||
"bh i print block[i] as hex\n"
|
||||
"bd i print block[i] as decimals\n"
|
||||
"bc i print block[i] as chars\n"
|
||||
"deb i print block[i] as dir entry\n"
|
||||
"root print root inode id\n"
|
||||
"mkdir i n make dir with name n in inode[i]\n"
|
||||
"touch i n make file with name n in inode[i]\n"
|
||||
"rm p i remove inode[i] from dir inode[p]\n"
|
||||
"ls i list entries in inode[i]\n"
|
||||
"w i write to inode[i]\n"
|
||||
"r i read from inode[i]\n"
|
||||
"");
|
||||
} else if (strcmp(command, "fs") == 0) {
|
||||
fs_dump_info(fs);
|
||||
} else if (strcmp(command, "sb") == 0) {
|
||||
fs_dump_superblock(fs);
|
||||
} else if (strcmp(command, "bm") == 0) {
|
||||
fs_dump_block_bitmap(fs);
|
||||
} else if (strcmp(command, "in") == 0) {
|
||||
uint16_t inode_id;
|
||||
if (scanf(" %hu", &inode_id) != 1)
|
||||
goto malformed_command;
|
||||
fs_dump_inode(fs, inode_id);
|
||||
} else if (strcmp(command, "bh") == 0) {
|
||||
uint16_t block_id;
|
||||
if (scanf(" %hu", &block_id) != 1)
|
||||
goto malformed_command;
|
||||
fs_dump_block_hex(fs, block_id);
|
||||
} else if (strcmp(command, "bd") == 0) {
|
||||
uint16_t block_id;
|
||||
if (scanf(" %hu", &block_id) != 1)
|
||||
goto malformed_command;
|
||||
fs_dump_block_dec(fs, block_id);
|
||||
} else if (strcmp(command, "bc") == 0) {
|
||||
uint16_t block_id;
|
||||
if (scanf(" %hu", &block_id) != 1)
|
||||
goto malformed_command;
|
||||
fs_dump_block_char(fs, block_id);
|
||||
} else if (strcmp(command, "deb") == 0) {
|
||||
uint16_t block_id;
|
||||
if (scanf(" %hu", &block_id) != 1)
|
||||
goto malformed_command;
|
||||
fs_dump_direntry_block(fs, block_id);
|
||||
} else if (strcmp(command, "root") == 0) {
|
||||
INode root;
|
||||
fs_root(fs, &root);
|
||||
printf("id = %u\n", root.id);
|
||||
} else if (strcmp(command, "mkdir") == 0) {
|
||||
uint16_t parent_id;
|
||||
char name[62];
|
||||
if (scanf(" %hu %61s", &parent_id, name) != 2)
|
||||
goto malformed_command;
|
||||
INode parent;
|
||||
fs_inode(fs, &parent, parent_id);
|
||||
INode inode;
|
||||
fs_make_dir(fs, &inode, &parent, name);
|
||||
fs_sync(fs);
|
||||
printf("id = %u\n", inode.id);
|
||||
} else if (strcmp(command, "touch") == 0) {
|
||||
uint16_t parent_id;
|
||||
char name[62];
|
||||
if (scanf(" %hu %61s", &parent_id, name) != 2)
|
||||
goto malformed_command;
|
||||
INode parent;
|
||||
fs_inode(fs, &parent, parent_id);
|
||||
INode inode;
|
||||
fs_make_file(fs, &inode, &parent, name);
|
||||
fs_sync(fs);
|
||||
printf("id = %u\n", inode.id);
|
||||
} else if (strcmp(command, "rm") == 0) {
|
||||
uint16_t parent_id;
|
||||
uint16_t inode_id;
|
||||
if (scanf(" %hu %hu", &parent_id, &inode_id) != 2)
|
||||
goto malformed_command;
|
||||
INode parent;
|
||||
fs_inode(fs, &parent, parent_id);
|
||||
INode inode;
|
||||
fs_inode(fs, &inode, inode_id);
|
||||
fs_remove(fs, &inode, &parent);
|
||||
fs_sync(fs);
|
||||
} else if (strcmp(command, "ls") == 0) {
|
||||
uint16_t inode_id;
|
||||
if (scanf(" %hu", &inode_id) != 1)
|
||||
goto malformed_command;
|
||||
INode inode;
|
||||
fs_inode(fs, &inode, inode_id);
|
||||
ListEntry entries[32];
|
||||
size_t entries_size = fs_list(
|
||||
fs, entries, sizeof(entries) / sizeof(entries[0]), &inode);
|
||||
fs_sync(fs);
|
||||
for (size_t i = 0; i < entries_size; ++i)
|
||||
printf("%s\n", entries[i].name);
|
||||
} else if (strcmp(command, "w") == 0) {
|
||||
uint16_t inode_id;
|
||||
if (scanf(" %hu", &inode_id) != 1)
|
||||
goto malformed_command;
|
||||
INode inode;
|
||||
fs_inode(fs, &inode, inode_id);
|
||||
uint16_t buffer[64] = { 0 };
|
||||
size_t i = 0;
|
||||
fgetc(stdin);
|
||||
int ch;
|
||||
while ((ch = fgetc(stdin)) != EOF)
|
||||
buffer[i++] = ch;
|
||||
clearerr(stdin);
|
||||
fs_write(fs, &inode, buffer, i);
|
||||
fs_sync(fs);
|
||||
} else if (strcmp(command, "r") == 0) {
|
||||
uint16_t inode_id;
|
||||
if (scanf(" %hu", &inode_id) != 1)
|
||||
goto malformed_command;
|
||||
INode inode;
|
||||
fs_inode(fs, &inode, inode_id);
|
||||
uint16_t buffer[64] = { 0 };
|
||||
size_t buffer_size = fs_read(fs, &inode, buffer, 64, 0);
|
||||
for (size_t i = 0; i < buffer_size; ++i)
|
||||
fputc(buffer[i], stdout);
|
||||
} else {
|
||||
printf("error: unknown command '%s'\n", command);
|
||||
}
|
||||
|
||||
continue;
|
||||
malformed_command:
|
||||
printf("error: malformed '%s' command\n", command);
|
||||
}
|
||||
|
||||
fs_destroy(fs);
|
||||
free(disk.blocks);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user