X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=AcessNative%2Facesskernel_src%2Fnativefs.c;h=178162179d44a245bfa7e47d7509360595968b8f;hb=cd5a9930815b6be88db4069ad680fba639853c95;hp=e51f286215ae00c1b1bcb979c11267a411ed724f;hpb=11dbd684e9a3d907d43d71a3145205f1a86992fb;p=tpg%2Facess2.git diff --git a/AcessNative/acesskernel_src/nativefs.c b/AcessNative/acesskernel_src/nativefs.c index e51f2862..17816217 100644 --- a/AcessNative/acesskernel_src/nativefs.c +++ b/AcessNative/acesskernel_src/nativefs.c @@ -7,9 +7,11 @@ */ #define DEBUG 0 #define off_t _acess_off_t +#define sprintf _acess_sprintf #include // Acess #include // Acess #undef off_t +#undef sprintf #include // Posix #include // Posix #include // Posix @@ -31,7 +33,7 @@ typedef struct 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); -char *NativeFS_ReadDir(tVFS_Node *Node, int Position); + int NativeFS_ReadDir(tVFS_Node *Node, int Position, char Dest[FILENAME_MAX]); size_t NativeFS_Read(tVFS_Node *Node, _acess_off_t Offset, size_t Length, void *Buffer); size_t NativeFS_Write(tVFS_Node *Node, _acess_off_t Offset, size_t Length, const void *Buffer); void NativeFS_Close(tVFS_Node *Node); @@ -48,9 +50,9 @@ tVFS_NodeType gNativeFS_DirNodeType = { .Close = NativeFS_Close }; tVFS_Driver gNativeFS_Driver = { - "nativefs", 0, - NativeFS_Mount, NativeFS_Unmount, - NULL, + .Name = "nativefs", + .InitDevice = NativeFS_Mount, + .Unmount = NativeFS_Unmount }; // === CODE === @@ -168,11 +170,10 @@ tVFS_Node *NativeFS_FindDir(tVFS_Node *Node, const char *Name) return Inode_CacheNode(info->InodeHandle, &baseRet); } -char *NativeFS_ReadDir(tVFS_Node *Node, int Position) +int NativeFS_ReadDir(tVFS_Node *Node, int Position, char Dest[FILENAME_MAX]) { struct dirent *ent; DIR *dp = (void*)(tVAddr)Node->Inode; - char *ret; ENTER("pNode iPosition", Node, Position); @@ -184,16 +185,16 @@ char *NativeFS_ReadDir(tVFS_Node *Node, int Position) } while(Position-- && ent); if( !ent ) { - LEAVE('n'); - return NULL; + LEAVE('i', -ENOENT); + return -ENOENT; } - ret = strdup(ent->d_name); + strncpy(Dest, ent->d_name, FILENAME_MAX); // TODO: Unlock node - LEAVE('s', ret); - return ret; + LEAVE('i', 0); + return 0; } size_t NativeFS_Read(tVFS_Node *Node, _acess_off_t Offset, size_t Length, void *Buffer) @@ -204,8 +205,9 @@ size_t NativeFS_Read(tVFS_Node *Node, _acess_off_t Offset, size_t Length, void * LEAVE('i', 0); return 0; } - LEAVE('-'); - return fread( Buffer, 1, Length, (FILE *)(tVAddr)Node->Inode ); + size_t ret = fread( Buffer, 1, Length, (FILE *)(tVAddr)Node->Inode ); + LEAVE('x', ret); + return ret; } size_t NativeFS_Write(tVFS_Node *Node, _acess_off_t Offset, size_t Length, const void *Buffer)