summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-07-05 18:02:09 +0200
committerSascha Hauer <sha@octopus.labnet.pengutronix.de>2007-07-05 18:02:09 +0200
commite2f1a28306b6fa228c8da9288bd849c08cbbd590 (patch)
treeb5f49dddf5937be5e6c9e9cf4802762fc29114f8 /fs
parent9d0f3063a7c6e49e8a009cd3ad584083227ff1cc (diff)
downloadbarebox-e2f1a28306b6fa228c8da9288bd849c08cbbd590.tar.gz
barebox-e2f1a28306b6fa228c8da9288bd849c08cbbd590.tar.xz
svn_rev_605
make read_file global
Diffstat (limited to 'fs')
-rw-r--r--fs/fs.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/fs/fs.c b/fs/fs.c
index 6165141426..5cee5a7691 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -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;