3

私のFUSEベースのファイルシステムは、SQLiteデータベースに裏打ちされています。「ファイル」を閉じることができません。

mymachine@ubuntu:~/Desktop/FUSE/dedup/myfs$ cat ガンプ バットマンの戻り値cat: ガンプ: 入出力エラー cat: ガンプ: 入出力エラー

strace は次の出力を提供します。

open("gump", O_RDONLY|O_LARGEFILE)      = 3
fstat64(3, {st_mode=S_IFREG|0777, st_size=15, ...}) = 0
read(3, "batman returns", 32768)        = 14
write(1, "batman returns", 14batman returns)          = 14
read(3, 0x9e41000, 32768)               = -1 EIO (Input/output error)
write(2, "cat: ", 5cat: )                    = 5
write(2, "gump", 4gump)                     = 4
open("/usr/share/locale/locale.alias", O_RDONLY) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb773e000
read(4, "# Locale name alias data base.\n#"..., 4096) = 2570
read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0xb773e000, 4096)                = 0
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Input/output error", 20: Input/output error)    = 20
write(2, "\n", 1
)                       = 1
close(3)                                = -1 EIO (Input/output error)
write(2, "cat: ", 5cat: )                    = 5
write(2, "gump", 4gump)                     = 4
write(2, ": Input/output error", 20: Input/output error)    = 20
write(2, "\n", 1
)                       = 1
close(1)                                = 0
close(2)                                = 0
exit_group(1)                           = ?

以下は、主要な FUSE API 実装の Python コードです。

def open(self, path, flags):
    print "open: trying to open %s"  %path
    sefs = seFS()
    ret = sefs.search(path)
    print ret
    if ret is True:
        return 0
    return -errno.ENOENT

def create(self, path, flags=None, mode=None):
    print "trying to create %s", path
    print path
    print flags

    sefs = seFS()
    ret = self.open(path, flags)
    print ret

    if ret == -errno.ENOENT:
        # Create the file in database
        ret = sefs.open(path)
        print ret
        print "Creating the file %s" %path
        t = int(time.time())
        mytime = (t, t, t)
        ret = sefs.utime(path, mytime)
        print ret
        self.fd = len(sefs.ls())
        print "In create:fd = %d" %(self.fd)
        sefs.setinode(path, self.fd)
        print sefs.ls()
    else:
        print "The file %s exists!!" %path
    return 0

def write(self, path, data, offset):
    print "In write path=%s" %path
    length = len(data)
    print "The data is %s len=%d offset=%d" %(str(data), length, offset)
    sefs = seFS()
    out_stream = StringIO();

    old_data = sefs.read(path)

    if old_data is not None:
        offset = len(old_data)
        out_stream.write(old_data)
    else:
        offset = 0

    out_stream.seek(offset)
    out_stream.write(data)

    print "Seeking and getting string"
    out_stream.seek(0)
    mydata = out_stream.read()

    ret = sefs.write(path, mydata)
    return length

def release(self, path, fh=None):
    print "In release %s" %(path)
    return 0

def read(self, path, length, offset, fh=None):
    print "In read %s %d %d" %(path, length, offset)
    sefs = seFS()
    ret = sefs.read(path)
    print "read(): sefs:%s" %(str(ret))
    if ret is not None:
        fbuf = StringIO()
        fbuf.write(str(ret).strip())
        fbuf.seek(offset)
        val = fbuf.read()
        fbuf.close()
        del fbuf
        return val
    else:
        return ""

def flush(path, fh=None):
    print "in flush"
    return 0
4

0 に答える 0