Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ KERNEL_ELF = kernel/kernel.bin
QEMU = qemu-system-i386
QEMU_FLAGS = -kernel $(KERNEL_ELF) -serial stdio

.PHONY: all clean run directories iso debug runiso release runrelease
.PHONY: all clean clean-all resetimg run directories iso debug runiso release runrelease rundebug

all: directories $(KERNEL_ELF)

Expand Down Expand Up @@ -113,6 +113,9 @@ rundebug :
$(MAKE)
$(QEMU) $(QEMU_FLAGS) -drive file=test_fat32.img,format=raw,if=ide

run: $(KERNEL_ELF) test_fat32.img
$(QEMU) $(QEMU_FLAGS) -drive file=test_fat32.img,format=raw,if=ide

runrelease :
$(MAKE) clean
$(MAKE) EXTRA_CFLAGS="-UDEBUG -UTEST"
Expand All @@ -128,9 +131,11 @@ clean:
rm -f kernel.iso
rm -f $(KERNEL_DEST)/kernel.bin
rm -f $(KERNEL_DEST)/kernel2.bin
clean-all: clean

resetimg:
rm -f test_fat32.img
rm -f fat32_template.img

clean-all: clean resetimg

# Create test FAT32 disk image
test_fat32.img: fat32_template.img
Expand Down
18 changes: 15 additions & 3 deletions include/kernel/fat32.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define FAT32_ATTR_LONG_NAME 0x0F

// Maximum values
#define FAT32_MAX_FILENAME 12
#define FAT32_MAX_FILENAME 255
#define FAT32_MAX_PATH 256
#define FAT32_MAX_OPEN_FILES 16

Expand Down Expand Up @@ -73,6 +73,17 @@ typedef struct __attribute__((packed)) {
uint32_t file_size;
} fat32_dir_entry_t;

typedef struct __attribute__((packed)) {
uint8_t order;
uint16_t name1[5];
uint8_t attributes;
uint8_t type;
uint8_t checksum;
uint16_t name2[6];
uint16_t first_cluster_low;
uint16_t name3[2];
} fat32_lfn_entry_t;

// Runtime structures
typedef struct {
uint8_t device_id;
Expand Down Expand Up @@ -102,7 +113,9 @@ typedef struct {
} fat32_file_t;

typedef struct {
char filename[13];
char filename[FAT32_MAX_FILENAME + 1];
char short_name[13];
uint8_t has_long_name;
uint8_t attributes;
uint32_t size;
uint32_t cluster;
Expand Down Expand Up @@ -135,6 +148,5 @@ uint32_t fat32_get_root_cluster(void);
uint32_t fat32_cluster_to_sector(uint32_t cluster);
uint32_t fat32_get_next_cluster(uint32_t cluster);
int fat32_read_cluster(uint32_t cluster, void* buffer);
int fat32_parse_dir_entry(fat32_dir_entry_t* entry, fat32_file_info_t* info);

#endif // FAT32_H
7 changes: 5 additions & 2 deletions include/kernel/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ typedef struct vfs_operations {
int (*write)(vfs_file_t* file, const void* buffer, size_t size);
int (*seek)(vfs_file_t* file, uint32_t position);
void (*close)(vfs_file_t* file);


// Lifecycle
int (*unmount)(struct vfs_mount* mount);

// Directory operations
int (*readdir)(struct vfs_mount* mount, const char* path, vfs_dirent_t* entries, int max_entries);
int (*mkdir)(struct vfs_mount* mount, const char* path);
Expand Down Expand Up @@ -118,4 +121,4 @@ int ramfs_vfs_mount(const char* mountpoint);
vfs_operations_t* fat32_get_vfs_ops(void);
int fat32_vfs_mount(const char* mountpoint, uint8_t device_id);

#endif // VFS_H
#endif // VFS_H
Loading