Kernel - Implimented VFS_Reopen
[tpg/acess2.git] / KernelLand / Kernel / include / vfs_int.h
1 /* 
2  * Acess Micro - VFS Server Ver 1
3  */
4 #ifndef _VFS_INT_H
5 #define _VFS_INT_H
6
7 #include "vfs.h"
8 #include <rwlock.h>
9
10 // === TYPES ===
11 typedef struct sVFS_Mount {
12         struct sVFS_Mount       *Next;
13         char    *MountPoint;
14         size_t  MountPointLen;
15         Uint32  Identifier;
16         char    *Device;
17         char    *Options;
18         tVFS_Driver     *Filesystem;
19         tVFS_Node       *RootNode;
20         
21          int    OpenHandleCount;
22         
23         char    StrData[];
24 } tVFS_Mount;
25
26 typedef struct sVFS_Handle {
27         tVFS_Node       *Node;
28         tVFS_Mount      *Mount;
29         Uint64  Position;
30         Uint    Mode;
31 } tVFS_Handle;
32
33 typedef struct sVFS_Proc {
34         struct sVFS_Proc        *Next;
35          int    ID;
36          int    CwdLen;
37         Uint    UID, GID;
38         char    *Cwd;
39          int    MaxHandles;
40         tVFS_Handle     Handles[];
41 } tVFS_Proc;
42
43 typedef struct sVFS_MMapPage {
44         Uint64  FileOffset;
45         tPAddr  PAddr;
46 } tVFS_MMapPage;
47
48 // === GLOBALS ===
49 extern tRWLock          glVFS_MountList;
50 extern tVFS_Mount       *gVFS_Mounts;
51 extern tVFS_Driver      *gVFS_Drivers;
52
53 // === PROTOTYPES ===
54 extern void     VFS_Deinit(void);
55 // --- open.c ---
56 extern char     *VFS_GetAbsPath(const char *Path);
57 extern tVFS_Node        *VFS_ParsePath(const char *Path, char **TruePath, tVFS_Mount **MountPoint);
58 extern tVFS_Handle      *VFS_GetHandle(int FD);
59 // --- acls.c ---
60 extern int      VFS_CheckACL(tVFS_Node *Node, Uint Permissions);
61 // --- mount.c ---
62 extern tVFS_Mount       *VFS_GetMountByIdent(Uint32 MountID);
63 // --- dir.c ---
64 extern int      VFS_MkNod(const char *Path, Uint Flags);
65 // --- handle.c ---
66 extern int      VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode);
67 extern int      VFS_SetHandle(int FD, tVFS_Node *Node, int Mode);
68
69
70 // --- VFS Helpers ---
71 static inline void _CloseNode(tVFS_Node *Node)
72 {
73         if(Node && Node->Type && Node->Type->Close)
74                 Node->Type->Close( Node );
75 }
76 static inline void _ReferenceNode(tVFS_Node *Node)
77 {
78         if( !MM_GetPhysAddr(Node->Type) ) {
79                 Log_Error("VFS", "Node %p's type is invalid (%p bad pointer) - %P corrupted",
80                         Node, Node->Type, MM_GetPhysAddr(&Node->Type));
81                 return ;
82         }
83         if( Node->Type && Node->Type->Reference )
84                 Node->Type->Reference( Node );
85         else
86                 Node->ReferenceCount ++;
87 }
88
89
90 #endif

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