Merge branch 'master' of git://cadel.mutabah.net/acess2
[tpg/acess2.git] / Tools / DiskTool / vfs_handles.c
1 /*
2  * 
3  */
4 #include <acess.h>
5 #include <vfs.h>
6 #include <vfs_int.h>
7
8 #define MAX_KERNEL_FILES        32
9
10 // === GLOBALS ===
11 tVFS_Handle     gaKernelHandles[MAX_KERNEL_FILES];
12
13 // === CODE ===
14 int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode)
15 {
16         for( int i = 0; i < MAX_KERNEL_FILES; i ++ )
17         {
18                 if(gaKernelHandles[i].Node)     continue;
19                 gaKernelHandles[i].Node = Node;
20                 gaKernelHandles[i].Position = 0;
21                 gaKernelHandles[i].Mode = Mode;
22                 return i;
23         }       
24
25         return -1;
26 }
27
28 tVFS_Handle *VFS_GetHandle(int ID)
29 {
30         if( ID < 0 || ID >= MAX_KERNEL_FILES )
31                 return NULL;
32         return &gaKernelHandles[ID];
33 }
34
35 int VFS_SetHandle(int FD, tVFS_Node *Node, int Mode)
36 {
37         if( FD < 0 ||  FD >= MAX_KERNEL_FILES )
38                 return -1;
39         gaKernelHandles[FD].Node = Node;
40         gaKernelHandles[FD].Mode = Mode;
41         return 0;
42 }

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