void FIFO_Close(tVFS_Node *Node);
int FIFO_Relink(tVFS_Node *Node, const char *OldName, const char *NewName);
Uint64 FIFO_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
tPipe *FIFO_Int_NewPipe(int Size, const char *Name);
// === GLOBALS ===
MODULE_DEFINE(0, 0x0032, FIFO, FIFO_Install, NULL, NULL);
+tVFS_NodeType gFIFO_DirNodeType = {
+ .TypeName = "FIFO Dir Node",
+ .ReadDir = FIFO_ReadDir,
+ .FindDir = FIFO_FindDir,
+ .MkNod = FIFO_MkNod,
+ .Relink = FIFO_Relink,
+ .IOCtl = FIFO_IOCtl
+};
+tVFS_NodeType gFIFO_PipeNodeType = {
+ .TypeName = "FIFO Pipe Node",
+ .Read = FIFO_Read,
+ .Write = FIFO_Write,
+ .Close = FIFO_Close
+};
tDevFS_Driver gFIFO_DriverInfo = {
NULL, "fifo",
{
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRW,
.Flags = VFS_FFLAG_DIRECTORY,
- .ReadDir = FIFO_ReadDir,
- .FindDir = FIFO_FindDir,
- .MkNod = FIFO_MkNod,
- .Relink = FIFO_Relink,
- .IOCtl = FIFO_IOCtl
+ .Type = &gFIFO_DirNodeType
}
};
tVFS_Node gFIFO_AnonNode = {
* \fn Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Write to a fifo pipe
*/
-Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
{
tPipe *pipe = Node->ImplPtr;
Uint len;
ret->Node.CTime
= ret->Node.MTime
= ret->Node.ATime = now();
- ret->Node.Read = FIFO_Read;
- ret->Node.Write = FIFO_Write;
- ret->Node.Close = FIFO_Close;
+ ret->Node.Type = &gFIFO_PipeNodeType;
return ret;
}
int giPCI_InodeHandle = -1;\r
int giPCI_DeviceCount = 0;\r
tPCIDevice *gPCI_Devices = NULL;\r
+tVFS_NodeType gPCI_RootNodeType = {\r
+ .TypeName = "PCI Root Node",\r
+ .ReadDir = PCI_int_ReadDirRoot,\r
+ .FindDir = PCI_int_FindDirRoot\r
+};\r
+tVFS_NodeType gPCI_DevNodeType = {\r
+ .TypeName = "PCI Dev Node",\r
+ .Read = PCI_int_ReadDevice\r
+};\r
tDevFS_Driver gPCI_DriverStruct = {\r
NULL, "pci",\r
{\r
.Size = -1,\r
.NumACLs = 1,\r
.ACLs = &gVFS_ACL_EveryoneRX,\r
- .ReadDir = PCI_int_ReadDirRoot,\r
- .FindDir = PCI_int_FindDirRoot\r
+ .Type = &gPCI_RootNodeType\r
}\r
};\r
Uint32 *gaPCI_PortBitmap = NULL;\r
info->Node.NumACLs = 1;\r
info->Node.ACLs = &gVFS_ACL_EveryoneRO;\r
\r
- info->Node.Read = PCI_int_ReadDevice;\r
+ info->Node.Type = &gPCI_RootNodeType;\r
\r
return 1;\r
}\r
extern tSysFS_Ent gSysFS_Version; // Defined Later
extern tSysFS_Ent gSysFS_Root; // Defined Later
MODULE_DEFINE(0, VERSION, SysFS, SysFS_Install, NULL, NULL);
+tVFS_NodeType gSysFS_FileNodeType = {
+ .TypeName = "SysFS File",
+ .Read = SysFS_Comm_ReadFile
+ };
+tVFS_NodeType gSysFS_DirNodeType = {
+ .TypeName = "SysFS Dir",
+ .ReadDir = SysFS_Comm_ReadDir,
+ .FindDir = SysFS_Comm_FindDir
+ };
tSysFS_Ent gSysFS_Version_Kernel = {
NULL, NULL, // Nexts
&gSysFS_Version, // Parent
.Size = 0,
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRO,
- .Read = SysFS_Comm_ReadFile
+ .Type = &gSysFS_FileNodeType
},
"Kernel"
};
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
.Flags = VFS_FFLAG_DIRECTORY,
- .ReadDir = SysFS_Comm_ReadDir,
- .FindDir = SysFS_Comm_FindDir
+ .Type = &gSysFS_DirNodeType
},
"Version"
};
.Flags = VFS_FFLAG_DIRECTORY,
.ImplPtr = &gSysFS_Version,
.Size = sizeof(gSysFS_Root)/sizeof(tSysFS_Ent),
- .ReadDir = SysFS_Comm_ReadDir,
- .FindDir = SysFS_Comm_FindDir,
- .IOCtl = NULL
+ .Type = &gSysFS_DirNodeType
}
};
int giSysFS_NextFileID = 2;
child->Node.NumACLs = 1;
child->Node.ACLs = &gVFS_ACL_EveryoneRX;
child->Node.Flags = VFS_FFLAG_DIRECTORY;
- child->Node.ReadDir = SysFS_Comm_ReadDir;
- child->Node.FindDir = SysFS_Comm_FindDir;
+ child->Node.Type = &gSysFS_DirNodeType;
if( !prev ) {
if(ent)
ent->Node.ImplPtr = child;
child->Node.Size = Length;
child->Node.NumACLs = 1;
child->Node.ACLs = &gVFS_ACL_EveryoneRO;
- child->Node.Read = SysFS_Comm_ReadFile;
- child->Node.Close = SysFS_Comm_CloseFile;
+ child->Node.Type = &gSysFS_FileNodeType;
// Add to parent's child list
if(ent) {
tVFS_Node *VT_FindDir(tVFS_Node *Node, const char *Name);
int VT_Root_IOCtl(tVFS_Node *Node, int Id, void *Data);
Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
int VT_Terminal_IOCtl(tVFS_Node *Node, int Id, void *Data);
void VT_SetResolution(int Width, int Height);
void VT_SetMode(int Mode);
void VT_SetTerminal(int ID);
void VT_KBCallBack(Uint32 Codepoint);
-void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count);
+void VT_int_PutString(tVTerm *Term, const Uint8 *Buffer, Uint Count);
void VT_int_ClearLine(tVTerm *Term, int Num);
void VT_int_ParseEscape_StandardLarge(tVTerm *Term, char CmdChar, int argc, int *args);
- int VT_int_ParseEscape(tVTerm *Term, char *Buffer);
+ int VT_int_ParseEscape(tVTerm *Term, const char *Buffer);
void VT_int_PutChar(tVTerm *Term, Uint32 Ch);
void VT_int_ScrollText(tVTerm *Term, int Count);
void VT_int_ScrollFramebuffer( tVTerm *Term, int Count );
// === GLOBALS ===
MODULE_DEFINE(0, VERSION, VTerm, VT_Install, NULL, DEFAULT_INPUT, NULL);
+tVFS_NodeType gVT_RootNodeType = {
+ .TypeName = "VTerm Root",
+ .ReadDir = VT_ReadDir,
+ .FindDir = VT_FindDir,
+ .IOCtl = VT_Root_IOCtl
+ };
+tVFS_NodeType gVT_TermNodeType = {
+ .TypeName = "VTerm",
+ .Read = VT_Read,
+ .Write = VT_Write,
+ .IOCtl = VT_Terminal_IOCtl
+ };
tDevFS_Driver gVT_DrvInfo = {
NULL, "VTerm",
{
.Size = NUM_VTS,
.Inode = -1,
.NumACLs = 0,
- .ReadDir = VT_ReadDir,
- .FindDir = VT_FindDir,
- .IOCtl = VT_Root_IOCtl
+ .Type = &gVT_RootNodeType
}
};
// --- Terminals ---
gVT_Terminals[i].Node.Inode = i;
gVT_Terminals[i].Node.ImplPtr = &gVT_Terminals[i];
gVT_Terminals[i].Node.NumACLs = 0; // Only root can open virtual terminals
-
- gVT_Terminals[i].Node.Read = VT_Read;
- gVT_Terminals[i].Node.Write = VT_Write;
- gVT_Terminals[i].Node.IOCtl = VT_Terminal_IOCtl;
+
+ gVT_Terminals[i].Node.Type = &gVT_TermNodeType;
// Semaphore_Init(&gVT_Terminals[i].InputSemaphore, 0, MAX_INPUT_CHARS8, "VTerm", gVT_Terminals[i].Name);
}
}
/**
- * \fn Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+ * \fn Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
* \brief Write to a virtual terminal
*/
-Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
{
tVTerm *term = &gVT_Terminals[ Node->Inode ];
int size;
}
/**
- * \fn int VT_int_ParseEscape(tVTerm *Term, char *Buffer)
+ * \fn int VT_int_ParseEscape(tVTerm *Term, const char *Buffer)
* \brief Parses a VT100 Escape code
*/
-int VT_int_ParseEscape(tVTerm *Term, char *Buffer)
+int VT_int_ParseEscape(tVTerm *Term, const char *Buffer)
{
char c;
int argc = 0, j = 1;
}
/**
- * \fn void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count)
+ * \fn void VT_int_PutString(tVTerm *Term, const Uint8 *Buffer, Uint Count)
* \brief Print a string to the Virtual Terminal
*/
-void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count)
+void VT_int_PutString(tVTerm *Term, const Uint8 *Buffer, Uint Count)
{
Uint32 val;
int i;
if( Buffer[i] == 0x1B )
{
i ++;
- i += VT_int_ParseEscape(Term, (char*)&Buffer[i]) - 1;
+ i += VT_int_ParseEscape(Term, (const char*)&Buffer[i]) - 1;
continue;
}
// === CODE ===
// --- Video Driver Helpers ---
-int DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,
+int DrvUtil_Video_2DStream(void *Ent, const void *Buffer, int Length,
tDrvUtil_Video_2DHandlers *Handlers, int SizeofHandlers)
{
- void *stream = Buffer;
+ const Uint8 *stream = Buffer;
int rem = Length;
int op;
while( rem )
{
rem --;
- op = *(Uint8*)stream;
- stream = (void*)((tVAddr)stream + 1);
+ op = *stream;
+ stream ++;
if(op > NUM_VIDEO_2DOPS) {
Log_Warning("DrvUtil",
case VIDEO_2DOP_NOP: break;
case VIDEO_2DOP_FILL:
- if(rem < 12) return Length-rem;
+ if(rem < 10) return Length-rem;
if(!Handlers->Fill) {
Log_Warning("DrvUtil", "DrvUtil_Video_2DStream: Driver"
Handlers->Fill(
Ent,
- ((Uint16*)stream)[0], ((Uint16*)stream)[1],
- ((Uint16*)stream)[2], ((Uint16*)stream)[3],
- ((Uint32*)stream)[2]
+ ((const Uint16*)stream)[0], ((const Uint16*)stream)[1],
+ ((const Uint16*)stream)[2], ((const Uint16*)stream)[3],
+ ((const Uint32*)stream)[4]
);
- rem -= 12;
- stream = (void*)((tVAddr)stream + 12);
+ rem -= 10;
+ stream += 10;
break;
case VIDEO_2DOP_BLIT:
Handlers->Blit(
Ent,
- ((Uint16*)stream)[0], ((Uint16*)stream)[1],
- ((Uint16*)stream)[2], ((Uint16*)stream)[3],
- ((Uint16*)stream)[4], ((Uint16*)stream)[5]
+ ((const Uint16*)stream)[0], ((const Uint16*)stream)[1],
+ ((const Uint16*)stream)[2], ((const Uint16*)stream)[3],
+ ((const Uint16*)stream)[4], ((const Uint16*)stream)[5]
);
rem -= 12;
- stream = (void*)((tVAddr)stream + 12);
+ stream += 12;
break;
}
return 0;
}
-int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t Length, void *Buffer)
+int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t Length, const void *Buffer)
{
Uint8 *dest;
- Uint32 *src = Buffer;
+ const Uint32 *src = Buffer;
int csr_x, csr_y;
int x, y;
int bytes_per_px = (FBInfo->Depth + 7) / 8;
{
case VIDEO_BUFFMT_TEXT:
{
- tVT_Char *chars = Buffer;
+ const tVT_Char *chars = Buffer;
int widthInChars = FBInfo->Width/giVT_CharWidth;
int heightInChars = FBInfo->Height/giVT_CharHeight;
int i;
// --- Disk Driver Helpers ---
Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,
- tDrvUtil_Callback ReadBlocks, Uint64 BlockSize, Uint Argument)
+ tDrvUtil_Read_Callback ReadBlocks, Uint64 BlockSize, Uint Argument)
{
Uint8 tmp[BlockSize]; // C99
Uint64 block = Start / BlockSize;
return Length;
}
-Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, void *Buffer,
- tDrvUtil_Callback ReadBlocks, tDrvUtil_Callback WriteBlocks,
+Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, const void *Buffer,
+ tDrvUtil_Read_Callback ReadBlocks, tDrvUtil_Write_Callback WriteBlocks,
Uint64 BlockSize, Uint Argument)
{
Uint8 tmp[BlockSize]; // C99
* \param Buffer Destination for read blocks\r
* \param Argument Argument provided in ::DrvUtil_ReadBlock and ::DrvUtil_WriteBlock\r
*/\r
-typedef Uint (*tDrvUtil_Callback)(Uint64 Address, Uint Count, void *Buffer, Uint Argument);\r
+typedef Uint (*tDrvUtil_Read_Callback)(Uint64 Address, Uint Count, void *Buffer, Uint Argument);\r
+typedef Uint (*tDrvUtil_Write_Callback)(Uint64 Address, Uint Count, const void *Buffer, Uint Argument);\r
\r
/**\r
* \brief Reads a range from a block device using aligned reads\r
* \return Number of bytes read\r
*/\r
extern Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,\r
- tDrvUtil_Callback ReadBlocks, Uint64 BlockSize, Uint Argument);\r
+ tDrvUtil_Read_Callback ReadBlocks, Uint64 BlockSize, Uint Argument);\r
/**\r
* \brief Writes a range to a block device using aligned writes\r
* \param Start Base byte offset\r
* \param Argument An argument to pass to \a ReadBlocks and \a WriteBlocks\r
* \return Number of bytes written\r
*/\r
-extern Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, void *Buffer,\r
- tDrvUtil_Callback ReadBlocks, tDrvUtil_Callback WriteBlocks,\r
+extern Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, const void *Buffer,\r
+ tDrvUtil_Read_Callback ReadBlocks, tDrvUtil_Write_Callback WriteBlocks,\r
Uint64 BlockSize, Uint Argument);\r
\r
/**\r
* \param SizeofHandlers Size of \a tDrvUtil_Video_2DHandlers according\r
* to the driver. Used as version control and error avoidence.\r
*/\r
-extern int DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,\r
+extern int DrvUtil_Video_2DStream(void *Ent, const void *Buffer, int Length,\r
tDrvUtil_Video_2DHandlers *Handlers, int SizeofHandlers);\r
\r
/**\r
* Handles all write modes in software, using the VT font calls for rendering.\r
* \note Calls the cursor clear and redraw if the cursor area is touched\r
*/\r
-extern int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t Length, void *Src);\r
+extern int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t Length, const void *Src);\r
\r
/**\r
* \name Software cursor rendering\r
*/
typedef struct sVFS_SelectList tVFS_SelectList;
+typedef struct sVFS_NodeType tVFS_NodeType;
+
/**
* \name tVFS_Node Flags
* \brief Flag values for tVFS_Node.Flags
* \}
*/
+ /**
+ * \brief Functions associated with the node
+ */
+ tVFS_NodeType *Type;
+} tVFS_Node;
+
+/**
+ * \brief Functions for a specific node type
+ */
+struct sVFS_NodeType
+{
+ /**
+ * \brief Debug name for the type
+ */
+ const char *TypeName;
+
/**
* \name Common Functions
* \brief Functions that are used no matter the value of .Flags
* \param Buffer Source of written data
* \return Number of bytes read
*/
- Uint64 (*Write)(struct sVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+ Uint64 (*Write)(struct sVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
/**
* \brief Map a region of a file into memory
* \param Node Pointer to this node (directory)
* \param Child Node to create a new link to
* \param NewName Name for the new link
- * \return Zeron on success, non-zero on error (see errno.h)
+ * \retur Zeron on success, non-zero on error (see errno.h)
*/
int (*Link)(struct sVFS_Node *Node, struct sVFS_Node *Child, const char *NewName);
/**
* \}
*/
-} tVFS_Node;
+};
/**
* \brief VFS Driver (Filesystem) Definition
// --- mount.c ---
extern tVFS_Mount *VFS_GetMountByIdent(Uint32 MountID);
+
+// --- VFS Helpers ---
+static inline void _CloseNode(tVFS_Node *Node)
+{
+ if(Node && Node->Type && Node->Type->Close)
+ Node->Type->Close( Node );
+}
+
+
#endif
// Permissions Check
if( !VFS_CheckACL(parent, VFS_PERM_EXECUTE|VFS_PERM_WRITE) ) {
- if(parent->Close) parent->Close( parent );
+ _CloseNode(parent);
free(absPath);
LEAVE('i', -1);
return -1;
LOG("parent = %p", parent);
- if(parent->MkNod == NULL) {
+ if(!parent->Type || !parent->Type->MkNod) {
Warning("VFS_MkNod - Directory has no MkNod method");
LEAVE('i', -1);
return -1;
}
// Create node
- ret = parent->MkNod(parent, name, Flags);
+ ret = parent->Type->MkNod(parent, name, Flags);
// Free allocated string
free(absPath);
// Free Parent
- if(parent->Close) parent->Close( parent );
+ _CloseNode(parent);
// Error Check
if(ret == 0) {
{
char *realLink;
int fp;
- char *_link;
ENTER("sName sLink", Name, Link);
// Get absolue path name
- _link = VFS_GetAbsPath( Link );
- if(!_link) {
+ realLink = VFS_GetAbsPath( Link );
+ if(!realLink) {
Log_Warning("VFS", "Path '%s' is badly formed", Link);
LEAVE('i', -1);
return -1;
}
- LOG("_link = '%s'", _link);
-
- #if 1
- {
- tVFS_Node *destNode = VFS_ParsePath( _link, &realLink, NULL );
- #if 0
- // Get true path and node
- free(_link);
- _link = NULL;
- #else
- realLink = _link;
- #endif
-
- // Check if destination exists
- if(!destNode) {
- Log_Warning("VFS", "File '%s' does not exist, symlink not created", Link);
- return -1;
- }
-
- // Derefence the destination
- if(destNode->Close) destNode->Close(destNode);
- }
- #else
- realLink = _link;
- #endif
LOG("realLink = '%s'", realLink);
// Make node
if( VFS_MkNod(Name, VFS_FFLAG_SYMLINK) != 0 ) {
Log_Warning("VFS", "Unable to create link node '%s'", Name);
+ free(realLink);
LEAVE('i', -2);
return -2; // Make link node
}
//ENTER("ph pDest", h, Dest);
- if(!h || h->Node->ReadDir == NULL) {
+ if(!h || !h->Node->Type || !h->Node->Type->ReadDir) {
//LEAVE('i', 0);
return 0;
}
}
do {
- tmp = h->Node->ReadDir(h->Node, h->Position);
+ tmp = h->Node->Type->ReadDir(h->Node, h->Position);
if((Uint)tmp < (Uint)VFS_MAXSKIP)
h->Position += (Uint)tmp;
else
tVFS_Driver gDevFS_Info = {
"devfs", 0, DevFS_InitDevice, NULL, NULL
};
+tVFS_NodeType gDevFS_DirType = {
+ .TypeName = "DevFS-Dir",
+ .ReadDir = DevFS_ReadDir,
+ .FindDir = DevFS_FindDir
+ };
tVFS_Node gDevFS_RootNode = {
.Size = 0,
.Flags = VFS_FFLAG_DIRECTORY,
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
- .ReadDir = DevFS_ReadDir,
- .FindDir = DevFS_FindDir
+ .Type = &gDevFS_DirType
};
tDevFS_Driver *gDevFS_Drivers = NULL;
int giDevFS_NextID = 1;
tVFS_Node *Root_FindDir(tVFS_Node *Node, const char *Name);
char *Root_ReadDir(tVFS_Node *Node, int Pos);
Uint64 Root_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
tRamFS_File *Root_int_AllocFile(void);
// === GLOBALS ===
{{1,0}, {0,VFS_PERM_ALL^VFS_PERM_EXECUTE}}, // Group (Root)
{{0,-1}, {0,VFS_PERM_READ}} // World (Nobody)
};
+tVFS_NodeType gRootFS_DirType = {
+ .TypeName = "RootFS-Dir",
+ .ReadDir = Root_ReadDir,
+ .FindDir = Root_FindDir,
+ .MkNod = Root_MkNod
+};
+tVFS_NodeType gRootFS_FileType = {
+ .TypeName = "RootFS-File",
+ .Read = Root_Read,
+ .Write = Root_Write,
+};
// === CODE ===
/**
= root->Node.ATime = now();
root->Node.NumACLs = 3;
root->Node.ACLs = RootFS_DirACLs;
-
- //root->Node.Close = Root_CloseFile; // Not Needed (It's a RAM Disk!)
- //root->Node.Relink = Root_RelinkRoot; // Not Needed (Why relink the root of the tree)
- root->Node.FindDir = Root_FindDir;
- root->Node.ReadDir = Root_ReadDir;
- root->Node.MkNod = Root_MkNod;
+
+ root->Node.Type = &gRootFS_DirType;
return &root->Node;
}
if(Flags & VFS_FFLAG_DIRECTORY)
{
child->Node.ACLs = RootFS_DirACLs;
- child->Node.ReadDir = Root_ReadDir;
- child->Node.FindDir = Root_FindDir;
- child->Node.MkNod = Root_MkNod;
+ child->Node.Type = &gRootFS_DirType;
} else {
if(Flags & VFS_FFLAG_SYMLINK)
child->Node.ACLs = RootFS_DirACLs;
else
child->Node.ACLs = RootFS_FileACLs;
- child->Node.Read = Root_Read;
- child->Node.Write = Root_Write;
+ child->Node.Type = &gRootFS_FileType;
}
prev->Next = child;
* \fn Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Write to a file in the root directory
*/
-Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
{
tRamFS_File *file = Node->ImplPtr;
if( !(h->Mode & VFS_OPENFLAG_READ) || h->Node->Flags & VFS_FFLAG_DIRECTORY )
LEAVE_RET('i', -1);
- if(!h->Node->Read) LEAVE_RET('i', 0);
+ if(!h->Node->Type || !h->Node->Type->Read) LEAVE_RET('i', 0);
- ret = h->Node->Read(h->Node, h->Position, Length, Buffer);
+ ret = h->Node->Type->Read(h->Node, h->Position, Length, Buffer);
if(ret == -1) LEAVE_RET('i', -1);
h->Position += ret;
if( !(h->Mode & VFS_OPENFLAG_READ) ) return -1;
if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) return -1;
- if(!h->Node->Read) {
+ if( !h->Node->Type || !h->Node->Type->Read) {
Warning("VFS_ReadAt - Node %p, does not have a read method", h->Node);
return 0;
}
- ret = h->Node->Read(h->Node, Offset, Length, Buffer);
+ ret = h->Node->Type->Read(h->Node, Offset, Length, Buffer);
if(ret == -1) return -1;
return ret;
}
if( !(h->Mode & VFS_OPENFLAG_WRITE) ) return -1;
if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) return -1;
- if(!h->Node->Write) return 0;
+ if( !h->Node->Type || !h->Node->Type->Write ) return 0;
- // TODO: This is a hack, I need to change VFS_Node to have "const void*"
- ret = h->Node->Write(h->Node, h->Position, Length, (void*)Buffer);
+ ret = h->Node->Type->Write(h->Node, h->Position, Length, Buffer);
if(ret == -1) return -1;
+
h->Position += ret;
return ret;
}
if( !(h->Mode & VFS_OPENFLAG_WRITE) ) return -1;
if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) return -1;
- if(!h->Node->Write) return 0;
- // TODO: This is a hack, I need to change VFS_Node to have "const void*"
- ret = h->Node->Write(h->Node, Offset, Length, (void*)Buffer);
+ if(!h->Node->Type || !h->Node->Type->Write) return 0;
+ ret = h->Node->Type->Write(h->Node, Offset, Length, Buffer);
+
if(ret == -1) return -1;
return ret;
}
h = VFS_GetHandle(FD);
if(!h) return -1;
- if(!h->Node->IOCtl) return -1;
- return h->Node->IOCtl(h->Node, ID, Buffer);
+ if(!h->Node->Type || !h->Node->Type->IOCtl) return -1;
+ return h->Node->Type->IOCtl(h->Node, ID, Buffer);
}
/**
//Log(" VFS_GetTruePath: node=%p, ret='%s'", node, ret);
if(!node) return NULL;
- if(node->Close) node->Close(node);
+ if(node->Type->Close) node->Type->Close(node);
return ret;
}
#include <vfs.h>
// === PROTOTYPES ===
-tVFS_Node *VFS_MemFile_Create(tVFS_Node *Unused, const char *Path);
+tVFS_Node *VFS_MemFile_Create(const char *Path);
void VFS_MemFile_Close(tVFS_Node *Node);
Uint64 VFS_MemFile_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
// === GLOBALS ===
-tVFS_Node gVFS_MemRoot = {
- .Flags = VFS_FFLAG_DIRECTORY,
- .NumACLs = 0,
- .FindDir = VFS_MemFile_Create
+tVFS_NodeType gVFS_MemFileType = {
+ .Close = VFS_MemFile_Close,
+ .Read = VFS_MemFile_Read,
+ .Write = VFS_MemFile_Write
};
// === CODE ===
/**
- * \fn tVFS_Node *VFS_MemFile_Create(tVFS_Node *Unused, const char *Path)
- * \note Treated as finddir by VFS_ParsePath
+ * \fn tVFS_Node *VFS_MemFile_Create(const char *Path)
*/
-tVFS_Node *VFS_MemFile_Create(tVFS_Node *Unused, const char *Path)
+tVFS_Node *VFS_MemFile_Create(const char *Path)
{
Uint base, size;
const char *str = Path;
ret->ACLs = &gVFS_ACL_EveryoneRWX;
// Functions
- ret->Close = VFS_MemFile_Close;
- ret->Read = VFS_MemFile_Read;
- ret->Write = VFS_MemFile_Write;
+ ret->Type = &gVFS_MemFileType;
return ret;
}
* \fn Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Write to a memory file
*/
-Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
{
// Check for use of free'd file
if(Node->ImplPtr == NULL) return 0;
{
if( pb->PhysAddrs[pagenum - pb->BaseOffset] == 0 )
{
- if( h->Node->MMap )
- h->Node->MMap(h->Node, pagenum*PAGE_SIZE, PAGE_SIZE, (void*)mapping_dest);
+ tVFS_NodeType *nt = h->Node->Type;
+ if( !nt )
+ {
+ // TODO: error
+ }
+ else if( nt->MMap )
+ nt->MMap(h->Node, pagenum*PAGE_SIZE, PAGE_SIZE, (void*)mapping_dest);
else
{
int read_len;
return NULL;
}
// TODO: Clip read length
- read_len = h->Node->Read(h->Node, pagenum*PAGE_SIZE, PAGE_SIZE, (void*)mapping_dest);
+ read_len = nt->Read(h->Node, pagenum*PAGE_SIZE, PAGE_SIZE, (void*)mapping_dest);
// if( read_len != PAGE_SIZE ) {
// memset( (void*)(mapping_dest+read_len), 0, PAGE_SIZE-read_len );
// }
ent->Node.ReferenceCount = 1;
next = ent->Next;
- if(ent->Node.Close)
- ent->Node.Close( &ent->Node );
+ if(ent->Node.Type && ent->Node.Type->Close)
+ ent->Node.Type->Close( &ent->Node );
free(ent);
ent = next;
#define MAX_PATH_LEN 255
// === IMPORTS ===
-extern tVFS_Node gVFS_MemRoot;
extern tVFS_Mount *gVFS_RootMount;
extern int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode);
+extern tVFS_Node *VFS_MemFile_Create(const char *Path);
// === PROTOTYPES ===
int VFS_int_CreateHandle( tVFS_Node *Node, tVFS_Mount *Mount, int Mode );
ENTER("sPath pTruePath", Path, TruePath);
- // Memory File
- if(Path[0] == '$') {
+ // HACK: Memory File
+ if(Threads_GetUID() == 0 && Path[0] == '$') {
if(TruePath) {
*TruePath = malloc(strlen(Path)+1);
strcpy(*TruePath, Path);
}
- curNode = gVFS_MemRoot.FindDir(&gVFS_MemRoot, Path);
+ curNode = VFS_MemFile_Create(Path);
if(MountPoint) {
*MountPoint = NULL;
}
// Check permissions on root of filesystem
if( !VFS_CheckACL(curNode, VFS_PERM_EXECUTE) ) {
- if(curNode->Close) curNode->Close( curNode );
- if(TruePath) {
- free(*TruePath);
- *TruePath = NULL;
- }
//Log("Permissions fail on '%s'", Path);
- LEAVE('n');
- return NULL;
+ goto _error;
}
// Check if the node has a FindDir method
- if( !curNode->FindDir )
+ if( !curNode->Type->FindDir )
{
- if(curNode->Close) curNode->Close(curNode);
- if(TruePath) {
- free(*TruePath);
- *TruePath = NULL;
- }
//Log("FindDir fail on '%s'", Path);
- LEAVE('n');
- return NULL;
+ goto _error;
}
- LOG("FindDir{=%p}(%p, '%s')", curNode->FindDir, curNode, pathEle);
+ LOG("FindDir{=%p}(%p, '%s')", curNode->Type->FindDir, curNode, pathEle);
// Get Child Node
- tmpNode = curNode->FindDir(curNode, pathEle);
+ tmpNode = curNode->Type->FindDir(curNode, pathEle);
LOG("tmpNode = %p", tmpNode);
- if(curNode->Close) {
- //LOG2("curNode->Close = %p", curNode->Close);
- curNode->Close(curNode);
- }
+ _CloseNode( curNode );
curNode = tmpNode;
// Error Check
if(!curNode) {
LOG("Node '%s' not found in dir '%s'", pathEle, Path);
- if(TruePath) {
- free(*TruePath);
- *TruePath = NULL;
- }
- //Log("Child fail on '%s' ('%s)", Path, pathEle);
- LEAVE('n');
- return NULL;
+ goto _error;
}
// Handle Symbolic Links
free(*TruePath);
*TruePath = NULL;
}
- if(!curNode->Read) {
+ if(!curNode->Type || !curNode->Type->Read) {
Log_Warning("VFS", "VFS_ParsePath - Read of symlink node %p'%s' is NULL",
curNode, Path);
- if(curNode->Close) curNode->Close(curNode);
- // No need to free *TruePath, it should already be NULL
- LEAVE('n');
- return NULL;
+ goto _error;
}
if(iNestedLinks > MAX_NESTED_LINKS) {
- if(curNode->Close) curNode->Close(curNode);
- LEAVE('n');
- return NULL;
+ Log_Notice("VFS", "VFS_ParsePath - Nested link limit exceeded");
+ goto _error;
}
// Parse Symlink Path
{
int remlen = strlen(Path) - (ofs + nextSlash);
if( curNode->Size + remlen > MAX_PATH_LEN ) {
- if(curNode->Close) curNode->Close(curNode);
Log_Warning("VFS", "VFS_ParsePath - Symlinked path too long");
- LEAVE('n');
- return NULL;
+ goto _error;
}
- curNode->Read( curNode, 0, curNode->Size, path_buffer );
+ curNode->Type->Read( curNode, 0, curNode->Size, path_buffer );
path_buffer[ curNode->Size ] = '\0';
LOG("path_buffer = '%s'", path_buffer);
strcat(path_buffer, Path + ofs+nextSlash);
if( !(curNode->Flags & VFS_FFLAG_DIRECTORY) )
{
Log_Warning("VFS", "VFS_ParsePath - Path segment is not a directory");
- if(TruePath) free(*TruePath);
- LEAVE('n');
- return NULL;
+ goto _error;
}
// Check if path needs extending
// Check if allocation succeeded
if(!tmp) {
Log_Warning("VFS", "VFS_ParsePath - Unable to reallocate true path buffer");
- free(*TruePath);
- *TruePath = NULL;
- if(curNode->Close) curNode->Close(curNode);
- LEAVE('n');
- return NULL;
+ goto _error;
}
*TruePath = tmp;
// Append to path
// - Extend Path
retLength += nextSlash + 1;
}
-
- if( !curNode->FindDir ) {
- if(curNode->Close) curNode->Close(curNode);
- if(TruePath) {
- free(*TruePath);
- *TruePath = NULL;
- }
+
+ // Check final finddir call
+ if( !curNode->Type || !curNode->Type->FindDir ) {
Log_Warning("VFS", "VFS_ParsePath - FindDir doesn't exist for element of '%s'", Path);
- LEAVE('n');
- return NULL;
+ goto _error;
}
// Get last node
LOG("FindDir(%p, '%s')", curNode, &Path[ofs]);
- tmpNode = curNode->FindDir(curNode, &Path[ofs]);
+ tmpNode = curNode->Type->FindDir(curNode, &Path[ofs]);
LOG("tmpNode = %p", tmpNode);
- if(curNode->Close) curNode->Close(curNode);
// Check if file was found
if(!tmpNode) {
LOG("Node '%s' not found in dir '%s'", &Path[ofs], Path);
- //Log("Child fail '%s' ('%s')", Path, &Path[ofs]);
- if(TruePath) free(*TruePath);
- if(curNode->Close) curNode->Close(curNode);
- LEAVE('n');
- return NULL;
+ goto _error;
}
+ _CloseNode( curNode );
if(TruePath)
{
// Check if allocation succeeded
if(!tmp) {
Log_Warning("VFS", "VFS_ParsePath - Unable to reallocate true path buffer");
- free(*TruePath);
- if(tmpNode->Close) tmpNode->Close(curNode);
- LEAVE('n');
- return NULL;
+ goto _error;
}
*TruePath = tmp;
// Append to path
LEAVE('p', tmpNode);
return tmpNode;
+
+_error:
+ _CloseNode( curNode );
+
+ if(TruePath && *TruePath) {
+ free(*TruePath);
+ *TruePath = NULL;
+ }
+ LEAVE('n');
+ return NULL;
}
/**
// Permissions Check
if( !VFS_CheckACL(Node, i) ) {
- if(Node->Close) Node->Close( Node );
+ _CloseNode( Node );
Log_Log("VFS", "VFS_int_CreateHandle: Permissions Failed");
errno = EACCES;
LEAVE_RET('i', -1);
Log_Warning("VFS", "VFS_Open - Symlink is too long (%i)", node->Size);
LEAVE_RET('i', -1);
}
- if( !node->Read ) {
+ if( !node->Type || !node->Type->Read ) {
Log_Warning("VFS", "VFS_Open - No read method on symlink");
LEAVE_RET('i', -1);
}
// Read symlink's path
- node->Read( node, 0, node->Size, tmppath );
+ node->Type->Read( node, 0, node->Size, tmppath );
tmppath[ node->Size ] = '\0';
- if(node->Close) node->Close( node );
+ _CloseNode( node );
// Open the target
node = VFS_ParsePath(tmppath, NULL, &mnt);
if(!node) {
// Check for directory
if( !(h->Node->Flags & VFS_FFLAG_DIRECTORY) ) {
- Log_Warning("VFS", "VFS_OpenChild - Passed handle is not a directory", FD);
+ Log_Warning("VFS", "VFS_OpenChild - Passed handle is not a directory");
+ errno = ENOTDIR;
+ LEAVE_RET('i', -1);
+ }
+
+ // Sanity check
+ if( !h->Node->Type || !h->Node->Type->FindDir ) {
+ Log_Error("VFS", "VFS_OpenChild - Node does not have a type/is missing FindDir");
errno = ENOTDIR;
LEAVE_RET('i', -1);
}
// Find Child
- node = h->Node->FindDir(h->Node, Name);
+ node = h->Node->Type->FindDir(h->Node, Name);
if(!node) {
errno = ENOENT;
LEAVE_RET('i', -1);
}
#endif
- if(h->Node->Close)
- h->Node->Close( h->Node );
+ _CloseNode(h->Node);
h->Node = NULL;
}
int BGA_int_MapFB(void *Dest);\r
// Filesystem\r
Uint64 BGA_Read(tVFS_Node *Node, Uint64 off, Uint64 len, void *buffer);\r
-Uint64 BGA_Write(tVFS_Node *Node, Uint64 off, Uint64 len, void *buffer);\r
+Uint64 BGA_Write(tVFS_Node *Node, Uint64 off, Uint64 len, const void *buffer);\r
int BGA_IOCtl(tVFS_Node *Node, int ID, void *Data);\r
\r
// === GLOBALS ===\r
MODULE_DEFINE(0, VERSION, BochsGA, BGA_Install, NULL, "PCI", NULL);\r
-tDevFS_Driver gBGA_DriverStruct = {\r
- NULL, "BochsGA",\r
- {\r
+tVFS_NodeType gBGA_NodeType = {\r
.Read = BGA_Read,\r
.Write = BGA_Write,\r
.IOCtl = BGA_IOCtl\r
- }\r
-};\r
+ };\r
+tDevFS_Driver gBGA_DriverStruct = {\r
+ NULL, "BochsGA",\r
+ {.Type = &gBGA_NodeType}\r
+ };\r
int giBGA_CurrentMode = -1;\r
tVideo_IOCtl_Pos gBGA_CursorPos = {-1,-1};\r
Uint *gBGA_Framebuffer;\r
/**\r
* \brief Write to the framebuffer\r
*/\r
-Uint64 BGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)\r
+Uint64 BGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)\r
{\r
if( giBGA_CurrentMode == -1 ) BGA_int_UpdateMode(0);\r
return DrvUtil_Video_WriteLFB(&gBGA_DrvUtil_BufInfo, Offset, Length, Buffer);\r
// === PROTOTYPES ===\r
int Vesa_Install(char **Arguments);\r
Uint64 Vesa_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);\r
-Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);\r
+Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);\r
int Vesa_IOCtl(tVFS_Node *Node, int ID, void *Data);\r
int Vesa_Int_SetMode(int Mode);\r
int Vesa_Int_FindMode(tVideo_IOCtl_Mode *data);\r
\r
// === GLOBALS ===\r
MODULE_DEFINE(0, VERSION, Vesa, Vesa_Install, NULL, "PCI", "VM8086", NULL);\r
-tDevFS_Driver gVesa_DriverStruct = {\r
- NULL, "Vesa",\r
- {\r
+tVFS_NodeType gVesa_NodeType = {\r
.Read = Vesa_Read,\r
.Write = Vesa_Write,\r
.IOCtl = Vesa_IOCtl\r
- }\r
-};\r
+ };\r
+tDevFS_Driver gVesa_DriverStruct = {\r
+ NULL, "Vesa",\r
+ {.Type = &gVesa_NodeType}\r
+ };\r
tMutex glVesa_Lock;\r
tVM8086 *gpVesa_BiosState;\r
int giVesaDriverId = -1;\r
/**\r
* \brief Write to the framebuffer\r
*/\r
-Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)\r
+Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)\r
{\r
if( gVesa_Modes[giVesaCurrentMode].framebuffer == 0 ) {\r
Log_Warning("VESA", "Vesa_Write - Non-LFB Modes not yet supported.");\r
// --- Helpers ---
tVFS_Node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeId);
+// === GLOBALS ===
+tVFS_NodeType gExt2_DirType = {
+ .TypeName = "ext2-dir",
+ .ReadDir = Ext2_ReadDir,
+ .FindDir = Ext2_FindDir,
+ .MkNod = Ext2_MkNod,
+ .Relink = Ext2_Relink,
+ .Link = Ext2_Link,
+ .Close = Ext2_CloseFile
+ };
+tVFS_NodeType gExt2_FileType = {
+ .TypeName = "ext2-file",
+ .Read = Ext2_Read,
+ .Write = Ext2_Write,
+ .Close = Ext2_CloseFile
+ };
+
// === CODE ===
/**
* \brief Reads a directory entry
retNode.ACLs = VFS_UnixToAcessACL(inode.i_mode & 0777, inode.i_uid, inode.i_gid);
// Set Function Pointers
- retNode.Read = Ext2_Read;
- retNode.Write = Ext2_Write;
- retNode.Close = Ext2_CloseFile;
+ retNode.Type = &gExt2_FileType;
switch(inode.i_mode & EXT2_S_IFMT)
{
break;
// Directory
case EXT2_S_IFDIR:
- retNode.ReadDir = Ext2_ReadDir;
- retNode.FindDir = Ext2_FindDir;
- retNode.MkNod = Ext2_MkNod;
- retNode.Relink = Ext2_Relink;
- retNode.Link = Ext2_Link;
+ retNode.Type = &gExt2_DirType;
retNode.Flags = VFS_FFLAG_DIRECTORY;
retNode.Data = calloc( sizeof(Uint16), DivUp(retNode.Size, Disk->BlockSize) );
break;
#include "ext2_common.h"\r
#include <modules.h>\r
\r
+// === IMPORTS ===\r
+extern tVFS_NodeType gExt2_DirType;\r
+\r
// === PROTOTYPES ===\r
int Ext2_Install(char **Arguments);\r
// Interface Functions\r
disk->RootNode.ImplPtr = disk; // Save disk pointer\r
disk->RootNode.Size = -1; // Fill in later (on readdir)\r
disk->RootNode.Flags = VFS_FFLAG_DIRECTORY;\r
- \r
- disk->RootNode.ReadDir = Ext2_ReadDir;\r
- disk->RootNode.FindDir = Ext2_FindDir;\r
- //disk->RootNode.Relink = Ext2_Relink;\r
+\r
+ disk->RootNode.Type = &gExt2_DirType;\r
\r
// Complete root node\r
disk->RootNode.UID = inode.i_uid;\r
// --- Read ---
extern Uint64 Ext2_Read(tVFS_Node *node, Uint64 offset, Uint64 length, void *buffer);
// --- Write ---
-extern Uint64 Ext2_Write(tVFS_Node *node, Uint64 offset, Uint64 length, void *buffer);
+extern Uint64 Ext2_Write(tVFS_Node *node, Uint64 offset, Uint64 length, const void *buffer);
#endif
#include "ext2_common.h"
// === PROTOYPES ===
-Uint64 Ext2_Write(tVFS_Node *node, Uint64 offset, Uint64 length, void *buffer);
Uint32 Ext2_int_AllocateBlock(tExt2_Disk *Disk, Uint32 PrevBlock);
void Ext2_int_DeallocateBlock(tExt2_Disk *Disk, Uint32 Block);
int Ext2_int_AppendBlock(tExt2_Disk *Disk, tExt2_Inode *Inode, Uint32 Block);
* \fn Uint64 Ext2_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Write to a file
*/
-Uint64 Ext2_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 Ext2_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
{
tExt2_Disk *disk = Node->ImplPtr;
tExt2_Inode inode;
tFAT_VolInfo gFAT_Disks[8];\r
int giFAT_PartCount = 0;\r
tVFS_Driver gFAT_FSInfo = {"fat", 0, FAT_InitDevice, FAT_Unmount, FAT_GetNodeFromINode, NULL};\r
+tVFS_NodeType gFAT_DirType = {\r
+ .TypeName = "FAT-Dir",\r
+ .ReadDir = FAT_ReadDir,\r
+ .FindDir = FAT_FindDir,\r
+ #if SUPPORT_WRITE\r
+ .MkNod = FAT_Mknod,\r
+ .Relink = FAT_Relink,\r
+ #endif\r
+ .Close = FAT_CloseFile\r
+ };\r
+tVFS_NodeType gFAT_FileType = {\r
+ .TypeName = "FAT-File",\r
+ .Read = FAT_Read,\r
+ #if SUPPORT_WRITE\r
+ .Write = FAT_Write,\r
+ #endif\r
+ .Close = FAT_CloseFile\r
+ };\r
\r
// === CODE ===\r
/**\r
node->ACLs = &gVFS_ACL_EveryoneRWX;\r
node->Flags = VFS_FFLAG_DIRECTORY;\r
node->CTime = node->MTime = node->ATime = now();\r
- \r
- node->Read = node->Write = NULL;\r
- node->ReadDir = FAT_ReadDir;\r
- node->FindDir = FAT_FindDir;\r
- #if SUPPORT_WRITE\r
- node->Relink = FAT_Relink;\r
- node->MkNod = FAT_Mknod;\r
- #else\r
- node->Relink = NULL;\r
- node->MkNod = NULL;\r
- #endif\r
- //node->Close = FAT_Unmount;\r
+\r
+ node->Type = &gFAT_DirType; \r
\r
giFAT_PartCount ++;\r
return node;\r
// Set pointers\r
if(node.Flags & VFS_FFLAG_DIRECTORY) {\r
//Log_Debug("FAT", "Directory %08x has size 0x%x", node.Inode, node.Size);\r
- node.ReadDir = FAT_ReadDir;\r
- node.FindDir = FAT_FindDir;\r
- #if SUPPORT_WRITE\r
- node.MkNod = FAT_Mknod;\r
- node.Relink = FAT_Relink;\r
- #endif\r
+ node.Type = &gFAT_DirType; \r
node.Size = -1;\r
}\r
else {\r
- node.Read = FAT_Read;\r
- #if SUPPORT_WRITE\r
- node.Write = FAT_Write;\r
- #endif\r
+ node.Type = &gFAT_FileType;\r
}\r
- node.Close = FAT_CloseFile;\r
\r
ret = Inode_CacheNode(disk->inodeHandle, &node);\r
LEAVE('p', ret);\r
// === GLOBALS ===
MODULE_DEFINE(0, 0x0A /*v0.1*/, FS_NTFS, NTFS_Install, NULL);
tVFS_Driver gNTFS_FSInfo = {"ntfs", 0, NTFS_InitDevice, NTFS_Unmount, NULL};
+tVFS_NodeType gNTFS_DirType = {
+ .TypeName = "NTFS-File",
+ .ReadDir = NTFS_ReadDir,
+ .FindDir = NTFS_FindDir,
+ .Close = NULL
+ };
tNTFS_Disk gNTFS_Disks;
disk->RootNode.NumACLs = 1;
disk->RootNode.ACLs = &gVFS_ACL_EveryoneRX;
- disk->RootNode.ReadDir = NTFS_ReadDir;
- disk->RootNode.FindDir = NTFS_FindDir;
- disk->RootNode.MkNod = NULL;
- disk->RootNode.Link = NULL;
- disk->RootNode.Relink = NULL;
- disk->RootNode.Close = NULL;
+ disk->RootNode.Type = &gNTFS_DirType;
+
NTFS_DumpEntry(disk, 5);
int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data);
// === GLOBALS ===
+tVFS_NodeType gIP_InterfaceNodeType = {
+ .ReadDir = IPStack_Iface_ReadDir,
+ .FindDir = IPStack_Iface_FindDir,
+ .IOCtl = IPStack_Iface_IOCtl
+};
//! Loopback (127.0.0.0/8, ::1) Pseudo-Interface
tInterface gIP_LoopInterface = {
.Node = {
.Size = -1,
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
- .ReadDir = IPStack_Iface_ReadDir,
- .FindDir = IPStack_Iface_FindDir,
- .IOCtl = IPStack_Iface_IOCtl
+ .Type = &gIP_InterfaceNodeType
},
.Adapter = NULL,
.Type = 0
iface->Node.Size = -1;
iface->Node.NumACLs = 1;
iface->Node.ACLs = &gVFS_ACL_EveryoneRX;
- iface->Node.ReadDir = IPStack_Iface_ReadDir;
- iface->Node.FindDir = IPStack_Iface_FindDir;
- iface->Node.IOCtl = IPStack_Iface_IOCtl;
- iface->Node.MkNod = NULL;
- iface->Node.Link = NULL;
- iface->Node.Relink = NULL;
- iface->Node.Close = NULL;
+ iface->Node.Type = &gIP_InterfaceNodeType;
// Set Defaults
iface->TimeoutDelay = DEFAULT_TIMEOUT;
// === GLOBALS ===
MODULE_DEFINE(0, VERSION, IPStack, IPStack_Install, NULL, NULL);
+tVFS_NodeType gIP_RootNodeType = {
+ .ReadDir = IPStack_Root_ReadDir,
+ .FindDir = IPStack_Root_FindDir,
+ .IOCtl = IPStack_Root_IOCtl
+};
tDevFS_Driver gIP_DriverInfo = {
NULL, "ip",
{
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
.Flags = VFS_FFLAG_DIRECTORY,
- .ReadDir = IPStack_Root_ReadDir,
- .FindDir = IPStack_Root_FindDir,
- .IOCtl = IPStack_Root_IOCtl
+ .Type = &gIP_RootNodeType
}
};
int giIP_NextRouteId = 1;
tRoute *gIP_Routes;
tRoute *gIP_RoutesEnd;
+tVFS_NodeType gIP_RouteNodeType = {
+ .IOCtl = IPStack_Route_IOCtl
+};
+tVFS_NodeType gIP_RouteDirNodeType = {
+ .ReadDir = IPStack_RouteDir_ReadDir,
+ .FindDir = IPStack_RouteDir_FindDir,
+ .IOCtl = IPStack_RouteDir_IOCtl
+};
tVFS_Node gIP_RouteNode = {
.Flags = VFS_FFLAG_DIRECTORY,
.Size = -1,
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
- .ReadDir = IPStack_RouteDir_ReadDir,
- .FindDir = IPStack_RouteDir_FindDir,
- .IOCtl = IPStack_RouteDir_IOCtl
+ .Type = &gIP_RouteDirNodeType
};
// === CODE ===
return NULL;
}
iface = node->ImplPtr;
- if(node->Close) node->Close(node);
+ if(node->Type->Close) node->Type->Close(node);
}
// Get the size of the specified address type
rt->Node.Size = 0;
rt->Node.NumACLs = 1,
rt->Node.ACLs = &gVFS_ACL_EveryoneRO;
- rt->Node.IOCtl = IPStack_Route_IOCtl;
+ rt->Node.Type = &gIP_RouteNodeType;
// Set up state
rt->AddressType = iface->Type;
// --- Client
tVFS_Node *TCP_Client_Init(tInterface *Interface);
Uint64 TCP_Client_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 TCP_Client_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 TCP_Client_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
int TCP_Client_IOCtl(tVFS_Node *Node, int ID, void *Data);
void TCP_Client_Close(tVFS_Node *Node);
// --- Helpers
// === TEMPLATES ===
tSocketFile gTCP_ServerFile = {NULL, "tcps", TCP_Server_Init};
tSocketFile gTCP_ClientFile = {NULL, "tcpc", TCP_Client_Init};
+tVFS_NodeType gTCP_ServerNodeType = {
+ .TypeName = "TCP Server",
+ .ReadDir = TCP_Server_ReadDir,
+ .FindDir = TCP_Server_FindDir,
+ .IOCtl = TCP_Server_IOCtl,
+ .Close = TCP_Server_Close
+ };
+tVFS_NodeType gTCP_ClientNodeType = {
+ .TypeName = "TCP Client/Connection",
+ .Read = TCP_Client_Read,
+ .Write = TCP_Client_Write,
+ .IOCtl = TCP_Client_IOCtl,
+ .Close = TCP_Client_Close
+ };
// === GLOBALS ===
int giTCP_NumHalfopen = 0;
conn->Node.ACLs = &gVFS_ACL_EveryoneRW;
conn->Node.ImplPtr = conn;
conn->Node.ImplInt = srv->NextID ++;
- conn->Node.Read = TCP_Client_Read;
- conn->Node.Write = TCP_Client_Write;
- //conn->Node.Close = TCP_SrvConn_Close;
+ conn->Node.Type = &gTCP_ClientNodeType; // TODO: Special type for the server end?
// Hmm... Theoretically, this lock will never have to wait,
// as the interface is locked to the watching thread, and this
srv->Node.ImplPtr = srv;
srv->Node.NumACLs = 1;
srv->Node.ACLs = &gVFS_ACL_EveryoneRW;
- srv->Node.ReadDir = TCP_Server_ReadDir;
- srv->Node.FindDir = TCP_Server_FindDir;
- srv->Node.IOCtl = TCP_Server_IOCtl;
- srv->Node.Close = TCP_Server_Close;
+ srv->Node.Type = &gTCP_ServerNodeType;
SHORTLOCK(&glTCP_Listeners);
srv->Next = gTCP_Listeners;
conn->Node.ImplPtr = conn;
conn->Node.NumACLs = 1;
conn->Node.ACLs = &gVFS_ACL_EveryoneRW;
- conn->Node.Read = TCP_Client_Read;
- conn->Node.Write = TCP_Client_Write;
- conn->Node.IOCtl = TCP_Client_IOCtl;
- conn->Node.Close = TCP_Client_Close;
+ conn->Node.Type = &gTCP_ClientNodeType;
conn->RecievedBuffer = RingBuffer_Create( TCP_RECIEVE_BUFFER_SIZE );
#if 0
/**
* \brief Send a data packet on a connection
*/
-void TCP_INT_SendDataPacket(tTCPConnection *Connection, size_t Length, void *Data)
+void TCP_INT_SendDataPacket(tTCPConnection *Connection, size_t Length, const void *Data)
{
char buf[sizeof(tTCPHeader)+Length];
tTCPHeader *packet = (void*)buf;
/**
* \brief Send some bytes on a connection
*/
-Uint64 TCP_Client_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 TCP_Client_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
{
tTCPConnection *conn = Node->ImplPtr;
size_t rem = Length;
// --- Client Channels
tVFS_Node *UDP_Channel_Init(tInterface *Interface);
Uint64 UDP_Channel_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 UDP_Channel_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 UDP_Channel_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
int UDP_Channel_IOCtl(tVFS_Node *Node, int ID, void *Data);
void UDP_Channel_Close(tVFS_Node *Node);
// --- Helpers
void UDP_int_FreePort(Uint16 Port);
// === GLOBALS ===
+tVFS_NodeType gUDP_NodeType = {
+ .Read = UDP_Channel_Read,
+ .Write = UDP_Channel_Write,
+ .IOCtl = UDP_Channel_IOCtl,
+ .Close = UDP_Channel_Close
+};
tMutex glUDP_Channels;
tUDPChannel *gpUDP_Channels;
new->Node.ImplPtr = new;
new->Node.NumACLs = 1;
new->Node.ACLs = &gVFS_ACL_EveryoneRW;
- new->Node.Read = UDP_Channel_Read;
- new->Node.Write = UDP_Channel_Write;
- new->Node.IOCtl = UDP_Channel_IOCtl;
- new->Node.Close = UDP_Channel_Close;
+ new->Node.Type = &gUDP_NodeType;
Mutex_Acquire(&glUDP_Channels);
new->Next = gpUDP_Channels;
/**
* \brief Write to the channel file (send a packet)
*/
-Uint64 UDP_Channel_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 UDP_Channel_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
{
tUDPChannel *chan = Node->ImplPtr;
tUDPEndpoint *ep;
int KB_IOCtl(tVFS_Node *Node, int Id, void *Data);
// === GLOBALS ===
+tVFS_NodeType gKB_NodeType = {
+ .IOCtl = KB_IOCtl
+};
tDevFS_Driver gKB_DevInfo = {
NULL, "PS2Keyboard",
- {
- .NumACLs = 0,
- .Size = 0,
- .IOCtl = KB_IOCtl
- }
+ { .Type = &gKB_NodeType }
};
tKeybardCallback gKB_Callback = NULL;
Uint32 **gpKB_Map = gpKBDUS;
int giMouse_Cycle = 0; // IRQ Position\r
Uint8 gaMouse_Bytes[4] = {0,0,0,0};\r
// - Driver definition\r
+tVFS_NodeType gMouse_NodeType = {\r
+ .Read = PS2Mouse_Read,\r
+ .IOCtl = PS2Mouse_IOCtl\r
+};\r
tDevFS_Driver gMouse_DriverStruct = {\r
NULL, "PS2Mouse",\r
{\r
.NumACLs = 1, .ACLs = &gVFS_ACL_EveryoneRX,\r
- .Read = PS2Mouse_Read, .IOCtl = PS2Mouse_IOCtl\r
+ .Type = &gMouse_NodeType\r
}\r
};\r
\r
char *Ne2k_ReadDir(tVFS_Node *Node, int Pos);
tVFS_Node *Ne2k_FindDir(tVFS_Node *Node, const char *Name);
int Ne2k_IOCtl(tVFS_Node *Node, int ID, void *Data);
-Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
Uint64 Ne2k_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
int Ne2k_int_ReadDMA(tCard *Card, int FirstPage, int NumPages, void *Buffer);
// === GLOBALS ===
MODULE_DEFINE(0, VERSION, Ne2k, Ne2k_Install, NULL, NULL);
+tVFS_NodeType gNe2K_RootNodeType = {
+ .ReadDir = Ne2k_ReadDir,
+ .FindDir = Ne2k_FindDir,
+ .IOCtl = Ne2k_IOCtl
+ };
+tVFS_NodeType gNe2K_DevNodeType = {
+ .Write = Ne2k_Write,
+ .Read = Ne2k_Read,
+ .IOCtl = Ne2k_IOCtl
+ };
tDevFS_Driver gNe2k_DriverInfo = {
NULL, "ne2k",
{
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
.Flags = VFS_FFLAG_DIRECTORY,
- .ReadDir = Ne2k_ReadDir,
- .FindDir = Ne2k_FindDir,
- .IOCtl = Ne2k_IOCtl
+ .Type = &gNe2K_RootNodeType
}
};
Uint16 gNe2k_BaseAddress;
gpNe2k_Cards[ k ].Node.ImplPtr = &gpNe2k_Cards[ k ];
gpNe2k_Cards[ k ].Node.NumACLs = 0; // Root Only
gpNe2k_Cards[ k ].Node.CTime = now();
- gpNe2k_Cards[ k ].Node.Write = Ne2k_Write;
- gpNe2k_Cards[ k ].Node.Read = Ne2k_Read;
- gpNe2k_Cards[ k ].Node.IOCtl = Ne2k_IOCtl;
+ gpNe2k_Cards[ k ].Node.Type = &gNe2K_DevNodeType;
// Initialise packet semaphore
// - Start at zero, no max
}
/**
- * \fn Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+ * \fn Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
* \brief Send a packet from the network card
*/
-Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
{
tCard *Card = (tCard*)Node->ImplPtr;
- Uint16 *buf = Buffer;
+ const Uint16 *buf = Buffer;
int rem = Length;
int page;
tVFS_Node *RTL8139_FindDir(tVFS_Node *Node, const char *Filename);
int RTL8139_RootIOCtl(tVFS_Node *Node, int ID, void *Arg);
Uint64 RTL8139_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 RTL8139_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 RTL8139_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
int RTL8139_IOCtl(tVFS_Node *Node, int ID, void *Arg);
void RTL8139_IRQHandler(int Num, void *Ptr);
// === GLOBALS ===
MODULE_DEFINE(0, VERSION, RTL8139, RTL8139_Install, NULL, NULL);
+tVFS_NodeType gRTL8139_RootNodeType = {
+ .ReadDir = RTL8139_ReadDir,
+ .FindDir = RTL8139_FindDir,
+ .IOCtl = RTL8139_IOCtl
+ };
+tVFS_NodeType gRTL8139_DevNodeType = {
+ .Write = RTL8139_Write,
+ .Read = RTL8139_Read,
+ .IOCtl = RTL8139_IOCtl
+ };
tDevFS_Driver gRTL8139_DriverInfo = {
NULL, "RTL8139",
{
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
.Flags = VFS_FFLAG_DIRECTORY,
- .ReadDir = RTL8139_ReadDir,
- .FindDir = RTL8139_FindDir,
- .IOCtl = RTL8139_RootIOCtl
+ .Type = &gRTL8139_RootNodeType
}
};
int giRTL8139_CardCount;
card->Node.ImplPtr = card;
card->Node.NumACLs = 0;
card->Node.CTime = now();
- card->Node.Write = RTL8139_Write;
- card->Node.Read = RTL8139_Read;
- card->Node.IOCtl = RTL8139_IOCtl;
+ card->Node.Type = &gRTL8139_DevNodeType;
Log_Log("RTL8139", "Card %i 0x%04x, IRQ %i %02x:%02x:%02x:%02x:%02x:%02x",
i, card->IOBase, card->IRQ,
return Length;
}
-Uint64 RTL8139_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 RTL8139_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
{
int td;
Uint32 status;
char *ATA_ReadDir(tVFS_Node *Node, int Pos);
tVFS_Node *ATA_FindDir(tVFS_Node *Node, const char *Name);
Uint64 ATA_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
int ATA_IOCtl(tVFS_Node *Node, int Id, void *Data);
// Read/Write Interface/Quantiser
Uint ATA_ReadRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk);
-Uint ATA_WriteRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk);
+Uint ATA_WriteRaw(Uint64 Address, Uint Count, const void *Buffer, Uint Disk);
// === GLOBALS ===
MODULE_DEFINE(0, VERSION, i386ATA, ATA_Install, NULL, "PCI", NULL);
+tVFS_NodeType gATA_RootNodeType = {
+ .TypeName = "ATA Root Node",
+ .ReadDir = ATA_ReadDir,
+ .FindDir = ATA_FindDir
+ };
+tVFS_NodeType gATA_DiskNodeType = {
+ .TypeName = "ATA Volume",
+ .Read = ATA_ReadFS,
+ .Write = ATA_WriteFS,
+ .IOCtl = ATA_IOCtl
+ };
tDevFS_Driver gATA_DriverInfo = {
NULL, "ata",
{
.Size = -1,
.Flags = VFS_FFLAG_DIRECTORY,
.ACLs = &gVFS_ACL_EveryoneRX,
- .ReadDir = ATA_ReadDir,
- .FindDir = ATA_FindDir
+ .Type = &gATA_RootNodeType
}
};
tATA_Disk gATA_Disks[MAX_ATA_DISKS];
node->Inode = (Disk << 8) | 0xFF;
node->ImplPtr = gATA_Disks[ Disk ].Name;
- node->ATime = node->MTime
- = node->CTime = now();
+ node->ATime = node->MTime = node->CTime = now();
- node->Read = ATA_ReadFS;
- node->Write = ATA_WriteFS;
- node->IOCtl = ATA_IOCtl;
+ node->Type = &gATA_DiskNodeType;
// --- Scan Partitions ---
LOG("Reading MBR");
Part->Node.Inode = (Disk << 8) | Num;
Part->Node.ImplPtr = Part->Name;
- Part->Node.Read = ATA_ReadFS;
- Part->Node.Write = ATA_WriteFS;
- Part->Node.IOCtl = ATA_IOCtl;
+ Part->Node.Type = &gATA_DiskNodeType;
Log_Notice("ATA", "Partition %s at 0x%llx+0x%llx", Part->Name, Part->Start, Part->Length);
LOG("Made '%s' (&Node=%p)", Part->Name, &Part->Node);
LEAVE('-');
}
/**
- * \fn Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+ * \fn Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
*/
-Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 ATA_WriteFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
{
int disk = Node->Inode >> 8;
int part = Node->Inode & 0xFF;
}
/**
- * \fn Uint ATA_WriteRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk)
+ * \fn Uint ATA_WriteRaw(Uint64 Address, Uint Count, const void *Buffer, Uint Disk)
*/
-Uint ATA_WriteRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk)
+Uint ATA_WriteRaw(Uint64 Address, Uint Count, const void *Buffer, Uint Disk)
{
int ret;
Uint offset;
MODULE_DEFINE(0, FDD_VERSION, Storage_FDDv2, FDD_Install, NULL, "x86_ISADMA", NULL);
tDrive gaFDD_Disks[MAX_DISKS];
tVFS_Node gaFDD_DiskNodes[MAX_DISKS];
+tVFS_NodeType gFDD_RootNodeType = {
+ .TypeName = "FDD Root Node",
+ .ReadDir = FDD_ReadDir,
+ .FindDir = FDD_FindDir,
+ .IOCtl = FDD_IOCtl
+ };
+tVFS_NodeType gFDD_DevNodeType = {
+ .TypeName = "FDD Device",
+ .Read = FDD_ReadFS,
+ .Write = NULL // FDD_WriteFS?
+ };
tDevFS_Driver gFDD_DriverInfo = {
NULL, "fdd",
{
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
.Flags = VFS_FFLAG_DIRECTORY,
- .ReadDir = FDD_ReadDir,
- .FindDir = FDD_FindDir,
- .IOCtl = FDD_IOCtl
+ .Type = &gFDD_RootNodeType
}
};
gaFDD_DiskNodes[i].Inode = i;
gaFDD_DiskNodes[i].Flags = 0;
gaFDD_DiskNodes[i].NumACLs = 0;
- gaFDD_DiskNodes[i].Read = FDD_ReadFS;
- gaFDD_DiskNodes[i].Write = NULL;//FDD_WriteFS;
+ gaFDD_DiskNodes[i].Type = &gFDD_DevNodeType;
gaFDD_DiskNodes[i].Size = 1440*1024; // TODO: Non 1.44 disks
}
// === PROTOTYPES ===
int VGA_Install(char **Arguments);
-Uint64 VGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
+Uint64 VGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer);
int VGA_IOCtl(tVFS_Node *Node, int Id, void *Data);
Uint8 VGA_int_GetColourNibble(Uint16 col);
-Uint16 VGA_int_GetWord(tVT_Char *Char);
+Uint16 VGA_int_GetWord(const tVT_Char *Char);
void VGA_int_SetCursor(Sint16 x, Sint16 y);
// --- 2D Acceleration Functions --
void VGA_2D_Fill(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour);
// === GLOBALS ===
MODULE_DEFINE(0, 0x000A, x86_VGAText, VGA_Install, NULL, NULL);
+tVFS_NodeType gVGA_NodeType = {
+ //.Read = VGA_Read,
+ .Write = VGA_Write,
+ .IOCtl = VGA_IOCtl
+ };
tDevFS_Driver gVGA_DevInfo = {
NULL, "x86_VGAText",
{
.NumACLs = 0,
.Size = VGA_WIDTH*VGA_HEIGHT*sizeof(tVT_Char),
- //.Read = VGA_Read,
- .Write = VGA_Write,
- .IOCtl = VGA_IOCtl
+ .Type = &gVGA_NodeType
}
};
Uint16 *gVGA_Framebuffer = (void*)( KERNEL_BASE|0xB8000 );
}
/**
- * \fn Uint64 VGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Writes a string of bytes to the VGA controller
*/
-Uint64 VGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+Uint64 VGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer)
{
if( giVGA_BufferFormat == VIDEO_BUFFMT_TEXT )
{
int num = Length / sizeof(tVT_Char);
int ofs = Offset / sizeof(tVT_Char);
int i = 0;
- tVT_Char *chars = Buffer;
+ const tVT_Char *chars = Buffer;
Uint16 word;
//ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
* \fn Uint16 VGA_int_GetWord(tVT_Char *Char)
* \brief Convers a character structure to a VGA character word
*/
-Uint16 VGA_int_GetWord(tVT_Char *Char)
+Uint16 VGA_int_GetWord(const tVT_Char *Char)
{
Uint16 ret;
Uint16 col;