mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
linux_mtd: Bail out early if sysfs node doesn't exist
This checks that the MTD sysfs node we will use actually exists prior to calling setup code. Although the setup code will eventually catch such an error, we need to think about the use case before printing a possibly irrelevant/confusing error message to the terminal. This patch makes it so that we only print an error message if the user specifies a non-existent MTD device. Otherwise, the failure is considered benign and we only print a debug message prior to bailing out. Change-Id: I8dc965eecc68cd305a989016869c688fe1a3921f Signed-off-by: David Hendricks <dhendricks@fb.com> Reviewed-on: https://review.coreboot.org/26500 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
parent
a75a2edc05
commit
b0247b3acb
18
linux_mtd.c
18
linux_mtd.c
@ -376,6 +376,24 @@ int linux_mtd_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If user specified the MTD device number then error out if it doesn't
|
||||||
|
* appear to exist. Otherwise assume the error is benign and print a
|
||||||
|
* debug message. Bail out in either case.
|
||||||
|
*/
|
||||||
|
char sysfs_path[32];
|
||||||
|
if (snprintf(sysfs_path, sizeof(sysfs_path), "%s/mtd%d", LINUX_MTD_SYSFS_ROOT, dev_num) < 0)
|
||||||
|
goto linux_mtd_init_exit;
|
||||||
|
|
||||||
|
struct stat s;
|
||||||
|
if (stat(sysfs_path, &s) < 0) {
|
||||||
|
if (param)
|
||||||
|
msg_perr("%s does not exist\n", sysfs_path);
|
||||||
|
else
|
||||||
|
msg_pdbg("%s does not exist\n", sysfs_path);
|
||||||
|
goto linux_mtd_init_exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (linux_mtd_setup(dev_num))
|
if (linux_mtd_setup(dev_num))
|
||||||
goto linux_mtd_init_exit;
|
goto linux_mtd_init_exit;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user