git.ucc.asn.au
/
tpg
/
acess2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
e56e258
)
VFS - Rework to remove function pointers from tVFS_Node
author
John Hodge
<
[email protected]
>
Sat, 21 Jan 2012 01:17:59 +0000
(09:17 +0800)
committer
John Hodge
<
[email protected]
>
Sat, 21 Jan 2012 01:17:59 +0000
(09:17 +0800)
- Moved them to an indirect pointer (tVFS_NodeType)
- Also fixed constness in VFS_Write
38 files changed:
Kernel/drv/fifo.c
patch
|
blob
|
history
Kernel/drv/pci.c
patch
|
blob
|
history
Kernel/drv/proc.c
patch
|
blob
|
history
Kernel/drv/vterm.c
patch
|
blob
|
history
Kernel/drvutil.c
patch
|
blob
|
history
Kernel/include/api_drv_disk.h
patch
|
blob
|
history
Kernel/include/api_drv_video.h
patch
|
blob
|
history
Kernel/include/vfs.h
patch
|
blob
|
history
Kernel/include/vfs_int.h
patch
|
blob
|
history
Kernel/vfs/dir.c
patch
|
blob
|
history
Kernel/vfs/fs/devfs.c
patch
|
blob
|
history
Kernel/vfs/fs/root.c
patch
|
blob
|
history
Kernel/vfs/io.c
patch
|
blob
|
history
Kernel/vfs/main.c
patch
|
blob
|
history
Kernel/vfs/memfile.c
patch
|
blob
|
history
Kernel/vfs/mmap.c
patch
|
blob
|
history
Kernel/vfs/nodecache.c
patch
|
blob
|
history
Kernel/vfs/open.c
patch
|
blob
|
history
Modules/Display/BochsGA/bochsvbe.c
patch
|
blob
|
history
Modules/Display/VESA/main.c
patch
|
blob
|
history
Modules/Filesystems/Ext2/dir.c
patch
|
blob
|
history
Modules/Filesystems/Ext2/ext2.c
patch
|
blob
|
history
Modules/Filesystems/Ext2/ext2_common.h
patch
|
blob
|
history
Modules/Filesystems/Ext2/write.c
patch
|
blob
|
history
Modules/Filesystems/FAT/fat.c
patch
|
blob
|
history
Modules/Filesystems/NTFS/main.c
patch
|
blob
|
history
Modules/IPStack/interface.c
patch
|
blob
|
history
Modules/IPStack/main.c
patch
|
blob
|
history
Modules/IPStack/routing.c
patch
|
blob
|
history
Modules/IPStack/tcp.c
patch
|
blob
|
history
Modules/IPStack/udp.c
patch
|
blob
|
history
Modules/Input/PS2KbMouse/kb.c
patch
|
blob
|
history
Modules/Input/PS2KbMouse/ps2mouse.c
patch
|
blob
|
history
Modules/Network/NE2000/ne2000.c
patch
|
blob
|
history
Modules/Network/RTL8139/rtl8139.c
patch
|
blob
|
history
Modules/Storage/ATA/main.c
patch
|
blob
|
history
Modules/Storage/FDDv2/main.c
patch
|
blob
|
history
Modules/x86/VGAText/vga.c
patch
|
blob
|
history
diff --git
a/Kernel/drv/fifo.c
b/Kernel/drv/fifo.c
index
b27c678
..
4d3595b
100644
(file)
--- a/
Kernel/drv/fifo.c
+++ b/
Kernel/drv/fifo.c
@@
-31,11
+31,25
@@
tVFS_Node *FIFO_FindDir(tVFS_Node *Node, const char *Filename);
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);
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);
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",
{
tDevFS_Driver gFIFO_DriverInfo = {
NULL, "fifo",
{
@@
-43,11
+57,7
@@
tDevFS_Driver gFIFO_DriverInfo = {
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRW,
.Flags = VFS_FFLAG_DIRECTORY,
.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 = {
}
};
tVFS_Node gFIFO_AnonNode = {
@@
-280,7
+290,7
@@
Uint64 FIFO_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \fn Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Write to a fifo pipe
*/
* \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;
{
tPipe *pipe = Node->ImplPtr;
Uint len;
@@
-386,9
+396,7
@@
tPipe *FIFO_Int_NewPipe(int Size, const char *Name)
ret->Node.CTime
= ret->Node.MTime
= ret->Node.ATime = now();
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;
}
return ret;
}
diff --git
a/Kernel/drv/pci.c
b/Kernel/drv/pci.c
index
7234296
..
8745080
100644
(file)
--- a/
Kernel/drv/pci.c
+++ b/
Kernel/drv/pci.c
@@
-44,6
+44,15
@@
MODULE_DEFINE(0, 0x0100, PCI, PCI_Install, NULL, NULL);
int giPCI_InodeHandle = -1;
\r
int giPCI_DeviceCount = 0;
\r
tPCIDevice *gPCI_Devices = NULL;
\r
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
tDevFS_Driver gPCI_DriverStruct = {
\r
NULL, "pci",
\r
{
\r
@@
-51,8
+60,7
@@
tDevFS_Driver gPCI_DriverStruct = {
.Size = -1,
\r
.NumACLs = 1,
\r
.ACLs = &gVFS_ACL_EveryoneRX,
\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
}
\r
};
\r
Uint32 *gaPCI_PortBitmap = NULL;
\r
@@
-473,7
+481,7
@@
int PCI_int_EnumDevice(Uint16 bus, Uint16 slot, Uint16 fcn, tPCIDevice *info)
info->Node.NumACLs = 1;
\r
info->Node.ACLs = &gVFS_ACL_EveryoneRO;
\r
\r
info->Node.NumACLs = 1;
\r
info->Node.ACLs = &gVFS_ACL_EveryoneRO;
\r
\r
- info->Node.
Read = PCI_int_ReadDevic
e;
\r
+ info->Node.
Type = &gPCI_RootNodeTyp
e;
\r
\r
return 1;
\r
}
\r
\r
return 1;
\r
}
\r
diff --git
a/Kernel/drv/proc.c
b/Kernel/drv/proc.c
index
3283c86
..
73f4535
100644
(file)
--- a/
Kernel/drv/proc.c
+++ b/
Kernel/drv/proc.c
@@
-40,6
+40,15
@@
void SysFS_Comm_CloseFile(tVFS_Node *Node);
extern tSysFS_Ent gSysFS_Version; // Defined Later
extern tSysFS_Ent gSysFS_Root; // Defined Later
MODULE_DEFINE(0, VERSION, SysFS, SysFS_Install, NULL, NULL);
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
tSysFS_Ent gSysFS_Version_Kernel = {
NULL, NULL, // Nexts
&gSysFS_Version, // Parent
@@
-50,7
+59,7
@@
tSysFS_Ent gSysFS_Version_Kernel = {
.Size = 0,
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRO,
.Size = 0,
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRO,
- .
Read = SysFS_Comm_ReadFil
e
+ .
Type = &gSysFS_FileNodeTyp
e
},
"Kernel"
};
},
"Kernel"
};
@@
-64,8
+73,7
@@
tSysFS_Ent gSysFS_Version = {
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
.Flags = VFS_FFLAG_DIRECTORY,
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
.Flags = VFS_FFLAG_DIRECTORY,
- .ReadDir = SysFS_Comm_ReadDir,
- .FindDir = SysFS_Comm_FindDir
+ .Type = &gSysFS_DirNodeType
},
"Version"
};
},
"Version"
};
@@
-88,9
+96,7
@@
tDevFS_Driver gSysFS_DriverInfo = {
.Flags = VFS_FFLAG_DIRECTORY,
.ImplPtr = &gSysFS_Version,
.Size = sizeof(gSysFS_Root)/sizeof(tSysFS_Ent),
.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;
}
};
int giSysFS_NextFileID = 2;
@@
-158,8
+164,7
@@
int SysFS_RegisterFile(const char *Path, const char *Data, int Length)
child->Node.NumACLs = 1;
child->Node.ACLs = &gVFS_ACL_EveryoneRX;
child->Node.Flags = VFS_FFLAG_DIRECTORY;
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;
if( !prev ) {
if(ent)
ent->Node.ImplPtr = child;
@@
-212,8
+217,7
@@
int SysFS_RegisterFile(const char *Path, const char *Data, int Length)
child->Node.Size = Length;
child->Node.NumACLs = 1;
child->Node.ACLs = &gVFS_ACL_EveryoneRO;
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) {
// Add to parent's child list
if(ent) {
diff --git
a/Kernel/drv/vterm.c
b/Kernel/drv/vterm.c
index
b4df6e3
..
03e7c6c
100644
(file)
--- a/
Kernel/drv/vterm.c
+++ b/
Kernel/drv/vterm.c
@@
-94,16
+94,16
@@
char *VT_ReadDir(tVFS_Node *Node, int Pos);
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);
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);
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);
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, c
onst c
har *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 );
void VT_int_PutChar(tVTerm *Term, Uint32 Ch);
void VT_int_ScrollText(tVTerm *Term, int Count);
void VT_int_ScrollFramebuffer( tVTerm *Term, int Count );
@@
-122,6
+122,18
@@
const Uint16 caVT100Colours[] = {
// === GLOBALS ===
MODULE_DEFINE(0, VERSION, VTerm, VT_Install, NULL, DEFAULT_INPUT, NULL);
// === 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",
{
tDevFS_Driver gVT_DrvInfo = {
NULL, "VTerm",
{
@@
-129,9
+141,7
@@
tDevFS_Driver gVT_DrvInfo = {
.Size = NUM_VTS,
.Inode = -1,
.NumACLs = 0,
.Size = NUM_VTS,
.Inode = -1,
.NumACLs = 0,
- .ReadDir = VT_ReadDir,
- .FindDir = VT_FindDir,
- .IOCtl = VT_Root_IOCtl
+ .Type = &gVT_RootNodeType
}
};
// --- Terminals ---
}
};
// --- Terminals ---
@@
-254,10
+264,8
@@
int VT_Install(char **Arguments)
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.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);
}
// Semaphore_Init(&gVT_Terminals[i].InputSemaphore, 0, MAX_INPUT_CHARS8, "VTerm", gVT_Terminals[i].Name);
}
@@
-528,10
+536,10
@@
Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
}
/**
}
/**
- * \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
*/
* \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;
{
tVTerm *term = &gVT_Terminals[ Node->Inode ];
int size;
@@
-1293,10
+1301,10
@@
void VT_int_ParseEscape_StandardLarge(tVTerm *Term, char CmdChar, int argc, int
}
/**
}
/**
- * \fn int VT_int_ParseEscape(tVTerm *Term, char *Buffer)
+ * \fn int VT_int_ParseEscape(tVTerm *Term, c
onst c
har *Buffer)
* \brief Parses a VT100 Escape code
*/
* \brief Parses a VT100 Escape code
*/
-int VT_int_ParseEscape(tVTerm *Term, char *Buffer)
+int VT_int_ParseEscape(tVTerm *Term, c
onst c
har *Buffer)
{
char c;
int argc = 0, j = 1;
{
char c;
int argc = 0, j = 1;
@@
-1380,10
+1388,10
@@
int VT_int_ParseEscape(tVTerm *Term, char *Buffer)
}
/**
}
/**
- * \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
*/
* \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;
{
Uint32 val;
int i;
@@
-1395,7
+1403,7
@@
void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count)
if( Buffer[i] == 0x1B )
{
i ++;
if( Buffer[i] == 0x1B )
{
i ++;
- i += VT_int_ParseEscape(Term, (char*)&Buffer[i]) - 1;
+ i += VT_int_ParseEscape(Term, (c
onst c
har*)&Buffer[i]) - 1;
continue;
}
continue;
}
diff --git
a/Kernel/drvutil.c
b/Kernel/drvutil.c
index
00ab5ce
..
d19a050
100644
(file)
--- a/
Kernel/drvutil.c
+++ b/
Kernel/drvutil.c
@@
-53,17
+53,17
@@
tVideo_IOCtl_Bitmap gDrvUtil_TextModeCursor = {
// === CODE ===
// --- Video Driver Helpers ---
// === 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)
{
tDrvUtil_Video_2DHandlers *Handlers, int SizeofHandlers)
{
-
void
*stream = Buffer;
+
const Uint8
*stream = Buffer;
int rem = Length;
int op;
while( rem )
{
rem --;
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",
if(op > NUM_VIDEO_2DOPS) {
Log_Warning("DrvUtil",
@@
-84,7
+84,7
@@
int DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,
case VIDEO_2DOP_NOP: break;
case VIDEO_2DOP_FILL:
case VIDEO_2DOP_NOP: break;
case VIDEO_2DOP_FILL:
- if(rem < 1
2
) return Length-rem;
+ if(rem < 1
0
) return Length-rem;
if(!Handlers->Fill) {
Log_Warning("DrvUtil", "DrvUtil_Video_2DStream: Driver"
if(!Handlers->Fill) {
Log_Warning("DrvUtil", "DrvUtil_Video_2DStream: Driver"
@@
-94,13
+94,13
@@
int DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,
Handlers->Fill(
Ent,
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 -= 1
2
;
- stream
= (void*)((tVAddr)stream + 12)
;
+ rem -= 1
0
;
+ stream
+= 10
;
break;
case VIDEO_2DOP_BLIT:
break;
case VIDEO_2DOP_BLIT:
@@
-114,13
+114,13
@@
int DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,
Handlers->Blit(
Ent,
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;
);
rem -= 12;
- stream
= (void*)((tVAddr)stream + 12)
;
+ stream
+= 12
;
break;
}
break;
}
@@
-128,10
+128,10
@@
int DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,
return 0;
}
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;
{
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;
int csr_x, csr_y;
int x, y;
int bytes_per_px = (FBInfo->Depth + 7) / 8;
@@
-147,7
+147,7
@@
int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t
{
case VIDEO_BUFFMT_TEXT:
{
{
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;
int widthInChars = FBInfo->Width/giVT_CharWidth;
int heightInChars = FBInfo->Height/giVT_CharHeight;
int i;
@@
-556,7
+556,7
@@
void DrvUtil_Video_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uin
// --- Disk Driver Helpers ---
Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,
// --- 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;
{
Uint8 tmp[BlockSize]; // C99
Uint64 block = Start / BlockSize;
@@
-625,8
+625,8
@@
Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,
return Length;
}
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
Uint64 BlockSize, Uint Argument)
{
Uint8 tmp[BlockSize]; // C99
diff --git
a/Kernel/include/api_drv_disk.h
b/Kernel/include/api_drv_disk.h
index
68e5330
..
94ea2c9
100644
(file)
--- a/
Kernel/include/api_drv_disk.h
+++ b/
Kernel/include/api_drv_disk.h
@@
-148,7
+148,8
@@
enum eTplDisk_CacheFlags
* \param Buffer Destination for read blocks
\r
* \param Argument Argument provided in ::DrvUtil_ReadBlock and ::DrvUtil_WriteBlock
\r
*/
\r
* \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
\r
/**
\r
* \brief Reads a range from a block device using aligned reads
\r
@@
-161,7
+162,7
@@
typedef Uint (*tDrvUtil_Callback)(Uint64 Address, Uint Count, void *Buffer, Uint
* \return Number of bytes read
\r
*/
\r
extern Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,
\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
/**
\r
* \brief Writes a range to a block device using aligned writes
\r
* \param Start Base byte offset
\r
@@
-173,8
+174,8
@@
extern Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,
* \param Argument An argument to pass to \a ReadBlocks and \a WriteBlocks
\r
* \return Number of bytes written
\r
*/
\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
Uint64 BlockSize, Uint Argument);
\r
\r
/**
\r
diff --git
a/Kernel/include/api_drv_video.h
b/Kernel/include/api_drv_video.h
index
f2d1a2d
..
ff9c395
100644
(file)
--- a/
Kernel/include/api_drv_video.h
+++ b/
Kernel/include/api_drv_video.h
@@
-435,7
+435,7
@@
typedef struct sDrvUtil_Video_2DHandlers
* \param SizeofHandlers Size of \a tDrvUtil_Video_2DHandlers according
\r
* to the driver. Used as version control and error avoidence.
\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
tDrvUtil_Video_2DHandlers *Handlers, int SizeofHandlers);
\r
\r
/**
\r
@@
-449,7
+449,7
@@
extern int DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,
* 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
* 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
\r
/**
\r
* \name Software cursor rendering
\r
diff --git
a/Kernel/include/vfs.h
b/Kernel/include/vfs.h
index
91771c8
..
1aa073b
100644
(file)
--- a/
Kernel/include/vfs.h
+++ b/
Kernel/include/vfs.h
@@
-26,6
+26,8
@@
*/
typedef struct sVFS_SelectList tVFS_SelectList;
*/
typedef struct sVFS_SelectList tVFS_SelectList;
+typedef struct sVFS_NodeType tVFS_NodeType;
+
/**
* \name tVFS_Node Flags
* \brief Flag values for tVFS_Node.Flags
/**
* \name tVFS_Node Flags
* \brief Flag values for tVFS_Node.Flags
@@
-177,6
+179,22
@@
typedef struct sVFS_Node
* \}
*/
* \}
*/
+ /**
+ * \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
/**
* \name Common Functions
* \brief Functions that are used no matter the value of .Flags
@@
-233,7
+251,7
@@
typedef struct sVFS_Node
* \param Buffer Source of written data
* \return Number of bytes read
*/
* \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
/**
* \brief Map a region of a file into memory
@@
-299,14
+317,14
@@
typedef struct sVFS_Node
* \param Node Pointer to this node (directory)
* \param Child Node to create a new link to
* \param NewName Name for the new link
* \param Node Pointer to this node (directory)
* \param Child Node to create a new link to
* \param NewName Name for the new link
- * \retur
n
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);
/**
* \}
*/
*/
int (*Link)(struct sVFS_Node *Node, struct sVFS_Node *Child, const char *NewName);
/**
* \}
*/
-}
tVFS_Node
;
+};
/**
* \brief VFS Driver (Filesystem) Definition
/**
* \brief VFS Driver (Filesystem) Definition
diff --git
a/Kernel/include/vfs_int.h
b/Kernel/include/vfs_int.h
index
4961f08
..
75de88b
100644
(file)
--- a/
Kernel/include/vfs_int.h
+++ b/
Kernel/include/vfs_int.h
@@
-54,4
+54,13
@@
extern int VFS_CheckACL(tVFS_Node *Node, Uint Permissions);
// --- mount.c ---
extern tVFS_Mount *VFS_GetMountByIdent(Uint32 MountID);
// --- 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
#endif
diff --git
a/Kernel/vfs/dir.c
b/Kernel/vfs/dir.c
index
3d4018f
..
aee7a60
100644
(file)
--- a/
Kernel/vfs/dir.c
+++ b/
Kernel/vfs/dir.c
@@
-73,7
+73,7
@@
int VFS_MkNod(const char *Path, Uint Flags)
// Permissions Check
if( !VFS_CheckACL(parent, VFS_PERM_EXECUTE|VFS_PERM_WRITE) ) {
// 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;
free(absPath);
LEAVE('i', -1);
return -1;
@@
-81,20
+81,20
@@
int VFS_MkNod(const char *Path, Uint Flags)
LOG("parent = %p", parent);
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
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
// Free allocated string
free(absPath);
// Free Parent
-
if(parent->Close) parent->Close( parent
);
+
_CloseNode(parent
);
// Error Check
if(ret == 0) {
// Error Check
if(ret == 0) {
@@
-116,48
+116,23
@@
int VFS_Symlink(const char *Name, const char *Link)
{
char *realLink;
int fp;
{
char *realLink;
int fp;
- char *_link;
ENTER("sName sLink", Name, Link);
// Get absolue path name
ENTER("sName sLink", Name, Link);
// Get absolue path name
-
_l
ink = VFS_GetAbsPath( Link );
- if(!
_l
ink) {
+
realL
ink = VFS_GetAbsPath( Link );
+ if(!
realL
ink) {
Log_Warning("VFS", "Path '%s' is badly formed", Link);
LEAVE('i', -1);
return -1;
}
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);
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
}
LEAVE('i', -2);
return -2; // Make link node
}
@@
-184,7
+159,7
@@
int VFS_ReadDir(int FD, char *Dest)
//ENTER("ph pDest", h, Dest);
//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;
}
//LEAVE('i', 0);
return 0;
}
@@
-195,7
+170,7
@@
int VFS_ReadDir(int FD, char *Dest)
}
do {
}
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
if((Uint)tmp < (Uint)VFS_MAXSKIP)
h->Position += (Uint)tmp;
else
diff --git
a/Kernel/vfs/fs/devfs.c
b/Kernel/vfs/fs/devfs.c
index
162f111
..
b3f4a57
100644
(file)
--- a/
Kernel/vfs/fs/devfs.c
+++ b/
Kernel/vfs/fs/devfs.c
@@
-20,13
+20,17
@@
tVFS_Node *DevFS_FindDir(tVFS_Node *Node, const char *Name);
tVFS_Driver gDevFS_Info = {
"devfs", 0, DevFS_InitDevice, NULL, NULL
};
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,
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;
};
tDevFS_Driver *gDevFS_Drivers = NULL;
int giDevFS_NextID = 1;
diff --git
a/Kernel/vfs/fs/root.c
b/Kernel/vfs/fs/root.c
index
a12d154
..
9fa1732
100644
(file)
--- a/
Kernel/vfs/fs/root.c
+++ b/
Kernel/vfs/fs/root.c
@@
-17,7
+17,7
@@
tVFS_Node *Root_InitDevice(const char *Device, const char **Options);
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);
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 ===
tRamFS_File *Root_int_AllocFile(void);
// === GLOBALS ===
@@
-35,6
+35,17
@@
tVFS_ACL RootFS_FileACLs[3] = {
{{1,0}, {0,VFS_PERM_ALL^VFS_PERM_EXECUTE}}, // Group (Root)
{{0,-1}, {0,VFS_PERM_READ}} // World (Nobody)
};
{{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 ===
/**
// === CODE ===
/**
@@
-57,12
+68,8
@@
tVFS_Node *Root_InitDevice(const char *Device, const char **Options)
= root->Node.ATime = now();
root->Node.NumACLs = 3;
root->Node.ACLs = RootFS_DirACLs;
= 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;
}
return &root->Node;
}
@@
-109,16
+116,13
@@
int Root_MkNod(tVFS_Node *Node, const char *Name, Uint Flags)
if(Flags & VFS_FFLAG_DIRECTORY)
{
child->Node.ACLs = RootFS_DirACLs;
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;
} 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;
}
prev->Next = child;
@@
-194,7
+198,7
@@
Uint64 Root_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \fn Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Write to a file in the root directory
*/
* \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;
{
tRamFS_File *file = Node->ImplPtr;
diff --git
a/Kernel/vfs/io.c
b/Kernel/vfs/io.c
index
358d703
..
e7a2a06
100644
(file)
--- a/
Kernel/vfs/io.c
+++ b/
Kernel/vfs/io.c
@@
-25,9
+25,9
@@
Uint64 VFS_Read(int FD, Uint64 Length, void *Buffer)
if( !(h->Mode & VFS_OPENFLAG_READ) || h->Node->Flags & VFS_FFLAG_DIRECTORY )
LEAVE_RET('i', -1);
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(ret == -1) LEAVE_RET('i', -1);
h->Position += ret;
@@
-50,11
+50,11
@@
Uint64 VFS_ReadAt(int FD, Uint64 Offset, Uint64 Length, void *Buffer)
if( !(h->Mode & VFS_OPENFLAG_READ) ) return -1;
if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) return -1;
if( !(h->Mode & VFS_OPENFLAG_READ) ) return -1;
if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) return -1;
- if(
!h->Nod
e->Read) {
+ if(
!h->Node->Type || !h->Node->Typ
e->Read) {
Warning("VFS_ReadAt - Node %p, does not have a read method", h->Node);
return 0;
}
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(ret == -1) return -1;
return ret;
}
@@
-74,11
+74,11
@@
Uint64 VFS_Write(int FD, Uint64 Length, const void *Buffer)
if( !(h->Mode & VFS_OPENFLAG_WRITE) ) return -1;
if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) return -1;
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;
if(ret == -1) return -1;
+
h->Position += ret;
return ret;
}
h->Position += ret;
return ret;
}
@@
-98,9
+98,9
@@
Uint64 VFS_WriteAt(int FD, Uint64 Offset, Uint64 Length, const void *Buffer)
if( !(h->Mode & VFS_OPENFLAG_WRITE) ) return -1;
if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) return -1;
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;
}
if(ret == -1) return -1;
return ret;
}
@@
-166,8
+166,8
@@
int VFS_IOCtl(int FD, int ID, void *Buffer)
h = VFS_GetHandle(FD);
if(!h) return -1;
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);
}
/**
}
/**
diff --git
a/Kernel/vfs/main.c
b/Kernel/vfs/main.c
index
cb798c1
..
c6525f4
100644
(file)
--- a/
Kernel/vfs/main.c
+++ b/
Kernel/vfs/main.c
@@
-81,7
+81,7
@@
char *VFS_GetTruePath(const char *Path)
//Log(" VFS_GetTruePath: node=%p, ret='%s'", node, ret);
if(!node) return NULL;
//Log(" VFS_GetTruePath: node=%p, ret='%s'", node, ret);
if(!node) return NULL;
- if(node->
Close) nod
e->Close(node);
+ if(node->
Type->Close) node->Typ
e->Close(node);
return ret;
}
return ret;
}
diff --git
a/Kernel/vfs/memfile.c
b/Kernel/vfs/memfile.c
index
c197626
..
14b3948
100644
(file)
--- a/
Kernel/vfs/memfile.c
+++ b/
Kernel/vfs/memfile.c
@@
-7,24
+7,23
@@
#include <vfs.h>
// === PROTOTYPES ===
#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);
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 ===
// === GLOBALS ===
-tVFS_Node
gVFS_MemRoot
= {
- .
Flags = VFS_FFLAG_DIRECTORY
,
- .
NumACLs = 0
,
- .
FindDir = VFS_MemFile_Crea
te
+tVFS_Node
Type gVFS_MemFileType
= {
+ .
Close = VFS_MemFile_Close
,
+ .
Read = VFS_MemFile_Read
,
+ .
Write = VFS_MemFile_Wri
te
};
// === CODE ===
/**
};
// === 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;
{
Uint base, size;
const char *str = Path;
@@
-73,9
+72,7
@@
tVFS_Node *VFS_MemFile_Create(tVFS_Node *Unused, const char *Path)
ret->ACLs = &gVFS_ACL_EveryoneRWX;
// Functions
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;
}
return ret;
}
@@
-119,7
+116,7
@@
Uint64 VFS_MemFile_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buf
* \fn Uint64 VFS_MemFile_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Write to a memory file
*/
* \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;
{
// Check for use of free'd file
if(Node->ImplPtr == NULL) return 0;
diff --git
a/Kernel/vfs/mmap.c
b/Kernel/vfs/mmap.c
index
f4132d5
..
9fe9282
100644
(file)
--- a/
Kernel/vfs/mmap.c
+++ b/
Kernel/vfs/mmap.c
@@
-114,8
+114,13
@@
void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD,
{
if( pb->PhysAddrs[pagenum - pb->BaseOffset] == 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;
else
{
int read_len;
@@
-127,7
+132,7
@@
void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD,
return NULL;
}
// TODO: Clip read length
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 );
// }
// if( read_len != PAGE_SIZE ) {
// memset( (void*)(mapping_dest+read_len), 0, PAGE_SIZE-read_len );
// }
diff --git
a/Kernel/vfs/nodecache.c
b/Kernel/vfs/nodecache.c
index
ad85ac3
..
d2796c1
100644
(file)
--- a/
Kernel/vfs/nodecache.c
+++ b/
Kernel/vfs/nodecache.c
@@
-178,8
+178,8
@@
void Inode_ClearCache(int Handle)
ent->Node.ReferenceCount = 1;
next = ent->Next;
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;
free(ent);
ent = next;
diff --git
a/Kernel/vfs/open.c
b/Kernel/vfs/open.c
index
a886c45
..
448f09b
100644
(file)
--- a/
Kernel/vfs/open.c
+++ b/
Kernel/vfs/open.c
@@
-15,9
+15,9
@@
#define MAX_PATH_LEN 255
// === IMPORTS ===
#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_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 );
// === PROTOTYPES ===
int VFS_int_CreateHandle( tVFS_Node *Node, tVFS_Mount *Mount, int Mode );
@@
-176,13
+176,13
@@
tVFS_Node *VFS_ParsePath(const char *Path, char **TruePath, tVFS_Mount **MountPo
ENTER("sPath pTruePath", Path, TruePath);
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);
}
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;
}
if(MountPoint) {
*MountPoint = NULL;
}
@@
-268,48
+268,27
@@
restart_parse:
// Check permissions on root of filesystem
if( !VFS_CheckACL(curNode, VFS_PERM_EXECUTE) ) {
// 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);
//Log("Permissions fail on '%s'", Path);
- LEAVE('n');
- return NULL;
+ goto _error;
}
// Check if the node has a FindDir method
}
// 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);
//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
// Get Child Node
- tmpNode = curNode->FindDir(curNode, pathEle);
+ tmpNode = curNode->
Type->
FindDir(curNode, pathEle);
LOG("tmpNode = %p", tmpNode);
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);
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
}
// Handle Symbolic Links
@@
-318,19
+297,15
@@
restart_parse:
free(*TruePath);
*TruePath = NULL;
}
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);
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(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
}
// Parse Symlink Path
@@
-339,12
+314,10
@@
restart_parse:
{
int remlen = strlen(Path) - (ofs + nextSlash);
if( curNode->Size + remlen > MAX_PATH_LEN ) {
{
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");
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);
path_buffer[ curNode->Size ] = '\0';
LOG("path_buffer = '%s'", path_buffer);
strcat(path_buffer, Path + ofs+nextSlash);
@@
-363,9
+336,7
@@
restart_parse:
if( !(curNode->Flags & VFS_FFLAG_DIRECTORY) )
{
Log_Warning("VFS", "VFS_ParsePath - Path segment is not a directory");
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 path needs extending
@@
-376,11
+347,7
@@
restart_parse:
// Check if allocation succeeded
if(!tmp) {
Log_Warning("VFS", "VFS_ParsePath - Unable to reallocate true path buffer");
// 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
}
*TruePath = tmp;
// Append to path
@@
-392,32
+359,23
@@
restart_parse:
// - Extend Path
retLength += nextSlash + 1;
}
// - 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);
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]);
}
// 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);
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);
// 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)
{
if(TruePath)
{
@@
-426,10
+384,7
@@
restart_parse:
// Check if allocation succeeded
if(!tmp) {
Log_Warning("VFS", "VFS_ParsePath - Unable to reallocate true path buffer");
// 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
}
*TruePath = tmp;
// Append to path
@@
-445,6
+400,16
@@
restart_parse:
LEAVE('p', tmpNode);
return tmpNode;
LEAVE('p', tmpNode);
return tmpNode;
+
+_error:
+ _CloseNode( curNode );
+
+ if(TruePath && *TruePath) {
+ free(*TruePath);
+ *TruePath = NULL;
+ }
+ LEAVE('n');
+ return NULL;
}
/**
}
/**
@@
-465,7
+430,7
@@
int VFS_int_CreateHandle( tVFS_Node *Node, tVFS_Mount *Mount, int Mode )
// Permissions Check
if( !VFS_CheckACL(Node, i) ) {
// Permissions Check
if( !VFS_CheckACL(Node, i) ) {
-
if(Node->Close) Node->Clos
e( Node );
+
_CloseNod
e( Node );
Log_Log("VFS", "VFS_int_CreateHandle: Permissions Failed");
errno = EACCES;
LEAVE_RET('i', -1);
Log_Log("VFS", "VFS_int_CreateHandle: Permissions Failed");
errno = EACCES;
LEAVE_RET('i', -1);
@@
-521,14
+486,14
@@
int VFS_Open(const char *Path, Uint Mode)
Log_Warning("VFS", "VFS_Open - Symlink is too long (%i)", node->Size);
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
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';
tmppath[ node->Size ] = '\0';
-
if(node->Close) node->Clos
e( node );
+
_CloseNod
e( node );
// Open the target
node = VFS_ParsePath(tmppath, NULL, &mnt);
if(!node) {
// Open the target
node = VFS_ParsePath(tmppath, NULL, &mnt);
if(!node) {
@@
-562,13
+527,20
@@
int VFS_OpenChild(int FD, const char *Name, Uint Mode)
// Check for directory
if( !(h->Node->Flags & VFS_FFLAG_DIRECTORY) ) {
// 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
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);
if(!node) {
errno = ENOENT;
LEAVE_RET('i', -1);
@@
-633,8
+605,7
@@
void VFS_Close(int FD)
}
#endif
}
#endif
- if(h->Node->Close)
- h->Node->Close( h->Node );
+ _CloseNode(h->Node);
h->Node = NULL;
}
h->Node = NULL;
}
diff --git
a/Modules/Display/BochsGA/bochsvbe.c
b/Modules/Display/BochsGA/bochsvbe.c
index
58a024f
..
806c1c1
100644
(file)
--- a/
Modules/Display/BochsGA/bochsvbe.c
+++ b/
Modules/Display/BochsGA/bochsvbe.c
@@
-64,19
+64,20
@@
void BGA_int_SetMode(Uint16 width, Uint16 height);
int BGA_int_MapFB(void *Dest);
\r
// Filesystem
\r
Uint64 BGA_Read(tVFS_Node *Node, Uint64 off, Uint64 len, void *buffer);
\r
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
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
.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
int giBGA_CurrentMode = -1;
\r
tVideo_IOCtl_Pos gBGA_CursorPos = {-1,-1};
\r
Uint *gBGA_Framebuffer;
\r
@@
-160,7
+161,7
@@
Uint64 BGA_Read(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer)
/**
\r
* \brief Write to the framebuffer
\r
*/
\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
{
\r
if( giBGA_CurrentMode == -1 ) BGA_int_UpdateMode(0);
\r
return DrvUtil_Video_WriteLFB(&gBGA_DrvUtil_BufInfo, Offset, Length, Buffer);
\r
diff --git
a/Modules/Display/VESA/main.c
b/Modules/Display/VESA/main.c
index
55083b0
..
a85d313
100644
(file)
--- a/
Modules/Display/VESA/main.c
+++ b/
Modules/Display/VESA/main.c
@@
-24,7
+24,7
@@
// === PROTOTYPES ===
\r
int Vesa_Install(char **Arguments);
\r
Uint64 Vesa_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *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
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
@@
-35,14
+35,15
@@
void Vesa_FlipCursor(void *Arg);
\r
// === GLOBALS ===
\r
MODULE_DEFINE(0, VERSION, Vesa, Vesa_Install, NULL, "PCI", "VM8086", NULL);
\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
.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
tMutex glVesa_Lock;
\r
tVM8086 *gpVesa_BiosState;
\r
int giVesaDriverId = -1;
\r
@@
-178,7
+179,7
@@
Uint64 Vesa_Read(tVFS_Node *Node, Uint64 off, Uint64 len, void *buffer)
/**
\r
* \brief Write to the framebuffer
\r
*/
\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
{
\r
if( gVesa_Modes[giVesaCurrentMode].framebuffer == 0 ) {
\r
Log_Warning("VESA", "Vesa_Write - Non-LFB Modes not yet supported.");
\r
diff --git
a/Modules/Filesystems/Ext2/dir.c
b/Modules/Filesystems/Ext2/dir.c
index
c7d8dd8
..
5eb476f
100644
(file)
--- a/
Modules/Filesystems/Ext2/dir.c
+++ b/
Modules/Filesystems/Ext2/dir.c
@@
-23,6
+23,23
@@
tVFS_Node *Ext2_FindDir(tVFS_Node *Node, const char *FileName);
// --- Helpers ---
tVFS_Node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeId);
// --- 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
// === CODE ===
/**
* \brief Reads a directory entry
@@
-345,9
+362,7
@@
tVFS_Node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeID)
retNode.ACLs = VFS_UnixToAcessACL(inode.i_mode & 0777, inode.i_uid, inode.i_gid);
// Set Function Pointers
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)
{
switch(inode.i_mode & EXT2_S_IFMT)
{
@@
-362,11
+377,7
@@
tVFS_Node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeID)
break;
// Directory
case EXT2_S_IFDIR:
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;
retNode.Flags = VFS_FFLAG_DIRECTORY;
retNode.Data = calloc( sizeof(Uint16), DivUp(retNode.Size, Disk->BlockSize) );
break;
diff --git
a/Modules/Filesystems/Ext2/ext2.c
b/Modules/Filesystems/Ext2/ext2.c
index
ad96cc8
..
7c4bf97
100644
(file)
--- a/
Modules/Filesystems/Ext2/ext2.c
+++ b/
Modules/Filesystems/Ext2/ext2.c
@@
-12,6
+12,9
@@
#include "ext2_common.h"
\r
#include <modules.h>
\r
\r
#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
// === PROTOTYPES ===
\r
int Ext2_Install(char **Arguments);
\r
// Interface Functions
\r
@@
-130,10
+133,8
@@
tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options)
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
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
\r
// Complete root node
\r
disk->RootNode.UID = inode.i_uid;
\r
diff --git
a/Modules/Filesystems/Ext2/ext2_common.h
b/Modules/Filesystems/Ext2/ext2_common.h
index
be4ae39
..
6ef9d7c
100644
(file)
--- a/
Modules/Filesystems/Ext2/ext2_common.h
+++ b/
Modules/Filesystems/Ext2/ext2_common.h
@@
-42,6
+42,6
@@
extern int Ext2_Link(tVFS_Node *Parent, tVFS_Node *Node, const char *Name);
// --- Read ---
extern Uint64 Ext2_Read(tVFS_Node *node, Uint64 offset, Uint64 length, void *buffer);
// --- Write ---
// --- 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
#endif
diff --git
a/Modules/Filesystems/Ext2/write.c
b/Modules/Filesystems/Ext2/write.c
index
5a7cfc0
..
03109e8
100644
(file)
--- a/
Modules/Filesystems/Ext2/write.c
+++ b/
Modules/Filesystems/Ext2/write.c
@@
-12,7
+12,6
@@
#include "ext2_common.h"
// === PROTOYPES ===
#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);
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);
@@
-22,7
+21,7
@@
void Ext2_int_DeallocateBlock(tExt2_Disk *Disk, Uint32 Block);
* \fn Uint64 Ext2_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Write to a file
*/
* \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;
{
tExt2_Disk *disk = Node->ImplPtr;
tExt2_Inode inode;
diff --git
a/Modules/Filesystems/FAT/fat.c
b/Modules/Filesystems/FAT/fat.c
index
af73322
..
f5d1916
100644
(file)
--- a/
Modules/Filesystems/FAT/fat.c
+++ b/
Modules/Filesystems/FAT/fat.c
@@
-90,6
+90,24
@@
MODULE_DEFINE(0, (0<<8)|50 /*v0.50*/, VFAT, FAT_Install, NULL, NULL);
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
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
\r
// === CODE ===
\r
/**
\r
@@
-273,18
+291,8
@@
tVFS_Node *FAT_InitDevice(const char *Device, const char **Options)
node->ACLs = &gVFS_ACL_EveryoneRWX;
\r
node->Flags = VFS_FFLAG_DIRECTORY;
\r
node->CTime = node->MTime = node->ATime = now();
\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
\r
giFAT_PartCount ++;
\r
return node;
\r
@@
-977,21
+985,12
@@
tVFS_Node *FAT_int_CreateNode(tVFS_Node *Parent, fat_filetable *Entry, int Pos)
// Set pointers
\r
if(node.Flags & VFS_FFLAG_DIRECTORY) {
\r
//Log_Debug("FAT", "Directory %08x has size 0x%x", node.Inode, node.Size);
\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.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
}
\r
- node.Close = FAT_CloseFile;
\r
\r
ret = Inode_CacheNode(disk->inodeHandle, &node);
\r
LEAVE('p', ret);
\r
\r
ret = Inode_CacheNode(disk->inodeHandle, &node);
\r
LEAVE('p', ret);
\r
diff --git
a/Modules/Filesystems/NTFS/main.c
b/Modules/Filesystems/NTFS/main.c
index
f5f99c7
..
dbda06e
100644
(file)
--- a/
Modules/Filesystems/NTFS/main.c
+++ b/
Modules/Filesystems/NTFS/main.c
@@
-24,6
+24,12
@@
void NTFS_DumpEntry(tNTFS_Disk *Disk, Uint32 Entry);
// === GLOBALS ===
MODULE_DEFINE(0, 0x0A /*v0.1*/, FS_NTFS, NTFS_Install, NULL);
tVFS_Driver gNTFS_FSInfo = {"ntfs", 0, NTFS_InitDevice, NTFS_Unmount, NULL};
// === 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;
tNTFS_Disk gNTFS_Disks;
@@
-99,12
+105,8
@@
tVFS_Node *NTFS_InitDevice(const char *Device, const char **Options)
disk->RootNode.NumACLs = 1;
disk->RootNode.ACLs = &gVFS_ACL_EveryoneRX;
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);
NTFS_DumpEntry(disk, 5);
diff --git
a/Modules/IPStack/interface.c
b/Modules/IPStack/interface.c
index
82d1b8c
..
5bfcda7
100644
(file)
--- a/
Modules/IPStack/interface.c
+++ b/
Modules/IPStack/interface.c
@@
-32,6
+32,11
@@
tVFS_Node *IPStack_Iface_FindDir(tVFS_Node *Node, const char *Name);
int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data);
// === GLOBALS ===
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 = {
//! Loopback (127.0.0.0/8, ::1) Pseudo-Interface
tInterface gIP_LoopInterface = {
.Node = {
@@
-40,9
+45,7
@@
tInterface gIP_LoopInterface = {
.Size = -1,
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
.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
},
.Adapter = NULL,
.Type = 0
@@
-234,13
+237,7
@@
tInterface *IPStack_AddInterface(const char *Device, const char *Name)
iface->Node.Size = -1;
iface->Node.NumACLs = 1;
iface->Node.ACLs = &gVFS_ACL_EveryoneRX;
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;
// Set Defaults
iface->TimeoutDelay = DEFAULT_TIMEOUT;
diff --git
a/Modules/IPStack/main.c
b/Modules/IPStack/main.c
index
5f650b3
..
9b9930e
100644
(file)
--- a/
Modules/IPStack/main.c
+++ b/
Modules/IPStack/main.c
@@
-30,6
+30,11
@@
extern tRoute *IPStack_AddRoute(const char *Interface, void *Network, int Subnet
// === GLOBALS ===
MODULE_DEFINE(0, VERSION, IPStack, IPStack_Install, NULL, NULL);
// === 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",
{
tDevFS_Driver gIP_DriverInfo = {
NULL, "ip",
{
@@
-37,9
+42,7
@@
tDevFS_Driver gIP_DriverInfo = {
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
.Flags = VFS_FFLAG_DIRECTORY,
.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
}
};
}
};
diff --git
a/Modules/IPStack/routing.c
b/Modules/IPStack/routing.c
index
1cde444
..
0145f21
100644
(file)
--- a/
Modules/IPStack/routing.c
+++ b/
Modules/IPStack/routing.c
@@
-31,14
+31,20
@@
tRoute *IPStack_FindRoute(int AddressType, tInterface *Interface, void *Address)
int giIP_NextRouteId = 1;
tRoute *gIP_Routes;
tRoute *gIP_RoutesEnd;
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,
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 ===
};
// === CODE ===
@@
-192,7
+198,7
@@
tRoute *IPStack_Route_Create(const char *InterfaceName)
return NULL;
}
iface = node->ImplPtr;
return NULL;
}
iface = node->ImplPtr;
- if(node->
Close) nod
e->Close(node);
+ if(node->
Type->Close) node->Typ
e->Close(node);
}
// Get the size of the specified address type
}
// Get the size of the specified address type
@@
-210,7
+216,7
@@
tRoute *IPStack_Route_Create(const char *InterfaceName)
rt->Node.Size = 0;
rt->Node.NumACLs = 1,
rt->Node.ACLs = &gVFS_ACL_EveryoneRO;
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;
// Set up state
rt->AddressType = iface->Type;
diff --git
a/Modules/IPStack/tcp.c
b/Modules/IPStack/tcp.c
index
e2cc4a8
..
7ba2556
100644
(file)
--- a/
Modules/IPStack/tcp.c
+++ b/
Modules/IPStack/tcp.c
@@
-40,7
+40,7
@@
void TCP_Server_Close(tVFS_Node *Node);
// --- Client
tVFS_Node *TCP_Client_Init(tInterface *Interface);
Uint64 TCP_Client_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
// --- 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
int TCP_Client_IOCtl(tVFS_Node *Node, int ID, void *Data);
void TCP_Client_Close(tVFS_Node *Node);
// --- Helpers
@@
-49,6
+49,20
@@
void TCP_Client_Close(tVFS_Node *Node);
// === TEMPLATES ===
tSocketFile gTCP_ServerFile = {NULL, "tcps", TCP_Server_Init};
tSocketFile gTCP_ClientFile = {NULL, "tcpc", TCP_Client_Init};
// === 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;
// === GLOBALS ===
int giTCP_NumHalfopen = 0;
@@
-226,9
+240,7
@@
void TCP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buffe
conn->Node.ACLs = &gVFS_ACL_EveryoneRW;
conn->Node.ImplPtr = conn;
conn->Node.ImplInt = srv->NextID ++;
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
// Hmm... Theoretically, this lock will never have to wait,
// as the interface is locked to the watching thread, and this
@@
-835,10
+847,7
@@
tVFS_Node *TCP_Server_Init(tInterface *Interface)
srv->Node.ImplPtr = srv;
srv->Node.NumACLs = 1;
srv->Node.ACLs = &gVFS_ACL_EveryoneRW;
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;
SHORTLOCK(&glTCP_Listeners);
srv->Next = gTCP_Listeners;
@@
-1003,10
+1012,7
@@
tVFS_Node *TCP_Client_Init(tInterface *Interface)
conn->Node.ImplPtr = conn;
conn->Node.NumACLs = 1;
conn->Node.ACLs = &gVFS_ACL_EveryoneRW;
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
conn->RecievedBuffer = RingBuffer_Create( TCP_RECIEVE_BUFFER_SIZE );
#if 0
@@
-1086,7
+1092,7
@@
Uint64 TCP_Client_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buff
/**
* \brief Send a data packet on a connection
*/
/**
* \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;
{
char buf[sizeof(tTCPHeader)+Length];
tTCPHeader *packet = (void*)buf;
@@
-1115,7
+1121,7
@@
void TCP_INT_SendDataPacket(tTCPConnection *Connection, size_t Length, void *Dat
/**
* \brief Send some bytes on a connection
*/
/**
* \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;
{
tTCPConnection *conn = Node->ImplPtr;
size_t rem = Length;
diff --git
a/Modules/IPStack/udp.c
b/Modules/IPStack/udp.c
index
c75aab0
..
7228f17
100644
(file)
--- a/
Modules/IPStack/udp.c
+++ b/
Modules/IPStack/udp.c
@@
-16,7
+16,7
@@
void UDP_SendPacketTo(tUDPChannel *Channel, int AddrType, void *Address, Uint16
// --- Client Channels
tVFS_Node *UDP_Channel_Init(tInterface *Interface);
Uint64 UDP_Channel_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
// --- 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
int UDP_Channel_IOCtl(tVFS_Node *Node, int ID, void *Data);
void UDP_Channel_Close(tVFS_Node *Node);
// --- Helpers
@@
-25,6
+25,12
@@
Uint16 UDP_int_AllocatePort();
void UDP_int_FreePort(Uint16 Port);
// === GLOBALS ===
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;
tMutex glUDP_Channels;
tUDPChannel *gpUDP_Channels;
@@
-169,10
+175,7
@@
tVFS_Node *UDP_Channel_Init(tInterface *Interface)
new->Node.ImplPtr = new;
new->Node.NumACLs = 1;
new->Node.ACLs = &gVFS_ACL_EveryoneRW;
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;
Mutex_Acquire(&glUDP_Channels);
new->Next = gpUDP_Channels;
@@
-244,7
+247,7
@@
Uint64 UDP_Channel_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buf
/**
* \brief Write to the channel file (send a packet)
*/
/**
* \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;
{
tUDPChannel *chan = Node->ImplPtr;
tUDPEndpoint *ep;
diff --git
a/Modules/Input/PS2KbMouse/kb.c
b/Modules/Input/PS2KbMouse/kb.c
index
56c98c2
..
a121b61
100644
(file)
--- a/
Modules/Input/PS2KbMouse/kb.c
+++ b/
Modules/Input/PS2KbMouse/kb.c
@@
-25,13
+25,12
@@
void KB_UpdateLEDs(void);
int KB_IOCtl(tVFS_Node *Node, int Id, void *Data);
// === GLOBALS ===
int KB_IOCtl(tVFS_Node *Node, int Id, void *Data);
// === GLOBALS ===
+tVFS_NodeType gKB_NodeType = {
+ .IOCtl = KB_IOCtl
+};
tDevFS_Driver gKB_DevInfo = {
NULL, "PS2Keyboard",
tDevFS_Driver gKB_DevInfo = {
NULL, "PS2Keyboard",
- {
- .NumACLs = 0,
- .Size = 0,
- .IOCtl = KB_IOCtl
- }
+ { .Type = &gKB_NodeType }
};
tKeybardCallback gKB_Callback = NULL;
Uint32 **gpKB_Map = gpKBDUS;
};
tKeybardCallback gKB_Callback = NULL;
Uint32 **gpKB_Map = gpKBDUS;
diff --git
a/Modules/Input/PS2KbMouse/ps2mouse.c
b/Modules/Input/PS2KbMouse/ps2mouse.c
index
e80a141
..
44be3b7
100644
(file)
--- a/
Modules/Input/PS2KbMouse/ps2mouse.c
+++ b/
Modules/Input/PS2KbMouse/ps2mouse.c
@@
-39,11
+39,15
@@
tJoystick_Callback gMouse_Callback;
int giMouse_Cycle = 0; // IRQ Position
\r
Uint8 gaMouse_Bytes[4] = {0,0,0,0};
\r
// - Driver definition
\r
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
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
}
\r
};
\r
\r
diff --git
a/Modules/Network/NE2000/ne2000.c
b/Modules/Network/NE2000/ne2000.c
index
37d9c5a
..
d05b2a3
100644
(file)
--- a/
Modules/Network/NE2000/ne2000.c
+++ b/
Modules/Network/NE2000/ne2000.c
@@
-86,7
+86,7
@@
typedef struct sNe2k_Card {
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);
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);
Uint64 Ne2k_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
int Ne2k_int_ReadDMA(tCard *Card, int FirstPage, int NumPages, void *Buffer);
@@
-95,15
+95,23
@@
void Ne2k_IRQHandler(int IntNum, void *Ptr);
// === GLOBALS ===
MODULE_DEFINE(0, VERSION, Ne2k, Ne2k_Install, NULL, NULL);
// === 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,
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;
}
};
Uint16 gNe2k_BaseAddress;
@@
-202,9
+210,7
@@
int Ne2k_Install(char **Options)
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.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
// Initialise packet semaphore
// - Start at zero, no max
@@
-275,13
+281,13
@@
int Ne2k_IOCtl(tVFS_Node *Node, int ID, void *Data)
}
/**
}
/**
- * \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
*/
* \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;
{
tCard *Card = (tCard*)Node->ImplPtr;
-
Uint16
*buf = Buffer;
+
const Uint16
*buf = Buffer;
int rem = Length;
int page;
int rem = Length;
int page;
diff --git
a/Modules/Network/RTL8139/rtl8139.c
b/Modules/Network/RTL8139/rtl8139.c
index
eb77812
..
1e9ac89
100644
(file)
--- a/
Modules/Network/RTL8139/rtl8139.c
+++ b/
Modules/Network/RTL8139/rtl8139.c
@@
-95,21
+95,29
@@
char *RTL8139_ReadDir(tVFS_Node *Node, int Pos);
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);
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);
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,
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;
}
};
int giRTL8139_CardCount;
@@
-206,9
+214,7
@@
int RTL8139_Install(char **Options)
card->Node.ImplPtr = card;
card->Node.NumACLs = 0;
card->Node.CTime = now();
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,
Log_Log("RTL8139", "Card %i 0x%04x, IRQ %i %02x:%02x:%02x:%02x:%02x:%02x",
i, card->IOBase, card->IRQ,
@@
-307,7
+313,7
@@
retry:
return Length;
}
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;
{
int td;
Uint32 status;
diff --git
a/Modules/Storage/ATA/main.c
b/Modules/Storage/ATA/main.c
index
958855f
..
41228d8
100644
(file)
--- a/
Modules/Storage/ATA/main.c
+++ b/
Modules/Storage/ATA/main.c
@@
-27,14
+27,25
@@
Uint16 ATA_GetBasePort(int Disk);
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);
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);
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);
// === 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",
{
tDevFS_Driver gATA_DriverInfo = {
NULL, "ata",
{
@@
-42,8
+53,7
@@
tDevFS_Driver gATA_DriverInfo = {
.Size = -1,
.Flags = VFS_FFLAG_DIRECTORY,
.ACLs = &gVFS_ACL_EveryoneRX,
.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];
}
};
tATA_Disk gATA_Disks[MAX_ATA_DISKS];
@@
-171,12
+181,9
@@
int ATA_ScanDisk(int Disk)
node->Inode = (Disk << 8) | 0xFF;
node->ImplPtr = gATA_Disks[ Disk ].Name;
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");
// --- Scan Partitions ---
LOG("Reading MBR");
@@
-224,9
+231,7
@@
void ATA_int_MakePartition(tATA_Partition *Part, int Disk, int Num, Uint64 Start
Part->Node.Inode = (Disk << 8) | Num;
Part->Node.ImplPtr = Part->Name;
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('-');
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('-');
@@
-330,9
+335,9
@@
Uint64 ATA_ReadFS(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
}
/**
}
/**
- * \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;
{
int disk = Node->Inode >> 8;
int part = Node->Inode & 0xFF;
@@
-417,9
+422,9
@@
Uint ATA_ReadRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk)
}
/**
}
/**
- * \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;
{
int ret;
Uint offset;
diff --git
a/Modules/Storage/FDDv2/main.c
b/Modules/Storage/FDDv2/main.c
index
0821a58
..
bec157c
100644
(file)
--- a/
Modules/Storage/FDDv2/main.c
+++ b/
Modules/Storage/FDDv2/main.c
@@
-32,6
+32,17
@@
Uint64 FDD_ReadFS(tVFS_Node *node, Uint64 off, Uint64 len, void *buffer);
MODULE_DEFINE(0, FDD_VERSION, Storage_FDDv2, FDD_Install, NULL, "x86_ISADMA", NULL);
tDrive gaFDD_Disks[MAX_DISKS];
tVFS_Node gaFDD_DiskNodes[MAX_DISKS];
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",
{
tDevFS_Driver gFDD_DriverInfo = {
NULL, "fdd",
{
@@
-39,9
+50,7
@@
tDevFS_Driver gFDD_DriverInfo = {
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
.Flags = VFS_FFLAG_DIRECTORY,
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
.Flags = VFS_FFLAG_DIRECTORY,
- .ReadDir = FDD_ReadDir,
- .FindDir = FDD_FindDir,
- .IOCtl = FDD_IOCtl
+ .Type = &gFDD_RootNodeType
}
};
}
};
@@
-88,8
+97,7
@@
int FDD_RegisterFS(void)
gaFDD_DiskNodes[i].Inode = i;
gaFDD_DiskNodes[i].Flags = 0;
gaFDD_DiskNodes[i].NumACLs = 0;
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
}
gaFDD_DiskNodes[i].Size = 1440*1024; // TODO: Non 1.44 disks
}
diff --git
a/Modules/x86/VGAText/vga.c
b/Modules/x86/VGAText/vga.c
index
d958956
..
41f0bd0
100644
(file)
--- a/
Modules/x86/VGAText/vga.c
+++ b/
Modules/x86/VGAText/vga.c
@@
-13,10
+13,10
@@
// === PROTOTYPES ===
int VGA_Install(char **Arguments);
// === 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);
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);
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);
@@
-24,14
+24,17
@@
void VGA_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uint16 SrcY,
// === GLOBALS ===
MODULE_DEFINE(0, 0x000A, x86_VGAText, VGA_Install, NULL, NULL);
// === 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),
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 );
}
};
Uint16 *gVGA_Framebuffer = (void*)( KERNEL_BASE|0xB8000 );
@@
-65,17
+68,16
@@
int VGA_Install(char **Arguments)
}
/**
}
/**
- * \fn Uint64 VGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
* \brief Writes a string of bytes to the VGA controller
*/
* \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;
{
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);
Uint16 word;
//ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
@@
-197,7
+199,7
@@
Uint8 VGA_int_GetColourNibble(Uint16 col)
* \fn Uint16 VGA_int_GetWord(tVT_Char *Char)
* \brief Convers a character structure to a VGA character word
*/
* \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;
{
Uint16 ret;
Uint16 col;
UCC
git Repository :: git.ucc.asn.au