2016-08-03 1 views
1

파이썬 - 퓨즈에 문제가 있습니다. 가짜 - 메모리 파일 시스템을 마운트 할 때 https://gist.github.com/ensonic/87e4108a7be64412d1c5a553b7e01f88파이썬 퓨즈에서 EINVAL로 이어지는 이중 읽기 호출

, 내가 내용을 나열 할 수 있습니다,하지만 난 파일을 읽을 수 있습니다 : 내가 퓨즈를 실행하면

> ls -al ~/temp/mount/ 
total 1 
-r--r--r-- 1 user group 34 Aug 3 22:44 test.txt 
> cat ~/temp/mount/test.txt 
cat: /home/user/temp/mount/test.txt: Invalid argument 

을 여기에 문제의 독립 예입니다 를 forground (-d)의 FS는,이 디버그 정보를 얻을 :

LOOKUP /test.txt 
getattr /test.txt 
    NODEID: 2 
    unique: 120, success, outsize: 144 
unique: 121, opcode: OPEN (14), nodeid: 2, insize: 48, pid: 10342 
open flags: 0x8000 /test.txt 
    open[0] flags: 0x8000 /test.txt 
    unique: 121, success, outsize: 32 
unique: 122, opcode: READ (15), nodeid: 2, insize: 80, pid: 10342 
read[0] 4096 bytes from 0 flags: 0x8000 
    unique: 122, error: -22 (Invalid argument), outsize: 16 
unique: 123, opcode: READ (15), nodeid: 2, insize: 80, pid: 10342 
read[0] 4096 bytes from 0 flags: 0x8000 
    unique: 123, error: -22 (Invalid argument), outsize: 16 
unique: 124, opcode: FLUSH (25), nodeid: 2, insize: 64, pid: 10342 
    unique: 124, error: -38 (Function not implemented), outsize: 16 
unique: 125, opcode: RELEASE (18), nodeid: 2, insize: 64, pid: 0 
release[0] flags: 0x8000 
    unique: 125, success, outsize: 16 

을 내 로그 파일이 있습니다

INFO:fakefs:open fake file /test.txt 
INFO:fakefs:read from /test.txt, offs 0, size 4096, len 34 
INFO:fakefs:read remainder 
INFO:fakefs:read() = 34 bytes 
INFO:fakefs:read from /test.txt, offs 0, size 4096, len 34 
INFO:fakefs:read remainder 
INFO:fakefs:read() = 34 bytes 
INFO:fakefs:released(/test.txt) = 0 
,536,913을

내가 궁금한 게 있는데 : 1) 왜 두 번 읽었 는가? (0 플래그에서 [0] 4096 바이트 읽기 : 0x8000) 2) 왜 EINVAL을 리턴합니까? 데이터를 반환합니다 - 내 코드에는 단일 EINVAL이 없습니다.

실제 예제에서 나는 fs 함수의 나머지 부분도 구현하고 있습니다. 이것은 문제가 아닙니다.

답변

0

파이썬 2의 인코딩 처리가 까다로운 것으로 밝혀졌습니다 (py3에는 파이썬 - 퓨즈가 없습니다).

read()에서 바이트 (buf)를 반환하면이를 수정합니다. 퓨즈 코드는 EINVAL을 사용하는데, 파이썬 측에서는 잘못된 것으로 보입니다.