Skip to content

Commit

Permalink
Merge branch 'bug/1'
Browse files Browse the repository at this point in the history
  • Loading branch information
terencehonles committed Jul 27, 2012
2 parents 2fbfe66 + 3c63959 commit 98e11c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
39 changes: 26 additions & 13 deletions fuse.py
Expand Up @@ -411,6 +411,9 @@ def getattr(self, path, buf):

def readlink(self, path, buf, bufsize):
ret = self.operations('readlink', path).encode(self.encoding)

# copies a string into the given buffer
# (null terminated and truncated if necessary)
data = create_string_buffer(ret[:bufsize - 1])
memmove(buf, data, len(data))
return 0
Expand Down Expand Up @@ -475,9 +478,13 @@ def read(self, path, buf, size, offset, fip):

if not ret: return 0

data = create_string_buffer(ret[:size], size)
memmove(buf, data, size)
return size
retsize = len(ret)
assert retsize <= size, \
'actual amount read %d greater than expected %d' % (retsize, size)

data = create_string_buffer(ret, retsize)
memmove(buf, ret, retsize)
return retsize

def write(self, path, buf, size, offset, fip):
data = string_at(buf, size)
Expand Down Expand Up @@ -536,26 +543,32 @@ def getxattr(self, path, name, value, size, *args):
.encode(self.encoding)

retsize = len(ret)
buf = create_string_buffer(ret, retsize) # Does not add trailing 0
# allow size queries
if not value: return retsize

if value:
if retsize > size: return -ERANGE
# do not truncate
if retsize > size: return -ERANGE

memmove(value, buf, retsize)
buf = create_string_buffer(ret, retsize) # Does not add trailing 0
memmove(value, buf, retsize)

return retsize

def listxattr(self, path, namebuf, size):
attrs = self.operations('listxattr', path.decode(self.encoding)) or ''
ret = '\x00'.join(attrs).encode(self.encoding) + '\x00'

retsize = len(ret)
# allow size queries
if not namebuf: return retsize

buf = create_string_buffer('\x00'.join(attrs).encode(self.encoding))
bufsize = len(buf)
if namebuf:
if bufsize > size: return -ERANGE
# do not truncate
if retsize > size: return -ERANGE

memmove(namebuf, buf, bufsize)
buf = create_string_buffer(ret, retsize)
memmove(namebuf, buf, retsize)

return bufsize
return retsize

def removexattr(self, path, name):
return self.operations('removexattr', path.decode(self.encoding),
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -13,7 +13,7 @@

setup(
name = 'fusepy',
version = '2.0',
version = '2.0.1',

description = 'Simple ctypes bindings for FUSE',
long_description = documentation,
Expand Down

0 comments on commit 98e11c5

Please sign in to comment.