Kernel - Slight reworks to timer code
[tpg/acess2.git] / Modules / Filesystems / NFS / main.c
1 /*
2  * Acess2 - NFS Driver
3  * By John Hodge (thePowersGang)
4  * This file is published under the terms of the Acess licence. See the
5  * file COPYING for details.
6  *
7  * main.c - Driver core
8  */
9 #define DEBUG   1
10 #define VERBOSE 0
11 #include "common.h"
12 #include <modules.h>
13
14 // === PROTOTYPES ===
15  int    NFS_Install(char **Arguments);
16 tVFS_Node       *NFS_InitDevice(char *Devices, char **Options);
17 void    NFS_Unmount(tVFS_Node *Node);
18
19 // === GLOBALS ===
20 MODULE_DEFINE(0, 0x32 /*v0.5*/, FS_NFS, NFS_Install, NULL);
21 tVFS_Driver     gNFS_FSInfo = {"nfs", 0, NFS_InitDevice, NFS_Unmount, NULL};
22
23 tNFS_Connection *gpNFS_Connections;
24
25 // === CODE ===
26 /**
27  * \brief Installs the NFS driver
28  */
29 int NFS_Install(char **Arguments)
30 {
31         VFS_AddDriver( &gNFS_FSInfo );
32         return 1;
33 }
34
35 /**
36  * \brief Mount a NFS share
37  */
38 tVFS_Node *NFS_InitDevice(char *Device, char **Options)
39 {
40         char    *path, *host;
41         tNFS_Connection *conn;
42         
43         path = strchr( Device, ':' ) + 1;
44         host = strndup( Device, (int)(path-Device)-1 );
45         
46         conn = malloc( sizeof(tNFS_Connection) );
47         
48         if( !IPTools_GetAddress(host, &conn->IP) ) {
49                 free(conn);
50                 return NULL;
51         }
52         free(host);
53         
54         conn->FD = IPTools_OpenUdpClient( &conn->Host );
55         if(conn->FD == -1) {
56                 free(conn);
57                 return NULL;
58         }
59         
60         conn->Base = strdup( path );
61         conn->RootNode.ImplPtr = conn;
62         conn->RootNode.Flags = VFS_FFLAG_DIRECTORY;
63         
64         conn->RootNode.ReadDir = NFS_ReadDir;
65         conn->RootNode.FindDir = NFS_FindDir;
66         conn->RootNode.Close = NULL;
67         
68         return &conn->RootNode;
69 }
70
71 void NFS_Unmount(tVFS_Node *Node)
72 {
73         
74 }

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