# HG changeset patch # User Paul Boddie # Date 1618698463 -7200 # Node ID 808968fd16e5ee0ab2495b1549571faf7520f203 # Parent bfd9e56484870962d7ddf3e5147b926c77a97053 Added automatic memory mapping for reading and writing if not already performed. diff -r bfd9e5648487 -r 808968fd16e5 libfsclient/lib/src/client.cc --- a/libfsclient/lib/src/client.cc Sun Apr 18 00:26:47 2021 +0200 +++ b/libfsclient/lib/src/client.cc Sun Apr 18 00:27:43 2021 +0200 @@ -200,6 +200,11 @@ if (file == NULL) return 0; + /* Map memory if none has been mapped so far. */ + + if ((file->memory == NULL) && (client_mmap(file, client_tell(file), count) == NULL)) + return 0; + /* Amount available in the descriptor buffer already. */ offset_t available = file_data_available(file); @@ -334,6 +339,11 @@ if (file == NULL) return 0; + /* Map memory if none has been mapped so far. */ + + if ((file->memory == NULL) && (client_mmap(file, client_tell(file), count) == NULL)) + return 0; + /* Attempt to ensure that the file can accept the amount of data to be written. This may not resize to the needed amount if a file has a fixed size, but data will still be written to any available space. */