diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-01-11 17:38:52 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-01-19 11:48:17 +0100 |
commit | a886dac94e8466c640e4aa23e1629467a941f439 (patch) | |
tree | 66a68fa07c3972d164b00a84da24add93e1a1c75 /fs | |
parent | 555dc6cc608632a3edd159fae59d13021540aa9e (diff) | |
download | barebox-a886dac94e8466c640e4aa23e1629467a941f439.tar.gz barebox-a886dac94e8466c640e4aa23e1629467a941f439.tar.xz |
Add write_file function
write_file() will write a buffer to a file. The file is created
if necessary.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fs.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -67,6 +67,25 @@ err_out: EXPORT_SYMBOL(read_file); +int write_file(const char *filename, void *buf, size_t size) +{ + int fd, ret; + + fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT); + if (fd < 0) + return fd; + + ret = write_full(fd, buf, size); + + close(fd); + + if (ret < 0) + return ret; + + return 0; +} +EXPORT_SYMBOL(write_file); + char *mkmodestr(unsigned long mode, char *str) { static const char *l = "xwr"; |