On legacy systems, if "/proc/mtd" doesn't exist or gives a read error,
mtd_dev_present returns -1 (since it calls legacy_dev_present), contrary
to what's specified in the header file.
This causes checks like
if (mtd_dev_present(n)) {
...
}
to give false positives. Fix this by comparing the return value to 1.
Signed-off-by: Guido MartÃnez <guido@vanguardiasur.com.ar>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
struct stat st;
struct libmtd *lib = (struct libmtd *)desc;
- if (!lib->sysfs_supported)
- return legacy_dev_present(mtd_num);
- else {
+ if (!lib->sysfs_supported) {
+ return legacy_dev_present(mtd_num) == 1;
+ } else {
char file[strlen(lib->mtd) + 10];
sprintf(file, lib->mtd, mtd_num);