summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-02-07 01:32:57 +0000
committerAnand V. Avati <avati@dev.gluster.com>2011-02-07 00:59:22 -0800
commit31efe81b13d6761cf153e71f7ac150751b2d4090 (patch)
treee169823dc15aa2ad602ad5efd5bb719ea616b30c /xlators
parentd376253d1e91b9fc29f6a23253021647e139c2c1 (diff)
syncdaemon: add "setattr" server method, needed to synchronize metadata of links/dirs
Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 2318 (gsyncd.py :chmod on directory not working) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2318
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/marker/utils/syncdaemon/master.py22
-rw-r--r--xlators/features/marker/utils/syncdaemon/resource.py13
2 files changed, 27 insertions, 8 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/master.py b/xlators/features/marker/utils/syncdaemon/master.py
index a2f9f718eb4..1abd0325268 100644
--- a/xlators/features/marker/utils/syncdaemon/master.py
+++ b/xlators/features/marker/utils/syncdaemon/master.py
@@ -67,7 +67,7 @@ class GMaster(object):
self.jobtab[path] = []
self.jobtab[path].append((label, a, lambda : job(*a, **kw)))
- def wait(self, path, mark):
+ def wait(self, path, *args):
jobs = self.jobtab.pop(path, [])
succeed = True
for j in jobs:
@@ -75,10 +75,12 @@ class GMaster(object):
if not ret:
succeed = False
if succeed:
- self.sendmark(path, mark)
+ self.sendmark(path, *args)
return succeed
- def sendmark(self, path, mark):
+ def sendmark(self, path, mark, adct=None):
+ if adct:
+ self.slave.server.setattr(path, adct)
self.slave.server.set_xtime(path, self.uuid, mark)
def crawl(self, path='.', xtl=None):
@@ -141,12 +143,15 @@ class GMaster(object):
else:
raise
for e, xte in chld:
- mo = indulgently(e, lambda e: os.lstat(e).st_mode)
- if mo == False:
+ st = indulgently(e, lambda e: os.lstat(e))
+ if st == False:
continue
+ mo = st.st_mode
+ adct = {'own': (st.st_uid, st.st_gid)}
if stat.S_ISLNK(mo):
- self.slave.server.symlink(os.readlink(e), e)
- self.sendmark(e, xte)
+ if indulgently(e, lambda e: self.slave.server.symlink(os.readlink(e), e)) == False:
+ continue
+ self.sendmark(e, xte, adct)
elif stat.S_ISREG(mo):
logging.debug("syncing %s ..." % e)
pb = self.syncer.add(e)
@@ -159,7 +164,8 @@ class GMaster(object):
logging.error("failed to sync " + e)
self.add_job(path, 'reg', regjob, e, xte, pb)
elif stat.S_ISDIR(mo):
- if indulgently(e, lambda e: (self.add_job(path, 'cwait', self.wait, e, xte),
+ adct['mode'] = mo
+ if indulgently(e, lambda e: (self.add_job(path, 'cwait', self.wait, e, xte, adct),
self.crawl(e, xte),
True)[-1], blame=e) == False:
continue
diff --git a/xlators/features/marker/utils/syncdaemon/resource.py b/xlators/features/marker/utils/syncdaemon/resource.py
index f484d1de5c1..7ba7cb9d453 100644
--- a/xlators/features/marker/utils/syncdaemon/resource.py
+++ b/xlators/features/marker/utils/syncdaemon/resource.py
@@ -1,6 +1,7 @@
import re
import os
import sys
+import stat
import time
import errno
import struct
@@ -157,6 +158,18 @@ class Server(object):
Xattr.lsetxattr(path, '.'.join([cls.GX_NSPACE, uuid, 'xtime']), struct.pack('!II', *mark))
@staticmethod
+ def setattr(path, adct):
+ own = adct.get('own')
+ if own:
+ os.lchown(path, *own)
+ mode = adct.get('mode')
+ if mode:
+ os.chmod(path, stat.S_IMODE(mode))
+ times = adct.get('times')
+ if times:
+ os.utime(path, times)
+
+ @staticmethod
def pid():
return os.getpid()