/**************************************************************************************
$Id: ubixfs.h,v 1.2 2002/04/27 16:17:14 reddawg Exp $


**************************************************************************************/

#ifndef INCLUDE_UBIX_FS
#define INCLUDE_UBIX_FS

typedef struct {
  unsigned char jmp[4];	/* jump to code (4bytes) */
  unsigned char id[6];	/* Should be 'UbixFS' */
  unsigned long version;	/* Should be 1 */
  unsigned long fs_start;	/* LBA pointer to the start of the FS */
  unsigned long krnl_start; /* LBA pointer to kernel file entry */
  unsigned int BytesPerSector;
  unsigned int SectersPerTrack;
  unsigned int TotalHeads;
  unsigned long TotalSectors;
  unsigned char code[479];
  } __attribute__ ((packed)) t_bootsect;

typedef struct
{
	unsigned char type;	/* 0 = unused. 1 = file entry. 2 = data_entry */
	unsigned long prev_entry;	/* LBA pointer to previous file entry */
	unsigned long next_entry;	/* LBA pointer to next file entry */
	unsigned char filename[255];	/* File name, padded with NULLs */
	/* Attributes
	 * Bit 0: Read
	 * Bit 1: Write
	 * Bit 2: Execute
	 * Bit 3: Hidden
	 * Bit 4: Directory
	 * Rest are unused, and available for future expansion
	 */
	unsigned char attributes;
	unsigned long size;		/* size in bytes */
	unsigned long parent_dir;	/* LBA pointer to parent dir entry */
	unsigned long first_dataentry;	/* LBA pointer to next data struct */
	unsigned char padding[3819];
} __attribute__ ((packed)) t_file_entry;

typedef struct
{
	unsigned char type;	/* 0 = unused. 1 = file entry. 2 = data_entry */
	unsigned long prev_entry;	/* LBA pointer to previous data/file entry */
	unsigned long next_entry;	/* LBA pointer to next data/file entry */
	unsigned char data[4087];
} __attribute__ ((packed)) t_data_entry;

void initUbixfs();
void displayrootdir();
unsigned long getdata(char *filename, unsigned long offset, unsigned long size, unsigned char *buffer);

#endif