blob: a55d5d77f4cf42e3025d9088c68dd9a22b63eb83 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/*
* Copyright (C) 2011 Sascha Hauer, Pengutronix
* Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
*
* Under GPLv2
*/
#include <common.h>
#include <fs.h>
#include <fcntl.h>
#include <linux/sizes.h>
#include <errno.h>
#include <malloc.h>
#include <libfile.h>
#include <bootstrap.h>
void* bootstrap_read_disk(const char *dev, const char *fstype)
{
int ret;
void *buf;
int len;
const char *path = "/";
ret = mount(dev, fstype, path, NULL);
if (ret) {
bootstrap_err("mounting %s failed with %d\n", dev, ret);
return NULL;
}
buf = read_file("/barebox.bin", &len);
if (!buf) {
bootstrap_err("could not read barebox.bin from %s\n", dev);
umount(path);
return NULL;
}
return buf;
}
|