[GOOD] BUILD 0.1.0.590 DATE 9/05/2011 AT 2:40 PM

====================================================
Mainly changed: FS.Initrd
+ (kind of) refractored VFS, bugfixed
+ Rewrote 'initrd' file system, fixed many problems
+ Working 'cat' and 'dir' console commands
+ Wrote 'initrd' image write application (for windows), however it may
be bugged
This commit is contained in:
2021-09-14 18:52:47 +03:00
parent caa7718af9
commit 852cf1bb17
71 changed files with 1979 additions and 659 deletions

54
Kernel/include/array.h Normal file
View File

@ -0,0 +1,54 @@
/*
* array.h
*
* Created on: Sep 3, 2011
* Author: Tiberiu
*/
#ifndef ARRAY_H_
#define ARRAY_H_
#include <types.h>
/*******************************************
* Dynamically expanding array *
*******************************************/
typedef struct {
// You can cast the Data to any type of array
// because it contains the actual data, not pointers
void* Data;
uint32 ElemSize;
uint32 Size;
uint32 Allocated;
} DynamicArray;
extern void DynamicArrayCreate (uint32 ElemSize, DynamicArray* arr);
extern void DynamicArrayPush (void* item, DynamicArray* arr);
extern void DynamicArrayPop (DynamicArray* arr);
extern void DynamicArrayInsert (void* item, uint32 index, DynamicArray* arr);
extern void DynamicArrayRemove (uint32 index, DynamicArray* arr);
extern void DynamicArraySwap (uint32 a, uint32 b, DynamicArray* arr);
extern void DynamicArrayDispose (DynamicArray* arr);
/*******************************************
* Ordered array *
*******************************************/
typedef int (*ComparePredicate) (uint32, uint32);
typedef struct {
uint32* Data;
uint32 Size;
uint32 SizeLimit;
ComparePredicate Compare;
} OrderedArray;
extern OrderedArray OrderedArrayCreate (uint32 maxSize, ComparePredicate p);
extern OrderedArray OrderedArrayPlace (uint32 addr, uint32 maxSize, ComparePredicate p);
extern void OrderedArrayDispose (OrderedArray* arr);
extern uint32 OrderedArraySearch (uint32 key, OrderedArray* arr, ComparePredicate predicate);
extern void OrderedArrayInsert (uint32 item, OrderedArray* arr);
extern uint32 OrderedArrayLookup (uint32 index, OrderedArray* arr);
extern void OrderedArrayDeleteIndex (uint32 index, OrderedArray* arr);
#endif /* ARRAY_H_ */

View File

@ -43,24 +43,23 @@ enum FileFlags
typedef struct
{
uint32 DeviceId; // The VFS identifies the mounted device that uses this
uint32 Id; // The FS idenitifies files using this field
//char Name[MAX_FILENAME_LEN];
uint32 Id; // The FS identifies files using this field
char* Name;
/*** Looks like this:
* bits description
* 0-2 file type
* 3-5 owner permissions (rwx)
* 6-8 group permissions (rwx)
* 9-11 other permissions (rwx)
* 12 hidden
* 13-31 (unassigned yet)
/*** Flags look like this:
*
* Note: In windows FS, the readonly and system
* attributes are set using permissions and owner id */
uint32 Flags;
uint32 OwnerId, GroupId;
* bits 31 ... 13 | 12 | 11 10 9 | 8 7 6 | 5 4 3 | 2 1 0
* unassigned | Hidden | x w r | x w r | x w r | file type (enum above)
* | others | group | owner |
* Note: In windows FSs, the readonly and system attributes are set
* using permissions mask and owner id (0 = system) */
uint32 Flags, OwnerId, GroupId;
uint32 Size;
// Useful for file systems
void *BufStart, *BufPos, *BufEnd ;
uint32 FsData[8]; // Can store info such as current cluster, etc
} FILE;
@ -70,31 +69,32 @@ typedef struct _DirectoryEntry
uint32 Flags, OwnerId, GroupId, Size;
TimeSystem TimeCreated, TimeModified, TimeAccessed;
} DirectoryEntry;
} __attribute__((packed)) DirectoryEntry;
typedef struct {
uint32 Id;
uint32 FsId;
uint32 Id, FsId;
char Name[MAX_MOUNTPOINTNAME_LEN];
uint32 BlockSize;
DevReadRoutine Read;
DevWriteRoutine Write;
uint32 FsData[8];
} MountPoint;
// File system routines
typedef uint32 (*FsReadRoutine)(const MountPoint*, FILE*, uint32, uint32, uint8*);
typedef uint32 (*FsWriteRoutine)(const MountPoint*, FILE*, uint32, uint32, uint8*);
typedef FILE* (*FsOpenRoutine)(const MountPoint*, FILE*,string);
typedef DirectoryEntry* (*FsTestRoutine)(const MountPoint*, string); // Test if a file exists, and returns info
typedef FILE* (*FsCloseRoutine)(const MountPoint*, FILE*);
typedef DirectoryEntry* (*FsReadDirRoutine)(const MountPoint*,FILE*,uint32);
typedef uint32 (*FsReadRoutine) (MountPoint*, FILE*, uint32, uint32, uint8*);
typedef uint32 (*FsWriteRoutine) (MountPoint*, FILE*, uint32, uint32, uint8*);
typedef FILE* (*FsOpenRoutine) (MountPoint*, FILE*, string);
typedef DirectoryEntry* (*FsTestRoutine) (MountPoint*, string); // Test if a file exists, and returns info
typedef FILE* (*FsCloseRoutine) (MountPoint*, FILE*);
typedef DirectoryEntry* (*FsReadDirRoutine) (MountPoint*, FILE*, uint32);
typedef uint32 (*FsDetectRoutine) (DevReadRoutine, uint32 blocksz);
typedef void (*FsMountRoutine) (const MountPoint*);
typedef void (*FsUnmountRoutine) (const MountPoint*);
typedef uint32 (*FsDetectRoutine) (MountPoint*);
typedef void (*FsMountRoutine) (MountPoint*);
typedef void (*FsUnmountRoutine) (MountPoint*, uint8 Forced); // If forced, the FS shouldn't try to write to device
// File system structure
typedef struct {
@ -115,18 +115,16 @@ typedef struct {
// Vfs routines
extern void VfsInstall ();
extern uint8 VfsInstallFs (FileSystem* fs);
extern uint32 VfsFindDevice (string dev);
extern uint32 VfsParsePath (string* path);
extern uint8 VfsMount (string Name, DevReadRoutine R, DevWriteRoutine W, uint32 BlockSize);
extern void VfsUnmount (uint32 dev_id);
extern FILE* VfsOpen (FILE* file, string path);
extern void VfsInstall ();
extern void VfsInstallFs (FileSystem* fs);
extern MountPoint* VfsMount (string devname, DevReadRoutine R, DevWriteRoutine W, uint32 bs);
extern void VfsUnmount (uint32 dev_id);
extern FILE* VfsOpen (FILE* file, string path);
extern DirectoryEntry* VfsTest (string path);
extern FILE* VfsClose (FILE* file);
extern uint32 VfsRead (FILE* file, uint32 bsz, uint32 n, uint8* buffer);
extern uint32 VfsWrite (FILE* file, uint32 bsz, uint32 n, uint8* buffer);
extern FILE* VfsClose (FILE* file);
extern uint32 VfsRead (FILE* file, uint32 bsz, uint32 n, uint8* buffer);
extern uint32 VfsWrite (FILE* file, uint32 bsz, uint32 n, uint8* buffer);
extern DirectoryEntry* VfsReadDirectory (FILE* handle, uint32 index);
extern MountPoint* VfsGetMountPoint (uint32 dev_id);
#endif /* FILEIO_H_ */

View File

@ -11,6 +11,7 @@
#include <memory.h>
#include <stdlib.h>
#include <debugio.h>
#include <array.h>
/***************************************************
* Paging *

View File

@ -23,10 +23,11 @@
***************************************************/
extern uint32 strlen (string s);
extern int32 strcmp (string a, string b);
extern int32 strcasecmp (string a, string b);
extern int32 strncmp (string a, string b, uint32 n);
extern int32 strcasecmp (string a, string b);
extern string strcpy (string s1, const string s2);
extern char* strchr (string s, int c);
extern char* strrchr (string s, int c);
extern char* strchr (string s, int c);
extern char* strrchr (string s, int c);
/***************************************************
* Number operations: len *
@ -50,23 +51,5 @@ extern int32 ConvertStringToInt (string buffer);
extern uint32 ConvertStringToUInt (string buffer);
extern uint32 ConvertStringToIntHex (string buffer);
/***************************************************
* Ordered array implementation *
***************************************************/
typedef int (*ComparePredicate) (uint32, uint32);
typedef struct {
uint32* Data;
uint32 Size;
uint32 SizeLimit;
ComparePredicate Compare;
} OrderedArray;
extern OrderedArray OrderedArrayCreate (uint32 maxSize, ComparePredicate p);
extern OrderedArray OrderedArrayPlace (uint32 addr, uint32 maxSize, ComparePredicate p);
extern void OrderedArrayDispose (OrderedArray* arr);
extern uint32 OrderedArraySearch (uint32 key, OrderedArray* arr, ComparePredicate predicate);
extern void OrderedArrayInsert (uint32 item, OrderedArray* arr);
extern uint32 OrderedArrayLookup (uint32 index, OrderedArray* arr);
extern void OrderedArrayDeleteIndex (uint32 index, OrderedArray* arr);
#endif

View File

@ -1 +1 @@
#define OS_BUILD "0.1.0.551"
#define OS_BUILD "0.1.0.590"