From 134f1d02a00ac320c3f22354e014917ea552b01f Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 5 Mar 2010 22:57:07 +0800 Subject: [PATCH] Starting on a NFS driver --- Modules/Filesystems/FS_NFS/Makefile | 7 +++ Modules/Filesystems/FS_NFS/common.h | 20 ++++++++ Modules/Filesystems/FS_NFS/main.c | 74 +++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 Modules/Filesystems/FS_NFS/Makefile create mode 100644 Modules/Filesystems/FS_NFS/common.h create mode 100644 Modules/Filesystems/FS_NFS/main.c diff --git a/Modules/Filesystems/FS_NFS/Makefile b/Modules/Filesystems/FS_NFS/Makefile new file mode 100644 index 00000000..6fa2e6e3 --- /dev/null +++ b/Modules/Filesystems/FS_NFS/Makefile @@ -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 index 00000000..d73592fe --- /dev/null +++ b/Modules/Filesystems/FS_NFS/common.h @@ -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 index 00000000..459945fa --- /dev/null +++ b/Modules/Filesystems/FS_NFS/main.c @@ -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 + +// === 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) +{ + +} -- 2.20.1