Starting on a NFS driver
authorJohn Hodge <[email protected]>
Fri, 5 Mar 2010 14:57:07 +0000 (22:57 +0800)
committerJohn Hodge <[email protected]>
Fri, 5 Mar 2010 14:57:07 +0000 (22:57 +0800)
Modules/Filesystems/FS_NFS/Makefile [new file with mode: 0644]
Modules/Filesystems/FS_NFS/common.h [new file with mode: 0644]
Modules/Filesystems/FS_NFS/main.c [new file with mode: 0644]

diff --git a/Modules/Filesystems/FS_NFS/Makefile b/Modules/Filesystems/FS_NFS/Makefile
new file mode 100644 (file)
index 0000000..6fa2e6e
--- /dev/null
@@ -0,0 +1,7 @@
+#
+#
+
+OBJ = main.o
+NAME = FS_NFS
+
+-include ../Makefile.tpl
diff --git a/Modules/Filesystems/FS_NFS/common.h b/Modules/Filesystems/FS_NFS/common.h
new file mode 100644 (file)
index 0000000..d73592f
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Acess2 - NFS Driver
+ * By John Hodge (thePowersGang)
+ * This file is published under the terms of the Acess licence. See the
+ * file COPYING for details.
+ *
+ * common.h - Common definitions
+ */
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+typedef struct sNFS_Connection
+{
+        int    FD;
+       tIPAddr Host;
+       char    *Base;
+       tVFS_Node       Node;
+}      tNFS_Connection;
+
+#endif
diff --git a/Modules/Filesystems/FS_NFS/main.c b/Modules/Filesystems/FS_NFS/main.c
new file mode 100644 (file)
index 0000000..459945f
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Acess2 - NFS Driver
+ * By John Hodge (thePowersGang)
+ * This file is published under the terms of the Acess licence. See the
+ * file COPYING for details.
+ *
+ * main.c - Driver core
+ */
+#define DEBUG  1
+#define VERBOSE        0
+#include "common.h"
+#include <modules.h>
+
+// === PROTOTYPES ===
+ int   NFS_Install(char **Arguments);
+tVFS_Node      *NFS_InitDevice(char *Devices, char **Options);
+void   NFS_Unmount(tVFS_Node *Node);
+
+// === GLOBALS ===
+MODULE_DEFINE(0, 0x32 /*v0.5*/, FS_NFS, NFS_Install, NULL);
+tVFS_Driver    gNFS_FSInfo = {"nfs", 0, NFS_InitDevice, NFS_Unmount, NULL};
+
+tNFS_Connection        *gpNFS_Connections;
+
+// === CODE ===
+/**
+ * \brief Installs the NFS driver
+ */
+int NFS_Install(char **Arguments)
+{
+       VFS_AddDriver( &gNFS_FSInfo );
+       return 1;
+}
+
+/**
+ * \brief Mount a NFS share
+ */
+tVFS_Node *NFS_InitDevice(char *Device, char **Options)
+{
+       char    *path, *host;
+       tNFS_Connection *conn;
+       
+       path = strchr( Device, ':' ) + 1;
+       host = strndup( Device, (int)(path-Device)-1 );
+       
+       conn = malloc( sizeof(tNFS_Connection) );
+       
+       if( !IPTools_GetAddress(host, &conn->IP) ) {
+               free(conn);
+               return NULL;
+       }
+       free(host);
+       
+       conn->FD = IPTools_OpenUdpClient( &conn->Host );
+       if(conn->FD == -1) {
+               free(conn);
+               return NULL;
+       }
+       
+       conn->Base = strdup( path );
+       conn->RootNode.ImplPtr = conn;
+       conn->RootNode.Flags = VFS_FFLAG_DIRECTORY;
+       
+       conn->RootNode.ReadDir = NFS_ReadDir;
+       conn->RootNode.FindDir = NFS_FindDir;
+       conn->RootNode.Close = NULL;
+       
+       return &conn->RootNode;
+}
+
+void NFS_Unmount(tVFS_Node *Node)
+{
+       
+}

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