aboutsummaryrefslogtreecommitdiff
path: root/include/os.h
diff options
context:
space:
mode:
authorSimon Glass2021-08-18 21:40:31 -0600
committerTom Rini2021-09-16 13:19:25 -0400
commitb9274095c2cd1ae42f232c823e9e9557696be91a (patch)
tree86f177f5110c4774d7b09e4042ae9591e8b984fd /include/os.h
parentb4467fae06e7c5b48635cd28e0b168b8508ad168 (diff)
sandbox: Add a way to map a file into memory
It is useful to map a file into memory so that it can be accessed using simple pointers. Add a function to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/os.h')
-rw-r--r--include/os.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/os.h b/include/os.h
index 7661078d336..770d76e02f7 100644
--- a/include/os.h
+++ b/include/os.h
@@ -406,6 +406,19 @@ int os_write_file(const char *name, const void *buf, int size);
*/
int os_read_file(const char *name, void **bufp, int *sizep);
+/**
+ * os_map_file() - Map a file from the host filesystem into memory
+ *
+ * This can be useful when to provide a backing store for an emulated device
+ *
+ * @pathname: File pathname to map
+ * @os_flags: Flags, like OS_O_RDONLY, OS_O_RDWR
+ * @bufp: Returns buffer containing the file
+ * @sizep: Returns size of data
+ * Return: 0 if OK, -ve on error
+ */
+int os_map_file(const char *pathname, int os_flags, void **bufp, int *sizep);
+
/*
* os_find_text_base() - Find the text section in this running process
*