@@ -132,15 +132,16 @@ func (f *file) createHeader() (fileID []byte, err error) {
132
132
return h .ID , err
133
133
}
134
134
135
- // doRead - returns "length" plaintext bytes from plaintext offset "off".
135
+ // doRead - read "length" plaintext bytes from plaintext offset "off" and append
136
+ // to "dst".
136
137
// Arguments "length" and "off" do not have to be block-aligned.
137
138
//
138
139
// doRead reads the corresponding ciphertext blocks from disk, decrypts them and
139
140
// returns the requested part of the plaintext.
140
141
//
141
142
// Called by Read() for normal reading,
142
143
// by Write() and Truncate() for Read-Modify-Write
143
- func (f * file ) doRead (off uint64 , length uint64 ) ([]byte , fuse.Status ) {
144
+ func (f * file ) doRead (dst [] byte , off uint64 , length uint64 ) ([]byte , fuse.Status ) {
144
145
// Make sure we have the file ID.
145
146
f .fileTableEntry .HeaderLock .RLock ()
146
147
if f .fileTableEntry .ID == nil {
@@ -211,7 +212,7 @@ func (f *file) doRead(off uint64, length uint64) ([]byte, fuse.Status) {
211
212
}
212
213
// else: out stays empty, file was smaller than the requested offset
213
214
214
- return out , fuse .OK
215
+ return append ( dst , out ... ) , fuse .OK
215
216
}
216
217
217
218
// Read - FUSE call
@@ -225,7 +226,7 @@ func (f *file) Read(buf []byte, off int64) (resultData fuse.ReadResult, code fus
225
226
serialize_reads .Wait (off , len (buf ))
226
227
}
227
228
228
- out , status := f .doRead (uint64 (off ), uint64 (len (buf )))
229
+ out , status := f .doRead (buf [: 0 ], uint64 (off ), uint64 (len (buf )))
229
230
230
231
if f .fs .args .SerializeReads {
231
232
serialize_reads .Done ()
@@ -282,7 +283,7 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) {
282
283
// Incomplete block -> Read-Modify-Write
283
284
if b .IsPartial () {
284
285
// Read
285
- oldData , status := f .doRead (b .BlockPlainOff (), f .contentEnc .PlainBS ())
286
+ oldData , status := f .doRead (nil , b .BlockPlainOff (), f .contentEnc .PlainBS ())
286
287
if status != fuse .OK {
287
288
tlog .Warn .Printf ("ino%d fh%d: RMW read failed: %s" , f .qIno .Ino , f .intFd (), status .String ())
288
289
return 0 , status
0 commit comments