X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FFilesystems%2FRAMDisk%2Framdisk.c;h=d196f5faad007ab0b5d8a2df0b4c8110e6f4a9a9;hb=7461f3e62b0783a3293828e4da74668f832f78b8;hp=defa50b4f0acefebec349ff420e622cc2df3bb20;hpb=e8b89fea150a06598b9edd6a36d67fdc970a1219;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/Filesystems/RAMDisk/ramdisk.c b/KernelLand/Modules/Filesystems/RAMDisk/ramdisk.c index defa50b4..d196f5fa 100644 --- a/KernelLand/Modules/Filesystems/RAMDisk/ramdisk.c +++ b/KernelLand/Modules/Filesystems/RAMDisk/ramdisk.c @@ -21,14 +21,14 @@ tVFS_Node *RAMFS_InitDevice(const char *Device, const char **Options); void RAMFS_Unmount(tVFS_Node *Node); // --- Directories --- -char *RAMFS_ReadDir(tVFS_Node *Node, int Index); -tVFS_Node *RAMFS_FindDir(tVFS_Node *Node, const char *Name); - int RAMFS_MkNod(tVFS_Node *Node, const char *Name, Uint Flags); + int RAMFS_ReadDir(tVFS_Node *Node, int Index, char Dest[256]); +tVFS_Node *RAMFS_FindDir(tVFS_Node *Node, const char *Name, Uint Flags); +tVFS_Node *RAMFS_MkNod(tVFS_Node *Node, const char *Name, Uint Flags); int RAMFS_Link(tVFS_Node *DirNode, const char *Name, tVFS_Node *Node); int RAMFS_Unlink(tVFS_Node *Node, const char *Name); // --- Files --- -size_t RAMFS_Read(tVFS_Node *Node, off_t Offset, size_t Size, void *Buffer); -size_t RAMFS_Write(tVFS_Node *Node, off_t Offset, size_t Size, const void *Buffer); +size_t RAMFS_Read(tVFS_Node *Node, off_t Offset, size_t Size, void *Buffer, Uint Flags); +size_t RAMFS_Write(tVFS_Node *Node, off_t Offset, size_t Size, const void *Buffer, Uint Flags); // --- Internals -- void RAMFS_int_RefFile(tRAMFS_Inode *Inode); void RAMFS_int_DerefFile(tRAMFS_Inode *Inode); @@ -136,21 +136,22 @@ void RAMFS_Unmount(tVFS_Node *Node) } // --- Directories --- -char *RAMFS_ReadDir(tVFS_Node *Node, int Index) +int RAMFS_ReadDir(tVFS_Node *Node, int Index, char Dest[FILENAME_MAX]) { tRAMFS_Dir *dir = Node->ImplPtr; for( tRAMFS_DirEnt *d = dir->FirstEnt; d; d = d->Next ) { if( Index -- == 0 ) { LOG("Return %s", d->Name); - return strdup(d->Name); + strncpy(Dest, d->Name, FILENAME_MAX); + return 0; } } - LOG("Return NULL"); - return NULL; + LOG("Return -ENOENT"); + return -ENOENT; } -tVFS_Node *RAMFS_FindDir(tVFS_Node *Node, const char *Name) +tVFS_Node *RAMFS_FindDir(tVFS_Node *Node, const char *Name, Uint Flags) { tRAMFS_Dir *dir = Node->ImplPtr; @@ -166,11 +167,11 @@ tVFS_Node *RAMFS_FindDir(tVFS_Node *Node, const char *Name) return NULL; } -int RAMFS_MkNod(tVFS_Node *Node, const char *Name, Uint Flags) +tVFS_Node *RAMFS_MkNod(tVFS_Node *Node, const char *Name, Uint Flags) { tRAMFS_Dir *dir = Node->ImplPtr; - if( RAMFS_FindDir(Node, Name) != NULL ) - return -1; + if( RAMFS_FindDir(Node, Name, 0) != NULL ) + return NULL; tRAMFS_DirEnt *de = malloc( sizeof(tRAMFS_DirEnt) + strlen(Name) + 1 ); de->Next = NULL; @@ -200,7 +201,7 @@ int RAMFS_MkNod(tVFS_Node *Node, const char *Name, Uint Flags) dir->FirstEnt = de; dir->LastEnt = de; - return 0; + return &de->Inode->Node; } int RAMFS_Link(tVFS_Node *DirNode, const char *Name, tVFS_Node *FileNode) @@ -326,14 +327,14 @@ size_t RAMFS_int_DoIO(tRAMFS_File *File, off_t Offset, size_t Size, void *Buffer return Size; } -size_t RAMFS_Read(tVFS_Node *Node, off_t Offset, size_t Size, void *Buffer) +size_t RAMFS_Read(tVFS_Node *Node, off_t Offset, size_t Size, void *Buffer, Uint Flags) { tRAMFS_File *file = Node->ImplPtr; return RAMFS_int_DoIO(file, Offset, Size, Buffer, 1); } -size_t RAMFS_Write(tVFS_Node *Node, off_t Offset, size_t Size, const void *Buffer) +size_t RAMFS_Write(tVFS_Node *Node, off_t Offset, size_t Size, const void *Buffer, Uint Flags) { tRAMFS_File *file = Node->ImplPtr;