Add ignore support and logging
[dtbartle/zfs.git] / copy-acls.py
1 #!/usr/bin/python
2 import os, sys, subprocess
3
4 def doit(src, dst):
5     global count
6     for file in os.listdir(src):
7         srcfile = src + "/" + file
8         dstfile = dst + "/" + file
9         if not os.path.islink(srcfile):
10             args = [ "/usr/bin/getfacl", "--skip-base", srcfile ]
11             getfacl = subprocess.Popen(args, stdin=subprocess.PIPE,
12                 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
13             out, err = getfacl.communicate()
14             status = getfacl.wait()
15             if status == 0 and len(out) > 0:
16                 print "+ " + srcfile
17                 args = [ "/usr/bin/setfacl", "-M", "-", dstfile ]
18                 setfacl = subprocess.Popen(args, stdin=subprocess.PIPE,
19                     stdout=subprocess.PIPE, stderr=subprocess.PIPE)
20                 out, err = setfacl.communicate(out)
21                 status = setfacl.wait()
22                 if status != 0:
23                     print "setfacl %s failed (%d)" % (dstfile, status)
24                     print err
25             if os.path.isdir(srcfile):
26                 print "D " + srcfile
27                 doit(srcfile, dstfile)
28
29 src = sys.argv[1]
30 dst = sys.argv[2]
31 doit(src, dst)