From bbace1ebc0a53c9b8c561de6a3a2d9955fcdab0b Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 30 Jul 2013 11:00:06 +0800 Subject: [PATCH] AcessNative - added MkNod to nativefs --- AcessNative/acesskernel_src/nativefs.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/AcessNative/acesskernel_src/nativefs.c b/AcessNative/acesskernel_src/nativefs.c index 1a076274..e603c26b 100644 --- a/AcessNative/acesskernel_src/nativefs.c +++ b/AcessNative/acesskernel_src/nativefs.c @@ -14,7 +14,7 @@ #undef sprintf #include // Posix #include // Posix -#include // Posix +#include // C //NOTES: // tVFS_Node->ImplPtr is a pointer to the filesystem flags (tNativeFS) @@ -34,6 +34,7 @@ tVFS_Node *NativeFS_Mount(const char *Device, const char **Arguments); void NativeFS_Unmount(tVFS_Node *Node); tVFS_Node *NativeFS_FindDir(tVFS_Node *Node, const char *Name, Uint Flags); int NativeFS_ReadDir(tVFS_Node *Node, int Position, char Dest[FILENAME_MAX]); +tVFS_Node *NativeFS_MkNod(tVFS_Node *Node, const char *Name, Uint Flags); size_t NativeFS_Read(tVFS_Node *Node, _acess_off_t Offset, size_t Length, void *Buffer, Uint Flags); size_t NativeFS_Write(tVFS_Node *Node, _acess_off_t Offset, size_t Length, const void *Buffer, Uint Flags); void NativeFS_Close(tVFS_Node *Node); @@ -47,6 +48,7 @@ tVFS_NodeType gNativeFS_FileNodeType = { tVFS_NodeType gNativeFS_DirNodeType = { .FindDir = NativeFS_FindDir, .ReadDir = NativeFS_ReadDir, + .MkNod = NativeFS_MkNod, .Close = NativeFS_Close }; tVFS_Driver gNativeFS_Driver = { @@ -204,6 +206,23 @@ int NativeFS_ReadDir(tVFS_Node *Node, int Position, char Dest[FILENAME_MAX]) return 0; } +tVFS_Node *NativeFS_MkNod(tVFS_Node *Node, const char *Name, Uint Flags) +{ + char path[Node->ImplInt+1+strlen(Name)+1]; + sprintf(path, "%s/%s", Node->Data, Name); + if( Flags & VFS_FFLAG_DIRECTORY ) + { + mkdir(path, 0755); + } + else + { + FILE *tmp = fopen(path, "w"); + if(!tmp) return NULL; + fclose(tmp); + } + return NativeFS_FindDir(Node, Name, 0); +} + size_t NativeFS_Read(tVFS_Node *Node, _acess_off_t Offset, size_t Length, void *Buffer, Uint Flags) { ENTER("pNode XOffset xLength pBuffer", Node, Offset, Length, Buffer); -- 2.20.1