view include/fs.h @ 67:9816d3510467

Redid the interface for handling file data The user can now get the file data for a file n (n has nothing to do with any part of the program other than if a != b then the function will give different results for a and b (this can be used to implement listFiles()
author Jonathan Pevarnek <pevarnj@gmail.com>
date Thu, 21 Apr 2011 23:58:13 -0400
parents 72d87920de94
children 19000e354e36
line wrap: on
line source

#include <std.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 DEPBLK (FSBLKSIZE / sizeof(Direntry)) //director entries per block

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;

int init_fs(u32 devnum, u64 __memsize);
u32 getFInfo(u32 n, void* de);
u32 lookupFile(char *fname);
int getFileSize(u32 fid, u32 *size);
int getFileData(u32 fid, void *ptr);
int setFileData(u32 fid, const void *ptr, size_t size);
short isBlockAt(u32 block);
void printFname(char *name);
void getFname(char *fname);
int fnameCmp(const char *a, const char *b);

#endif //__FSH_H