#ifndef FS_H
#define FS_H

#include <stdint.h>
#include "fat12.h"
#include "disk_io.h"
#include "print.h"

#define BLOCK_SIZE 4096
#define MAX_FILE_NAME 255
#define MAX_FILES 128

// Declarations for block operations
void write_block(uint32_t block_index, const void *data, uint32_t size);
void read_block(uint32_t block_index, void *buffer, uint32_t size);

// Structure of the superblock
typedef struct {
    uint32_t total_blocks;
    uint32_t free_blocks;
    uint32_t total_inodes;
    uint32_t free_inodes;
} Superblock;

// Structure of an inode
typedef struct {
    char name[MAX_FILE_NAME];
    uint32_t size;
    uint32_t data_block_start;
    uint32_t permissions;
} Inode;

// Structure of a directory entry
typedef struct {
    char name[MAX_FILE_NAME];
    uint32_t inode_index;
} DirectoryEntry;

// Filesystem operations
void fs_init();
int fs_create_file(const char *name, uint32_t size);
int fs_write_file(const char *name, const void *data, uint32_t size);
int fs_read_file(const char *name, void *buffer, uint32_t size);
int fs_delete_file(const char *name);
void list_files();

#endif // FS_H
