Usermode/libc - Fix strchr and strrchr behavior
[tpg/acess2.git] / KernelLand / Kernel / memfs_helpers.c
1 /*
2  * Acess2 Kernel
3  * - By John Hodge (thePowersGang)
4  *
5  * memfs_helpers.c
6  * - Helpers for in-memory filesystems
7  */
8 #include <memfs_helpers.h>
9
10 // === CODE ===
11 void MemFS_InitDir(tMemFS_DirHdr *Dir)
12 {
13         MemFS_InitFile(&Dir->FileHdr);
14 }
15 void MemFS_InitFile(tMemFS_FileHdr *File)
16 {
17         File->Next = NULL;
18 }
19
20 int MemFS_ReadDir(tMemFS_DirHdr *Dir, int Pos, char Name[FILENAME_MAX])
21 {
22          int    i = 0;
23         // TODO: Lock
24         for( tMemFS_FileHdr *file = Dir->FirstChild; file; file = file->Next, i ++ )
25         {
26                 if( i == Pos )
27                 {
28                         strncpy(Name, file->Name, FILENAME_MAX);
29                         return 0;
30                 }
31         }
32         return -EINVAL;
33 }
34 tMemFS_FileHdr *MemFS_FindDir(tMemFS_DirHdr *Dir, const char *Name)
35 {
36         // TODO: Lock
37         for( tMemFS_FileHdr *file = Dir->FirstChild; file; file = file->Next )
38         {
39                 if( strcmp(file->Name, Name) == 0 )
40                         return file;
41         }
42         return NULL;
43 }
44 tMemFS_FileHdr *MemFS_Remove(tMemFS_DirHdr *Dir, const char *Name)
45 {
46         UNIMPLEMENTED();
47         return NULL;
48 }
49 bool MemFS_Insert(tMemFS_DirHdr *Dir, tMemFS_FileHdr *File)
50 {
51         UNIMPLEMENTED();
52         return false;
53 }
54

UCC git Repository :: git.ucc.asn.au