From b4467fae06e7c5b48635cd28e0b168b8508ad168 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 18 Aug 2021 21:40:30 -0600 Subject: sandbox: Add a way to find the size of a file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a function to return the size of a file. This is useful in situations where we need to allocate memory for it before reading it. Signed-off-by: Simon Glass Reviewed-by: Marek BehĂșn --- include/os.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/os.h b/include/os.h index 7b20d606dd0..7661078d336 100644 --- a/include/os.h +++ b/include/os.h @@ -51,6 +51,14 @@ off_t os_lseek(int fd, off_t offset, int whence); #define OS_SEEK_CUR 1 #define OS_SEEK_END 2 +/** + * os_filesize() - Calculate the size of a file + * + * @fd: File descriptor as returned by os_open() + * Return: file size or negative error code + */ +int os_filesize(int fd); + /** * Access to the OS open() system call * -- cgit v1.3.1