aboutsummaryrefslogtreecommitdiff
path: root/include/os.h
diff options
context:
space:
mode:
authorSean Anderson2023-11-04 16:37:51 -0400
committerTom Rini2023-11-16 12:43:49 -0500
commit9181cb0507d1dd5627cc3d9cd86d427abe00cc21 (patch)
tree0cd706c4991026ec68c46f009c8fa124e4e8d6e3 /include/os.h
parent333d43f6a3e2aa1d6249d22211d77802614e37e5 (diff)
arch: sandbox: Add function to create temporary files
When working with sparse data buffers that may be larger than the address space, it is convenient to work with files instead. Add a function to create temporary files of a certain size. Signed-off-by: Sean Anderson <seanga2@gmail.com>
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 fc8a1b15cbf..877404a6c13 100644
--- a/include/os.h
+++ b/include/os.h
@@ -109,6 +109,19 @@ int os_unlink(const char *pathname);
int os_persistent_file(char *buf, int maxsize, const char *fname);
/**
+ * os_mktemp() - Create a temporary file
+ * @fname: The template to use for the file name. This must end with 6 Xs. It
+ * will be modified to the opened filename on success.
+ * @size: The size of the file
+ *
+ * Create a temporary file using @fname as a template, unlink it, and truncate
+ * it to @size.
+ *
+ * Return: A file descriptor, or negative errno on error
+ */
+int os_mktemp(char *fname, off_t size);
+
+/**
* os_exit() - access to the OS exit() system call
*
* This exits with the supplied return code, which should be 0 to indicate