diff --git a/src/dtbootmenu.cpp b/src/dtbootmenu.cpp index 2009c60..5e2ed87 100644 --- a/src/dtbootmenu.cpp +++ b/src/dtbootmenu.cpp @@ -21,11 +21,11 @@ void scanDisks(int delay) Partition("/dev/mmcblk" + std::to_string(disk) + "p" + std::to_string(part)).scan(); } - for (int disk = 0; fileExists("/dev/sd" + (char)('a' + disk)); disk++) + for (int disk = 0; fileExists("/dev/sd" + std::string(1, 'a' + disk)); disk++) { - Partition("/dev/sd" + std::to_string('a' + (char)disk)).scan(); - for (int part = 1; fileExists("/dev/sd" + std::to_string('a' + disk) + std::to_string(part)); part++) - Partition("/dev/sd" + std::to_string('a' + disk) + std::to_string(part)).scan(); + Partition("/dev/sd" + std::string(1, 'a' + disk)).scan(); + for (int part = 1; fileExists("/dev/sd" + std::string(1, 'a' + disk) + std::to_string(part)); part++) + Partition("/dev/sd" + std::string(1, 'a' + disk) + std::to_string(part)).scan(); } } @@ -49,7 +49,7 @@ int main() detectModel(); - scanDisks(5); + scanDisks(3); ui::mainLoop(); diff --git a/src/entry.cpp b/src/entry.cpp index 78c7996..5537392 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -24,12 +24,13 @@ Entry::Entry(std::string partition, std::string title, std::string zImage, std:: legacy{true}, title{title + " (legacy, on " + partition + ")"}, zImage{zImage}, - initrd{initrd} {} + initrd{initrd}, + partition{partition} {} void Entry::run() { if (mount(partition.c_str(), "/tmpmount", "ext4", MS_RDONLY, "") != 0) { - std::cerr << "Unable to mount paritition" << partition << ": " << errno << std::endl; + std::cerr << "Unable to mount paritition '" << partition << "': " << errno << std::endl; while(1); } diff --git a/src/partition.cpp b/src/partition.cpp index 1bc89a0..5522a58 100644 --- a/src/partition.cpp +++ b/src/partition.cpp @@ -4,6 +4,7 @@ #include #include #include +#include //#define DEBUG_SCAN 1 @@ -30,7 +31,7 @@ void Partition::scanDir(std::string dirname) { std::string name = entry->d_name; #ifdef DEBUG_SCAN - cout << "Found file " << entry->d_name << ".\n"; + std::cout << "Found file " << entry->d_name << ".\n"; #endif if (checkExtension(name, ".dtbootmenu")) { @@ -45,6 +46,9 @@ void Partition::scanDir(std::string dirname) saveFile("/" + name, loadFile(dirname + "/" + name)); } } + if (closedir(dir) != 0) { + throw std::runtime_error("closedir failed"); + } } } @@ -70,6 +74,7 @@ void Partition::scan(std::vector directories) scanDir("/tmpmount/" + d); } + if (umount("/tmpmount") != 0) { std::cerr << "unable to unmount partition " << path << ": " << errno << std::endl; while (1);