fs: Drop echfs support
This commit is contained in:
parent
13b9a333ad
commit
ee69dacb08
@ -274,23 +274,6 @@ mbrtest.hdd:
|
|||||||
dd if=/dev/zero bs=1M count=0 seek=64 of=mbrtest.hdd
|
dd if=/dev/zero bs=1M count=0 seek=64 of=mbrtest.hdd
|
||||||
echo -e "o\nn\np\n1\n2048\n\nt\n6\na\nw\n" | fdisk mbrtest.hdd -H 16 -S 63
|
echo -e "o\nn\np\n1\n2048\n\nt\n6\na\nw\n" | fdisk mbrtest.hdd -H 16 -S 63
|
||||||
|
|
||||||
.PHONY: echfs-test
|
|
||||||
echfs-test:
|
|
||||||
$(MAKE) test-clean
|
|
||||||
$(MAKE) test.hdd
|
|
||||||
$(MAKE) limine-bios
|
|
||||||
$(MAKE) limine-deploy
|
|
||||||
$(MAKE) -C test
|
|
||||||
echfs-utils -g -p0 test.hdd quick-format 512 > part_guid
|
|
||||||
sed "s/@GUID@/`cat part_guid`/g" < test/limine.cfg > limine.cfg.tmp
|
|
||||||
echfs-utils -g -p0 test.hdd import limine.cfg.tmp limine.cfg
|
|
||||||
rm -f limine.cfg.tmp part_guid
|
|
||||||
echfs-utils -g -p0 test.hdd import test/test.elf boot/test.elf
|
|
||||||
echfs-utils -g -p0 test.hdd import test/bg.bmp boot/bg.bmp
|
|
||||||
echfs-utils -g -p0 test.hdd import $(BINDIR)/limine.sys boot/limine.sys
|
|
||||||
$(BINDIR)/limine-deploy test.hdd
|
|
||||||
qemu-system-x86_64 -net none -smp 4 -hda test.hdd -debugcon stdio
|
|
||||||
|
|
||||||
.PHONY: fwcfg-common fwcfg-test fwcfg-simple-test
|
.PHONY: fwcfg-common fwcfg-test fwcfg-simple-test
|
||||||
fwcfg-common:
|
fwcfg-common:
|
||||||
$(MAKE) test-clean
|
$(MAKE) test-clean
|
||||||
|
@ -20,7 +20,6 @@ as the reference implementation for the [Limine boot protocol](/PROTOCOL.md).
|
|||||||
|
|
||||||
### Supported filesystems
|
### Supported filesystems
|
||||||
* ext2/3/4
|
* ext2/3/4
|
||||||
* echfs
|
|
||||||
* FAT12/16/32
|
* FAT12/16/32
|
||||||
* NTFS
|
* NTFS
|
||||||
* ISO9660 (CDs/DVDs)
|
* ISO9660 (CDs/DVDs)
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
#ifndef __FS__ECHFS_H__
|
|
||||||
#define __FS__ECHFS_H__
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <lib/part.h>
|
|
||||||
#include <lib/blib.h>
|
|
||||||
|
|
||||||
struct echfs_dir_entry {
|
|
||||||
uint64_t parent_id;
|
|
||||||
uint8_t type;
|
|
||||||
char name[201];
|
|
||||||
uint64_t atime;
|
|
||||||
uint64_t mtime;
|
|
||||||
uint16_t perms;
|
|
||||||
uint16_t owner;
|
|
||||||
uint16_t group;
|
|
||||||
uint64_t ctime;
|
|
||||||
uint64_t payload;
|
|
||||||
uint64_t size;
|
|
||||||
} __attribute__((packed));
|
|
||||||
|
|
||||||
struct echfs_file_handle {
|
|
||||||
struct volume *part;
|
|
||||||
uint64_t block_size;
|
|
||||||
uint64_t block_count;
|
|
||||||
uint64_t dir_length;
|
|
||||||
uint64_t alloc_table_size;
|
|
||||||
uint64_t alloc_table_offset;
|
|
||||||
uint64_t dir_offset;
|
|
||||||
uint64_t file_block_count;
|
|
||||||
uint64_t *alloc_map;
|
|
||||||
struct echfs_dir_entry dir_entry;
|
|
||||||
};
|
|
||||||
|
|
||||||
int echfs_check_signature(struct volume *part);
|
|
||||||
bool echfs_get_guid(struct guid *guid, struct volume *part);
|
|
||||||
|
|
||||||
bool echfs_open(struct echfs_file_handle *ret, struct volume *part, const char *filename);
|
|
||||||
void echfs_read(struct echfs_file_handle *file, void *buf, uint64_t loc, uint64_t count);
|
|
||||||
void echfs_close(struct echfs_file_handle *file);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,145 +0,0 @@
|
|||||||
#include <fs/echfs.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <lib/libc.h>
|
|
||||||
#include <lib/blib.h>
|
|
||||||
#include <lib/print.h>
|
|
||||||
#include <drivers/disk.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <mm/pmm.h>
|
|
||||||
|
|
||||||
struct echfs_identity_table {
|
|
||||||
uint8_t jmp[4];
|
|
||||||
char signature[8];
|
|
||||||
uint64_t block_count;
|
|
||||||
uint64_t dir_length;
|
|
||||||
uint64_t block_size;
|
|
||||||
uint32_t reserved;
|
|
||||||
struct guid guid;
|
|
||||||
} __attribute__((packed));
|
|
||||||
|
|
||||||
#define ROOT_DIR_ID (~((uint64_t)0))
|
|
||||||
#define END_OF_CHAIN (~((uint64_t)0))
|
|
||||||
#define FILE_TYPE 0
|
|
||||||
#define DIR_TYPE 1
|
|
||||||
|
|
||||||
static bool read_block(struct echfs_file_handle *file, void *buf, uint64_t block, uint64_t offset, uint64_t count) {
|
|
||||||
return volume_read(file->part, buf, (file->alloc_map[block] * file->block_size) + offset, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void echfs_read(struct echfs_file_handle *file, void *buf, uint64_t loc, uint64_t count) {
|
|
||||||
for (uint64_t progress = 0; progress < count;) {
|
|
||||||
uint64_t block = (loc + progress) / file->block_size;
|
|
||||||
|
|
||||||
uint64_t chunk = count - progress;
|
|
||||||
uint64_t offset = (loc + progress) % file->block_size;
|
|
||||||
if (chunk > file->block_size - offset)
|
|
||||||
chunk = file->block_size - offset;
|
|
||||||
|
|
||||||
read_block(file, buf + progress, block, offset, chunk);
|
|
||||||
progress += chunk;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int echfs_check_signature(struct volume *part) {
|
|
||||||
struct echfs_identity_table id_table;
|
|
||||||
volume_read(part, &id_table, 0, sizeof(struct echfs_identity_table));
|
|
||||||
|
|
||||||
if (strncmp(id_table.signature, "_ECH_FS_", 8)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool echfs_get_guid(struct guid *guid, struct volume *part) {
|
|
||||||
struct echfs_identity_table id_table;
|
|
||||||
volume_read(part, &id_table, 0, sizeof(struct echfs_identity_table));
|
|
||||||
|
|
||||||
if (strncmp(id_table.signature, "_ECH_FS_", 8)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*guid = id_table.guid;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void echfs_close(struct echfs_file_handle *file) {
|
|
||||||
pmm_free(file->alloc_map, file->file_block_count * sizeof(uint64_t));
|
|
||||||
pmm_free(file, sizeof(struct echfs_file_handle));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool echfs_open(struct echfs_file_handle *ret, struct volume *part, const char *path) {
|
|
||||||
ret->part = part;
|
|
||||||
|
|
||||||
struct echfs_identity_table id_table;
|
|
||||||
volume_read(ret->part, &id_table, 0, sizeof(struct echfs_identity_table));
|
|
||||||
|
|
||||||
if (strncmp(id_table.signature, "_ECH_FS_", 8)) {
|
|
||||||
print("echfs: signature invalid\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret->block_size = id_table.block_size;
|
|
||||||
ret->block_count = id_table.block_count;
|
|
||||||
ret->dir_length = id_table.dir_length * ret->block_size;
|
|
||||||
ret->alloc_table_size = DIV_ROUNDUP(ret->block_count * sizeof(uint64_t), ret->block_size) * ret->block_size;
|
|
||||||
ret->alloc_table_offset = 16 * ret->block_size;
|
|
||||||
ret->dir_offset = ret->alloc_table_offset + ret->alloc_table_size;
|
|
||||||
|
|
||||||
// Find the file in the root dir.
|
|
||||||
uint64_t wanted_parent = ROOT_DIR_ID;
|
|
||||||
bool last_elem = false;
|
|
||||||
|
|
||||||
next:;
|
|
||||||
char wanted_name[128];
|
|
||||||
for (; *path == '/'; path++);
|
|
||||||
for (int i = 0; ; i++, path++) {
|
|
||||||
if (*path == '\0' || *path == '/') {
|
|
||||||
if (*path == '\0')
|
|
||||||
last_elem = true;
|
|
||||||
wanted_name[i] = '\0';
|
|
||||||
path++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
wanted_name[i] = *path;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint64_t i = 0; i < ret->dir_length; i += sizeof(struct echfs_dir_entry)) {
|
|
||||||
volume_read(ret->part, &ret->dir_entry, i + ret->dir_offset, sizeof(struct echfs_dir_entry));
|
|
||||||
|
|
||||||
if (!ret->dir_entry.parent_id) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(wanted_name, ret->dir_entry.name) &&
|
|
||||||
ret->dir_entry.parent_id == wanted_parent &&
|
|
||||||
ret->dir_entry.type == (last_elem ? FILE_TYPE : DIR_TYPE)) {
|
|
||||||
if (last_elem) {
|
|
||||||
goto found;
|
|
||||||
} else {
|
|
||||||
wanted_parent = ret->dir_entry.payload;
|
|
||||||
goto next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
found:;
|
|
||||||
// Load the allocation map.
|
|
||||||
ret->file_block_count = DIV_ROUNDUP(ret->dir_entry.size, ret->block_size);
|
|
||||||
|
|
||||||
ret->alloc_map = ext_mem_alloc(ret->file_block_count * sizeof(uint64_t));
|
|
||||||
|
|
||||||
ret->alloc_map[0] = ret->dir_entry.payload;
|
|
||||||
for (uint64_t i = 1; i < ret->file_block_count; i++) {
|
|
||||||
// Read the next block.
|
|
||||||
volume_read(ret->part,
|
|
||||||
&ret->alloc_map[i],
|
|
||||||
ret->alloc_table_offset + ret->alloc_map[i-1] * sizeof(uint64_t),
|
|
||||||
sizeof(uint64_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <fs/file.h>
|
#include <fs/file.h>
|
||||||
#include <fs/echfs.h>
|
|
||||||
#include <fs/ext2.h>
|
#include <fs/ext2.h>
|
||||||
#include <fs/fat32.h>
|
#include <fs/fat32.h>
|
||||||
#include <fs/iso9660.h>
|
#include <fs/iso9660.h>
|
||||||
@ -14,9 +13,6 @@
|
|||||||
#include <pxe/tftp.h>
|
#include <pxe/tftp.h>
|
||||||
|
|
||||||
bool fs_get_guid(struct guid *guid, struct volume *part) {
|
bool fs_get_guid(struct guid *guid, struct volume *part) {
|
||||||
if (echfs_check_signature(part)) {
|
|
||||||
return echfs_get_guid(guid, part);
|
|
||||||
}
|
|
||||||
if (ext2_check_signature(part)) {
|
if (ext2_check_signature(part)) {
|
||||||
return ext2_get_guid(guid, part);
|
return ext2_get_guid(guid, part);
|
||||||
}
|
}
|
||||||
@ -68,21 +64,6 @@ struct file_handle *fopen(struct volume *part, const char *filename) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (echfs_check_signature(part)) {
|
|
||||||
struct echfs_file_handle *fd = ext_mem_alloc(sizeof(struct echfs_file_handle));
|
|
||||||
|
|
||||||
if (!echfs_open(fd, part, filename)) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret->fd = (void *)fd;
|
|
||||||
ret->read = (void *)echfs_read;
|
|
||||||
ret->close = (void *)echfs_close;
|
|
||||||
ret->size = fd->dir_entry.size;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ext2_check_signature(part)) {
|
if (ext2_check_signature(part)) {
|
||||||
struct ext2_file_handle *fd = ext_mem_alloc(sizeof(struct ext2_file_handle));
|
struct ext2_file_handle *fd = ext_mem_alloc(sizeof(struct ext2_file_handle));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user