changeset 163:9f771fd07445 draft default tip

WIP - add stub functions; docs
author Steve Dougherty <steve@asksteved.com>
date Sun, 18 Oct 2015 20:00:54 -0400
parents 9edefbbd208f
children
files src/fs/fs src/fs/nomad/nomadsocket.py
diffstat 2 files changed, 34 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/fs/fs	Sun Oct 18 18:35:37 2015 -0400
+++ b/src/fs/fs	Sun Oct 18 20:00:54 2015 -0400
@@ -36,12 +36,26 @@
         # TODO: where to close these? fsdestroy?
         self.sock = socket.create_connection(("localhost", 2323))
         self.conn = nomadsocket.NomadSocket(self.sock)
-        self.conn.nop()
+        self.root_node = self.conn.login("A", "myfiles")
+        root_attr = self.conn.stat(self.root_node)
+        print(root_attr)
 
     def getattr(self, path):
+        handle = self.conn.lookup(self.root_node, path)
+        return self.conn.stat(handle)
+
+    def readdir(self, path, offset, *fh):
         return -errno.ENOSYS
 
-    def getdir(self, path):
+    def unlink(self, path):
+        return self.conn.remove(self.root_node, path)
+
+    # TODO: args
+    def read(self):
+        return -errno.ENOSYS
+
+    # TODO: args
+    def write(self):
         return -errno.ENOSYS
 
 
--- a/src/fs/nomad/nomadsocket.py	Sun Oct 18 18:35:37 2015 -0400
+++ b/src/fs/nomad/nomadsocket.py	Sun Oct 18 20:00:54 2015 -0400
@@ -1,6 +1,7 @@
 from collections import namedtuple
 import datetime
 import nomad.xdrsock
+import os
 
 # TODO: use constantsgen
 NOP = 0
@@ -43,10 +44,19 @@
         self.conn = nomad.xdrsock.XDRSock(sock)
 
     def nop(self):
+        """
+        no-op; intended as a ping.
+        """
         self._send_header(NOP)
         self._recv_header()
 
     def login(self, conn_name, vg_name):
+        """
+
+        :param conn_name:
+        :param vg_name:
+        :return: root node handle
+        """
         self._send_header(LOGIN)
         self.conn.send_string(conn_name)
         self.conn.send_string(vg_name)
@@ -55,6 +65,11 @@
         return self._recv_handle()
 
     def stat(self, handle):
+        """
+
+        :param handle:
+        :return: attributes
+        """
         self._send_header(STAT)
         self._send_handle(handle)
 
@@ -100,6 +115,9 @@
     def _recv_header(self):
         value = self.conn.recv_u32()
         # TODO: raise on nonzero instead? errors map?
+
+        if value:
+            print("Failed: {} ({})".format(value, os.strerror(value)))
         assert value == 0
         return value