view include/fs.h @ 99:2a0aa3efc228

The shell script will now theroretically load the program into memory, will not run it. The shell script loads a program into memory and displays the address but as of now does not jump to it (though it does display the address it would jump to) Added a memset function Added a python script (credit for its writing to Jeff) that sets up a filesystem
author Jonathan Pevarnek <pevarnj@gmail.com>
date Sat, 14 May 2011 19:40:18 -0400
parents 7962969a9abd
children
line wrap: on
line source

#include <std.h>
#include <error.h>

#ifndef __FS_H
#define __FS_H

#define CACHESPACE 1 //percentage of heap to use for the FS Cache
#define FNAMELEN 28 //How long the filenames are
#define FSBLKSIZE 1024
#define DSKBLKSIZE 512
#define MAXBLOCKS 248
#define FSMAGICNUM 0x42420374
#define DEPBLK (FSBLKSIZE / sizeof(Direntry)) //director entries per block

#define ERR_FSBLKREADFAIL mkError(MODFS, BLKREADFAIL, ERROR)

struct SUPERBLOCK {
	u32 magic;              // == 0x42420374
	u32 root_inode;         // the disk block containing the root inode
	u32 nblocks;            // number of block on the disk
	u32 _pad[253];          // unused (should be '\0' filled)
};
typedef struct SUPERBLOCK Superblock;

struct INODE {
	u32 size;               // file length in bytes
	u32 _pad0;              // unused (should be 0)
	u64 ctime;              // creation time stamp
	u64 mtime;              // last modification time stamp
	u16 nblocks;            // number of data blocks in this file
	u16 _pad1;              // unused (should be 0)
	u32 _pad2;              // unused (should be 0)
	u32 blocks[MAXBLOCKS];  // file block ptrs
};
typedef struct INODE Inode;

struct FSBLK {
	u8 blocks[FSBLKSIZE];
};
typedef struct FSBLK FSBlk;

struct DSKBLK {
	u8 blocks[DSKBLKSIZE];
};
typedef struct DSKBLK DskBlk;

struct DIRENTRY { //32 bytes
	char fname[FNAMELEN];
	u32 inode;
};
typedef struct DIRENTRY Direntry;

ErrCode init_fs(u32 devnum, u64 __memsize);
ErrCode getFInfo(u32 n, void* de);
ErrCode lookupFile(char *fname, u32 *fid);
ErrCode makeFile(char *fname, u32 *fid);
ErrCode deleteFile(u32 fid);
ErrCode fileAppend(u32 fid, void *data, u32 length);
ErrCode fileWrite(u32 fid, void *data, u32 length, u32 offset);
ErrCode getFileSize(u32 fid, u32 *size);
ErrCode getFileData(u32 fid, void *ptr);
void printFname(char *name);
void getFname(char *fname);
int fnameCmp(const char *a, const char *b);

#endif //__FS_H