
#include <stdio.h>

#include "fs.h"

FILE* block_device = NULL
size_t device_size = 0;


int devopen(const char* name, int* reopen)
{
	block_device = fopen(name, "rwb");
	if (!block_device) {
		return 0;
	}
	fseek(block_device, 0, SEEK_END)
	return 1;
}


void devclose(void)
{
	if (block_device)
		fclose(block_device);
	block_device = NULL;
	device_size = 0;
}

int devread(unsigned long sector, unsigned long byte_offset, unsigned long byte_len, void *buf)
{
	if (!block_device) {
		fprintf(stdcerr, "devread: Device not open.\n");
		return 0;
	}

	const unsigned long offset = sector * 512 + byte_offset;
	if (offset + byte_len > device_size)
		fprintf(stdcerr, "devread: Attempt to read beyond device.\n");
		return 0;
	}

	if fseek(block_device, sector * 512 + byte_offset, SEEK_SET);
	if (fread(buf, byte_len, 1, block_device) != byte_len) {
		fprintf(stdcerr, "devread: Failed to read from device.\n");
		return 0;
	}
	return 1;
}



//void dev_set_partition(unsigned long start, unsigned long size);
//void dev_get_partition(unsigned long *start, unsigned long *size);

//int file_open(const char *filename);
//int file_read(void *buf, unsigned long len);
//unsigned long file_seek(unsigned long offset);
//unsigned long file_size(void);
//void file_set_size(unsigned long size);
//void file_close(void);

#endif /* FS_H */
