Fix append issue
This commit is contained in:
parent
1ca4fc89aa
commit
b13cc9686c
@ -56,6 +56,7 @@ func (f *file) doRead(off uint64, length uint64) ([]byte, fuse.Status) {
|
|||||||
|
|
||||||
// Read the backing ciphertext in one go
|
// Read the backing ciphertext in one go
|
||||||
alignedOffset, alignedLength, skip := f.cfs.CiphertextRange(off, length)
|
alignedOffset, alignedLength, skip := f.cfs.CiphertextRange(off, length)
|
||||||
|
cryptfs.Debug.Printf("CiphertextRange(%d, %d) -> %d, %d, %d\n", off, length, alignedOffset, alignedLength, skip)
|
||||||
ciphertext := make([]byte, int(alignedLength))
|
ciphertext := make([]byte, int(alignedLength))
|
||||||
n, err := f.fd.ReadAt(ciphertext, int64(alignedOffset))
|
n, err := f.fd.ReadAt(ciphertext, int64(alignedOffset))
|
||||||
ciphertext = ciphertext[0:n]
|
ciphertext = ciphertext[0:n]
|
||||||
@ -121,7 +122,7 @@ func (f *file) Write(data []byte, off int64) (uint32, fuse.Status) {
|
|||||||
if b.IsPartial() {
|
if b.IsPartial() {
|
||||||
// Read
|
// Read
|
||||||
o, _ := b.PlaintextRange()
|
o, _ := b.PlaintextRange()
|
||||||
oldData, status := f.doRead(f.cfs.PlainBS(), o)
|
oldData, status := f.doRead(o, f.cfs.PlainBS())
|
||||||
if status != fuse.OK {
|
if status != fuse.OK {
|
||||||
cryptfs.Warn.Printf("RMW read failed: %s\n", status.String())
|
cryptfs.Warn.Printf("RMW read failed: %s\n", status.String())
|
||||||
return written, status
|
return written, status
|
||||||
|
Loading…
x
Reference in New Issue
Block a user