diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2007-07-05 18:02:09 +0200 |
---|---|---|
committer | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-07-05 18:02:09 +0200 |
commit | e2f1a28306b6fa228c8da9288bd849c08cbbd590 (patch) | |
tree | b5f49dddf5937be5e6c9e9cf4802762fc29114f8 /fs | |
parent | 9d0f3063a7c6e49e8a009cd3ad584083227ff1cc (diff) | |
download | barebox-e2f1a28306b6fa228c8da9288bd849c08cbbd590.tar.gz barebox-e2f1a28306b6fa228c8da9288bd849c08cbbd590.tar.xz |
svn_rev_605
make read_file global
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fs.c | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -8,6 +8,34 @@ #include <xfuncs.h> #include <init.h> +void *read_file(const char *filename) +{ + int fd; + struct stat s; + void *buf = NULL; + + if (stat(filename, &s)) + return NULL; + + buf = xzalloc(s.st_size + 1); + + fd = open(filename, O_RDONLY); + if (fd < 0) + goto err_out; + + if (read(fd, buf, s.st_size) < s.st_size) + goto err_out1; + + close(fd); + return buf; + +err_out1: + close(fd); +err_out: + free(buf); + return NULL; +} + char *mkmodestr(unsigned long mode, char *str) { static const char *l = "xwr"; @@ -490,7 +518,7 @@ int mount(const char *device, const char *fsname, const char *path) int ret; errno = 0; - +printf("mount: %s on %s type %s\n", device, path, fsname); drv = get_driver_by_name(fsname); if (!drv) { errno = -ENODEV; |