diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-07-30 10:54:16 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-08-07 06:13:52 +0200 |
commit | 28ce918d96f5de657e88eb54f87edf441ab2caa5 (patch) | |
tree | 18dd5a0bcdcbf3f41591e100949341813e8f20bb /include/libfile.h | |
parent | 3cfa4bc00c61eca4c0986c793dd21b8b5271fd8f (diff) | |
download | barebox-28ce918d96f5de657e88eb54f87edf441ab2caa5.tar.gz barebox-28ce918d96f5de657e88eb54f87edf441ab2caa5.tar.xz |
read_file: introduce read_file_2
read_file has some limitations:
- It is not possible to check the error code since read_file returns
NULL for failure
- It is not possible to limit the buffer size to sensible limits.
This patch introduces read_file_2 which doesn't have these limitations.
read_file becomes a wrapper around read_file_2.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/libfile.h')
-rw-r--r-- | include/libfile.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/libfile.h b/include/libfile.h index d47a11198c..4a25a9153c 100644 --- a/include/libfile.h +++ b/include/libfile.h @@ -8,6 +8,9 @@ char *read_file_line(const char *fmt, ...); void *read_file(const char *filename, size_t *size); +int read_file_2(const char *filename, size_t *size, void **outbuf, + loff_t max_size); + int write_file(const char *filename, void *buf, size_t size); int copy_file(const char *src, const char *dst, int verbose); |