From 99c9da2817ba1bcc3d33782e68ec6ceeeb2c4545 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 10 Nov 2015 08:58:16 +0100 Subject: 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 Signed-off-by: Sascha Hauer --- arch/arm/mach-omap/omap_generic.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-omap/omap_generic.c b/arch/arm/mach-omap/omap_generic.c index 071a1bfced..4e26c6ba0b 100644 --- a/arch/arm/mach-omap/omap_generic.c +++ b/arch/arm/mach-omap/omap_generic.c @@ -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); -- cgit v1.2.3