Skip to content

Commit

Permalink
fix some serious brokennes that prevented booting in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
zagto committed Jul 27, 2021
1 parent 307f551 commit 091edfc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/dtbootmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand All @@ -49,7 +49,7 @@ int main()

detectModel();

scanDisks(5);
scanDisks(3);


ui::mainLoop();
Expand Down
5 changes: 3 additions & 2 deletions src/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
7 changes: 6 additions & 1 deletion src/partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <dirent.h>
#include <sys/mount.h>
#include <iostream>
#include <unistd.h>

//#define DEBUG_SCAN 1

Expand All @@ -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"))
{
Expand All @@ -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");
}
}
}

Expand All @@ -70,6 +74,7 @@ void Partition::scan(std::vector<std::string> directories)
scanDir("/tmpmount/" + d);
}


if (umount("/tmpmount") != 0) {
std::cerr << "unable to unmount partition " << path << ": " << errno << std::endl;
while (1);
Expand Down

0 comments on commit 091edfc

Please sign in to comment.