Ficus
  • Overview
  • Repository
  • Tickets
  • Statistics
  • Projects

Repository

mkdir implementation

Parent commits : f1b5bb15dbfc194b78b8b4335c950ee503e96f3c,
Children commits : 6f75e871462e83d693ce378bef704936dd52de25,

By Laurent Defert on 2012-09-18 11:49:42
mkdir implementation

Browse content
Difference with parent commit f1b5bb15dbfc194b78b8b4335c950ee503e96f3c
Files modified:
bin/ficus_mount.in
--- 
+++ 
@@ -36,7 +36,7 @@
         return path.split('/')
 
 class FicusFS(fuse.Fuse):
-    IMPLEMENTED_METHODS = ['getattr', 'readdir', 'chmod', 'chown']
+    IMPLEMENTED_METHODS = ['getattr', 'readdir', 'chmod', 'chown', 'mkdir']
     def __init__(self, *args, **kw):
         self.host = '127.0.0.1'
         self.port = 9801

ficus/ficus_client.py
--- 
+++ 
@@ -246,8 +246,8 @@
             return
         self.server.send([choice(list(owners))], 'get_dir %s' % path, callback)
 
-    @cmd_arg_types(normpath)
-    def cmd_dmkdir(self, path):
+    @cmd_arg_types(normpath, int, int, int)
+    def cmd_dmkdir(self, path, mode, gid, uid):
         if path == '/':
             logging.error('Trying to mkdir /')
             return
@@ -256,11 +256,11 @@
 
         if not self.fs.has_file(parent):
             print 'doing get_dir before dmkdir'
-            self.dretrieve_dir(parent, lambda: self.cmd_dmkdir(path))
+            self.dretrieve_dir(parent, lambda: self.cmd_dmkdir(path, mode, gid, uid))
             return
 
         # Create the dir locally
-        self.fs.mkdir(path)
+        self.fs.mkdir(path, mode, gid, uid)
         self.fs.set_owners(path, set([self.server.get_id()]))
 
         # As the parent dir was modified (to add the entry),

ficus/ficus_server.py
--- 
+++ 
@@ -1,3 +1,4 @@
+import stat
 import socket
 import logging
 from ConfigParser import NoOptionError
@@ -25,7 +26,7 @@
         else:
             if not self.has_root():
                 logging.info('Creating root directory')
-                self.fs.mkdir('/')
+                self.fs.mkdir('/', stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO, 0, 0)
                 self.set_root_owners([self.get_id()])
 
     def is_initing(self):

ficus/fs.py
--- 
+++ 
@@ -1,5 +1,6 @@
 import logging
 import time
+import stat
 
 from ficus.fs_history import FSHistory
 from ficus.store import Store, Dir, File, Node
@@ -29,14 +30,14 @@
         f.write(data)
         f.close()
 
-    def mkdir(self, dirname):
+    def mkdir(self, dirname, mode, gid, uid):
         logging.debug('mkdir %s' % dirname)
         filename = self.hdd_filename(dirname)
         entry = Dir(filename)
-        entry.attrs['mode'] = 16877,
+        entry.attrs['mode'] = stat.S_IFDIR | mode,
         entry.attrs['size'] = 1000,
-        entry.attrs['uid'] = 1000,
-        entry.attrs['gid'] = 1000,
+        entry.attrs['gid'] = gid,
+        entry.attrs['uid'] = uid,
         entry.attrs['ctime'] = int(time.time()),
         entry.attrs['mtime'] = int(time.time()),
         entry.attrs['atime'] = int(time.time()),

ficus/mount/client.py
--- 
+++ 
@@ -154,9 +154,12 @@
         print '*** link', targetPath, linkPath
         return -errno.ENOSYS
 
-    def mkdir ( self, path, mode ):
+    def mkdir(self, path, mode):
         print '*** mkdir', path, oct(mode)
-        return -errno.ENOSYS
+        ctx = fuse.FuseGetContext()
+        self.send('dmkdir %s %i %i %i' % (path, mode, ctx['gid'], ctx['uid']))
+        cmd, data = self.receive()
+        return 0
 
     def mknod ( self, path, mode, dev ):
         print '*** mknod', path, oct(mode), dev

Generated with KisssPM