changeset 160:e0eac67d92b2 draft

fs: add initial fuse NOP implementation
author Steve Dougherty <steve@asksteved.com>
date Sat, 17 Oct 2015 20:59:47 -0400
parents c2181a1effb8
children 2d0546bd3c3f
files .gitignore src/CMakeLists.txt src/fs/nomadfs.py src/fs/nomadsocket.py
diffstat 4 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.gitignore	Sun Oct 18 16:32:58 2015 -0400
+++ b/.gitignore	Sat Oct 17 20:59:47 2015 -0400
@@ -4,6 +4,7 @@
 Makefile
 cmake_install.cmake
 install_manifest.txt
+*.pyc
 
 build/
 
--- a/src/CMakeLists.txt	Sun Oct 18 16:32:58 2015 -0400
+++ b/src/CMakeLists.txt	Sat Oct 17 20:59:47 2015 -0400
@@ -71,3 +71,4 @@
 add_subdirectory(server)
 add_subdirectory(client)
 add_subdirectory(tool)
+add_subdirectory(fs)
--- a/src/fs/nomadfs.py	Sun Oct 18 16:32:58 2015 -0400
+++ b/src/fs/nomadfs.py	Sat Oct 17 20:59:47 2015 -0400
@@ -23,6 +23,8 @@
 
 import errno
 import fuse
+import socket
+import nomadsocket
 
 fuse.fuse_python_api = (0, 2)
 
@@ -30,6 +32,11 @@
 class Nomad(fuse.Fuse):
     def __init__(self, *args, **kw):
         fuse.Fuse.__init__(self, *args, **kw)
+        # TODO: take hostname and port as arguments
+        # TODO: where to close these? fsdestroy?
+        self.sock = socket.create_connection(("localhost", 2323))
+        self.conn = nomadsocket.NomadSocket(self.sock)
+        self.conn.nop()
 
     def getattr(self, path):
         return -errno.ENOSYS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fs/nomadsocket.py	Sat Oct 17 20:59:47 2015 -0400
@@ -0,0 +1,18 @@
+import xdrsock
+
+# TODO: use constantsgen
+NOP = 0
+LOGIN = 1
+
+
+class NomadSocket(object):
+
+    def __init__(self, sock):
+        self.conn = xdrsock.XDRSock(sock)
+
+    def _send_header(self, command):
+        self.conn.send_u32(command)
+
+    def nop(self):
+        self._send_header(NOP)
+        assert self.conn.recv_u32() == 0