1.1 --- a/include/fsclient/client.h Thu Apr 02 23:18:09 2020 +0200
1.2 +++ b/include/fsclient/client.h Sun Apr 05 23:49:39 2020 +0200
1.3 @@ -39,9 +39,9 @@
1.4
1.5 /* File and device opening. */
1.6
1.7 -file_descriptor_t *client_open(file_descriptor_t *desc, const char *name, int flags);
1.8 -file_descriptor_t *client_open_device(file_descriptor_t *desc, const char *cap, int flags);
1.9 -int client_open_desc(file_descriptor_t *desc, int flags);
1.10 +file_descriptor_t *client_open(file_descriptor_t *desc, const char *name, int flags, size_t buffer_size);
1.11 +file_descriptor_t *client_open_device(file_descriptor_t *desc, const char *cap, int flags, size_t buffer_size);
1.12 +int client_open_desc(file_descriptor_t *desc, int flags, size_t buffer_size);
1.13
1.14 /* File and device closing. */
1.15
2.1 --- a/lib/src/client.c Thu Apr 02 23:18:09 2020 +0200
2.2 +++ b/lib/src/client.c Sun Apr 05 23:49:39 2020 +0200
2.3 @@ -34,7 +34,7 @@
2.4
2.5
2.6
2.7 -/* NOTE: Need to parameterise this (again). */
2.8 +/* Default size of mapped memory region. */
2.9
2.10 const int DEFAULT_BUFFER_SIZE = 4096;
2.11
2.12 @@ -118,7 +118,7 @@
2.13 /* Open a filesystem object. */
2.14
2.15 file_descriptor_t *client_open(file_descriptor_t *desc, const char *name,
2.16 - int flags)
2.17 + int flags, size_t buffer_size)
2.18 {
2.19 if (desc == NULL)
2.20 return NULL;
2.21 @@ -146,7 +146,7 @@
2.22 return NULL;
2.23 }
2.24
2.25 - if (client_open_desc(desc, flags))
2.26 + if (client_open_desc(desc, flags, buffer_size))
2.27 return desc;
2.28 else
2.29 return NULL;
2.30 @@ -157,7 +157,7 @@
2.31 /* Open a device as a file. */
2.32
2.33 file_descriptor_t *client_open_device(file_descriptor_t *desc, const char *cap,
2.34 - int flags)
2.35 + int flags, size_t buffer_size)
2.36 {
2.37 if (desc == NULL)
2.38 return NULL;
2.39 @@ -181,7 +181,7 @@
2.40 return NULL;
2.41 }
2.42
2.43 - if (client_open_desc(desc, flags))
2.44 + if (client_open_desc(desc, flags, buffer_size))
2.45 return desc;
2.46 else
2.47 return NULL;
2.48 @@ -191,7 +191,7 @@
2.49
2.50 /* Complete the initialisation of a descriptor. */
2.51
2.52 -int client_open_desc(file_descriptor_t *desc, int flags)
2.53 +int client_open_desc(file_descriptor_t *desc, int flags, size_t buffer_size)
2.54 {
2.55 /* Release the context. */
2.56
2.57 @@ -204,7 +204,8 @@
2.58 /* Initially, memory-map the start of the file. If the memory mapping fails,
2.59 the dataspace address for the object will be zero. */
2.60
2.61 - desc->obj.buffer = client_mmap(desc, 0, DEFAULT_BUFFER_SIZE);
2.62 + desc->obj.buffer = client_mmap(desc, 0, buffer_size ? buffer_size
2.63 + : DEFAULT_BUFFER_SIZE);
2.64
2.65 /* Return with success if a buffer was assigned. */
2.66