Commit 07d00c02 by rfkelly0

make FUSE always pass unicode to the exposed FS

parent 4e5b9814
...@@ -156,6 +156,7 @@ class FSOperations(Operations): ...@@ -156,6 +156,7 @@ class FSOperations(Operations):
@handle_fs_errors @handle_fs_errors
def create(self,path,mode,fi): def create(self,path,mode,fi):
path = path.decode(NATIVE_ENCODING)
fh = self._reg_file(self.fs.open(path,"w"),path) fh = self._reg_file(self.fs.open(path,"w"),path)
fi.fh = fh fi.fh = fh
fi.keep_cache = 0 fi.keep_cache = 0
...@@ -171,10 +172,12 @@ class FSOperations(Operations): ...@@ -171,10 +172,12 @@ class FSOperations(Operations):
@handle_fs_errors @handle_fs_errors
def getattr(self,path,fh=None): def getattr(self,path,fh=None):
return self._get_stat_dict(path) return self._get_stat_dict(path.decode(NATIVE_ENCODING))
@handle_fs_errors @handle_fs_errors
def getxattr(self,path,name,position=0): def getxattr(self,path,name,position=0):
path = path.decode(NATIVE_ENCODING)
name = name.decode(NATIVE_ENCODING)
try: try:
value = self.fs.getxattr(path,name) value = self.fs.getxattr(path,name)
except AttributeError: except AttributeError:
...@@ -190,6 +193,7 @@ class FSOperations(Operations): ...@@ -190,6 +193,7 @@ class FSOperations(Operations):
@handle_fs_errors @handle_fs_errors
def listxattr(self,path): def listxattr(self,path):
path = path.decode(NATIVE_ENCODING)
try: try:
return self.fs.listxattrs(path) return self.fs.listxattrs(path)
except AttributeError: except AttributeError:
...@@ -197,6 +201,7 @@ class FSOperations(Operations): ...@@ -197,6 +201,7 @@ class FSOperations(Operations):
@handle_fs_errors @handle_fs_errors
def mkdir(self,path,mode): def mkdir(self,path,mode):
path = path.decode(NATIVE_ENCODING)
try: try:
self.fs.makedir(path,mode) self.fs.makedir(path,mode)
except TypeError: except TypeError:
...@@ -208,6 +213,7 @@ class FSOperations(Operations): ...@@ -208,6 +213,7 @@ class FSOperations(Operations):
@handle_fs_errors @handle_fs_errors
def open(self,path,fi): def open(self,path,fi):
path = path.decode(NATIVE_ENCODING)
mode = flags_to_mode(fi.flags) mode = flags_to_mode(fi.flags)
fi.fh = self._reg_file(self.fs.open(path,mode),path) fi.fh = self._reg_file(self.fs.open(path,mode),path)
fi.keep_cache = 0 fi.keep_cache = 0
...@@ -226,6 +232,7 @@ class FSOperations(Operations): ...@@ -226,6 +232,7 @@ class FSOperations(Operations):
@handle_fs_errors @handle_fs_errors
def readdir(self,path,fh=None): def readdir(self,path,fh=None):
path = path.decode(NATIVE_ENCODING)
# If listdir() can return info dicts directly, it will save FUSE # If listdir() can return info dicts directly, it will save FUSE
# having to call getinfo() on each entry individually. # having to call getinfo() on each entry individually.
try: try:
...@@ -238,7 +245,7 @@ class FSOperations(Operations): ...@@ -238,7 +245,7 @@ class FSOperations(Operations):
else: else:
entries = [(e["name"].encode(NATIVE_ENCODING),e,0) for e in entries] entries = [(e["name"].encode(NATIVE_ENCODING),e,0) for e in entries]
for (name,attrs,offset) in entries: for (name,attrs,offset) in entries:
self._fill_stat_dict(pathjoin(path,name),attrs) self._fill_stat_dict(pathjoin(path,name.decode(NATIVE_ENCODING)),attrs)
entries = [".",".."] + entries entries = [".",".."] + entries
return entries return entries
...@@ -258,6 +265,8 @@ class FSOperations(Operations): ...@@ -258,6 +265,8 @@ class FSOperations(Operations):
@handle_fs_errors @handle_fs_errors
def removexattr(self,path,name): def removexattr(self,path,name):
path = path.decode(NATIVE_ENCODING)
name = name.decode(NATIVE_ENCODING)
try: try:
return self.fs.delxattr(path,name) return self.fs.delxattr(path,name)
except AttributeError: except AttributeError:
...@@ -265,6 +274,8 @@ class FSOperations(Operations): ...@@ -265,6 +274,8 @@ class FSOperations(Operations):
@handle_fs_errors @handle_fs_errors
def rename(self,old,new): def rename(self,old,new):
old = old.decode(NATIVE_ENCODING)
new = new.decode(NATIVE_ENCODING)
if issamedir(old,new): if issamedir(old,new):
try: try:
self.fs.rename(old,new) self.fs.rename(old,new)
...@@ -279,10 +290,13 @@ class FSOperations(Operations): ...@@ -279,10 +290,13 @@ class FSOperations(Operations):
@handle_fs_errors @handle_fs_errors
def rmdir(self, path): def rmdir(self, path):
path = path.decode(NATIVE_ENCODING)
self.fs.removedir(path) self.fs.removedir(path)
@handle_fs_errors @handle_fs_errors
def setxattr(self,path,name,value,options,position=0): def setxattr(self,path,name,value,options,position=0):
path = path.decode(NATIVE_ENCODING)
name = name.decode(NATIVE_ENCODING)
try: try:
return self.fs.setxattr(path,name,value) return self.fs.setxattr(path,name,value)
except AttributeError: except AttributeError:
...@@ -294,6 +308,7 @@ class FSOperations(Operations): ...@@ -294,6 +308,7 @@ class FSOperations(Operations):
@handle_fs_errors @handle_fs_errors
def truncate(self, path, length, fh=None): def truncate(self, path, length, fh=None):
path = path.decode(NATIVE_ENCODING)
if fh is None and length == 0: if fh is None and length == 0:
self.fs.open(path,"w").close() self.fs.open(path,"w").close()
else: else:
...@@ -325,6 +340,7 @@ class FSOperations(Operations): ...@@ -325,6 +340,7 @@ class FSOperations(Operations):
@handle_fs_errors @handle_fs_errors
def unlink(self, path): def unlink(self, path):
path = path.decode(NATIVE_ENCODING)
self.fs.remove(path) self.fs.remove(path)
@handle_fs_errors @handle_fs_errors
...@@ -501,6 +517,7 @@ class MountProcess(subprocess.Popen): ...@@ -501,6 +517,7 @@ class MountProcess(subprocess.Popen):
super(MountProcess,self).__init__(cmd,**kwds) super(MountProcess,self).__init__(cmd,**kwds)
os.close(w) os.close(w)
if os.read(r,1) != "S": if os.read(r,1) != "S":
self.terminate()
raise RuntimeError("FUSE error: " + os.read(r,20)) raise RuntimeError("FUSE error: " + os.read(r,20))
def unmount(self): def unmount(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment