3

python-fuse を使用してプログラムを作成しようとしていますが、ファイルを書き留めることができません。私のfile_classは次のようになります

class FuseFile(object):
def __init__(self, path, flags, *mode):
    debug(path)
    #debug(mode);
    self.file = tempfile.TemporaryFile(*mode);
    self.fd = self.file.fileno()
    self.path = path
def write(self, buf, offset):
    head, tail = os.path.split(self.path)
    self.file.seek(offset);
    self.file.write(buf);
    return len(buf)

def read(self, length, offset):
    file = apiCall("readfile",{"file":self.path}).read();
    slen = len(file)
    if length < slen:
        if offset + size > slen:
            size = slen - offset
        buf = file[offset:offset+size]
    else:
        buf = ''
    return file # I don't know if this buff stuff is necesarry...
def ftruncate(self, len):
    self.file.truncate(len);
def release(self, flags):
    self.file.close()
def flush(self):
    self._fflush()
def fsync(self, isfsyncfile):
    self._fflush()
    if isfsyncfile and hasattr(os, 'fdatasync'):
        os.fdatasync(self.fd)
    else:
        os.fsync(self.fd)
def _fflush(self):
    if 'w' in self.file.mode or 'a' in self.file.mode:
        self.file.flush()

しかし、VIM などのエディターでファイルを編集しようとすると、次のようになります。

"mnt/stuff.txt" E514: write error (file system full?)
WARNING: Original file may be lost or damaged
don't quit the editor until the file is successfully written!

[EDIT]私は問題を発見しました.openメソッドはありませんでしたが、それでも、メインのFUSEクラスにメソッドを実装するためにfile_classを取り出しました。

4

1 に答える 1

2

最終的に、ファイル クラスに open() メソッドまたは create() メソッドを作成していないことが問題であることがわかりましたが、file_class が適切に機能していないように見えたため、最終的にはすべてのメソッドをメインの FUSE クラスに実装することにしました。私のために働いて

于 2011-06-28T18:25:17.973 に答える