9
0
Fork 0

ARM: omap: Use correct device to mount on /boot

The current code tests if a partition (i.e. disk0.0) exists and instead
of mounting boot from this partition it uses the whole device (disk0).
This only works because the the FAT code accepts a MBR as input and
automatically skips it.

Let the code use the partition to mount /boot instead as it was
intended. We don't have to stat() the partition device, since this
error will be caught by mount() anyway, so remove the unnecessary
stat().

Reported-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2015-11-10 08:58:16 +01:00
parent d9c2cfd534
commit 99c9da2817
1 changed files with 7 additions and 14 deletions

View File

@ -111,7 +111,6 @@ const char *omap_get_bootmmc_devname(void)
#define ENV_PATH "/boot/barebox.env"
static int omap_env_init(void)
{
struct stat s;
char *partname;
const char *diskdev;
int ret;
@ -128,25 +127,19 @@ static int omap_env_init(void)
partname = asprintf("/dev/%s.0", diskdev);
ret = stat(partname, &s);
free(partname);
if (ret) {
pr_err("Failed to load environment: no device '%s'\n", diskdev);
return 0;
}
mkdir("/boot", 0666);
ret = mount(diskdev, "fat", "/boot", NULL);
ret = mount(partname, "fat", "/boot", NULL);
if (ret) {
pr_err("Failed to load environment: mount %s failed (%d)\n", diskdev, ret);
return 0;
pr_err("Failed to load environment: mount %s failed (%d)\n", partname, ret);
goto out;
}
pr_debug("Loading default env from %s on device %s\n", ENV_PATH, diskdev);
pr_debug("Loading default env from %s on device %s\n", ENV_PATH, partname);
default_environment_path_set(ENV_PATH);
out:
free(partname);
return 0;
}
late_initcall(omap_env_init);