Removed debug from VFS_GetACL and VTerm, fixed DevFS not being a directory
[tpg/acess2.git] / Kernel / vfs / fs / devfs.c
1 /*
2  * Acess 2
3  * Device Filesystem (DevFS)
4  * - vfs/fs/devfs.c
5  */
6 #include <common.h>
7 #include <vfs.h>
8 #include <fs_devfs.h>
9
10 // === PROTOTYPES ===
11  int    DevFS_AddDevice(tDevFS_Driver *Dev);
12 tVFS_Node       *DevFS_InitDevice(char *Device, char *Options);
13 char    *DevFS_ReadDir(tVFS_Node *Node, int Pos);
14 tVFS_Node       *DevFS_FindDir(tVFS_Node *Node, char *Name);
15
16 // === GLOBALS ===
17 tVFS_Driver     gDevFS_Info = {
18         "devfs", 0, DevFS_InitDevice, NULL, NULL
19         };
20 tVFS_Node       gDevFS_RootNode = {
21         .NumACLs = 1,
22         .Flags = VFS_FFLAG_DIRECTORY,
23         .ACLs = &gVFS_ACL_EveryoneRW,
24         .ReadDir = DevFS_ReadDir,
25         .FindDir = DevFS_FindDir
26         };
27 tDevFS_Driver   *gDevFS_Drivers = NULL;
28  int    giDevFS_NextID = 1;
29
30 // === CODE ===
31 /**
32  * \fn int DevFS_AddDevice(tDevFS_Driver *Dev)
33  */
34 int DevFS_AddDevice(tDevFS_Driver *Dev)
35 {
36         Dev->Next = gDevFS_Drivers;
37         gDevFS_Drivers = Dev;
38         
39         return giDevFS_NextID++;
40 }
41
42 /**
43  * \fn tVFS_Node *DevFS_InitDevice(char *Device, char *Options)
44  * \brief Initialise the DevFS and detect double-mounting, or just do nothing
45  * \stub
46  */
47 tVFS_Node *DevFS_InitDevice(char *Device, char *Options)
48 {
49         return &gDevFS_RootNode;
50 }
51
52 /**
53  * \fn char *DevFS_ReadDir(tVFS_Node *Node, int Pos)
54  */
55 char *DevFS_ReadDir(tVFS_Node *Node, int Pos)
56 {
57         tDevFS_Driver   *dev;
58         
59         if(Pos < 0)     return NULL;
60         
61         for(dev = gDevFS_Drivers;
62                 dev && Pos--;
63                 dev = dev->Next
64                 );
65         
66         return dev->Name;
67 }
68
69 /**
70  * \fn tVFS_Node *DevFS_FindDir(tVFS_Node *Node, char *Name)
71  * \brief Get an entry from the devices directory
72  */
73 tVFS_Node *DevFS_FindDir(tVFS_Node *Node, char *Name)
74 {
75         tDevFS_Driver   *dev;
76         
77         //ENTER("pNode sName", Node, Name);
78         
79         for(dev = gDevFS_Drivers;
80                 dev;
81                 dev = dev->Next
82                 )
83         {
84                 //LOG("dev = %p", dev);
85                 //LOG("dev->Name = '%s'", dev->Name);
86                 if(strcmp(dev->Name, Name) == 0) {
87                         //LEAVE('p', &dev->RootNode);
88                         return &dev->RootNode;
89                 }
90         }
91         
92         //LEAVE('n');
93         return NULL;
94 }
95
96 // --- EXPORTS ---
97 EXPORT(DevFS_AddDevice);

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