def truncate(self, shelf, length, fd): # shadow_dir, yes an fd
try:
if fd: # It's an open shelf
assert self[shelf.name]._fd == fd, 'fd mismatch on truncate'
os.truncate(
shelf._fd if shelf._fd >= 0 else self.shadowpath(shelf.name),
length)
shelf.size_bytes = length
if shelf.open_handle is None:
shelf = self[shelf.id]
if shelf is not None:
shelf.size_bytes = length
return 0
except OSError as e:
raise TmfsOSError(e.errno)
评论列表
文章目录