Skip to content

Commit

Permalink
remove limitations on where DTB files are searched
Browse files Browse the repository at this point in the history
  • Loading branch information
zagto committed Apr 7, 2021
1 parent f4e02dc commit 7ec5f6a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/dtbootmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void scanDisks(int delay)
sleep(delay);
entries = {};

Partition("/dev/mmcblk0p8", true).scan({"media/0/boot"});
Partition("/dev/mmcblk0p8").scan({"media/0/boot"});

for (int disk = 1; fileExists("/dev/mmcblk" + to_string(disk)); disk++)
{
Expand All @@ -16,8 +16,8 @@ void scanDisks(int delay)

for (int disk = 0; fileExists((string)"/dev/sd" + (char)('a' + disk)); disk++)
{
Partition((string)"/dev/sd" + (char)('a' + (char)disk)).scan();
for (int part = 1; fileExists("/dev/sd" + (char)('a' + disk) + to_string(part)); part++)
Partition((string)"/dev/sd" + to_string('a' + (char)disk)).scan();
for (int part = 1; fileExists("/dev/sd" + to_string('a' + disk) + to_string(part)); part++)
Partition((string)"/dev/sd" + (char)('a' + disk) + to_string(part)).scan();
}
}
Expand All @@ -42,7 +42,7 @@ int main()

detectModel();

scanDisks(1);
scanDisks(5);


ui::mainLoop();
Expand Down
21 changes: 9 additions & 12 deletions src/partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,38 @@ void Partition::scanDir(string dirname)
while ((entry = readdir(dir)) != NULL)
{
string name = entry->d_name;
cout << "Found file " << entry->d_name << ".\n";
if (checkExtension(name, ".dtbootmenu"))
{
Entry entry = EntryFile(path, dirname, name).parse();
if (entry.isValid())
entries.push_back(entry);
}

if (override)
if (checkExtension(name, ".dtb"))
{
if (checkExtension(name, ".dtb"))
{
cout << "Unsing external " << name << " from " << path << ".\n";
saveFile("/" + name, loadFile(dirname + "/" + name));
}
cout << "Unsing external " << name << " from " << path << ".\n";
saveFile("/" + name, loadFile(dirname + "/" + name));
}
}
}
}

Partition::Partition(string _path, bool _override)
Partition::Partition(string _path)
{
path = _path;
override = _override;
}

void Partition::scan(vector<string> directories)
{
//cout << "Scanning " + path + "\n";
cout << "Scanning " + path + "\n";
if (mount(path.c_str(), "/tmpmount", "ext4", MS_RDONLY, "") == 0)
{
//cout << "Found supported file system on " + path + ".\n";
cout << "Found supported file system on " + path + ".\n";

for (string d: directories)
for (string &d: directories)
{
//cout << "Scanning " + d + " on " + path + "\n";
cout << "Scanning " + d + " on " + path + "\n";
scanDir("/tmpmount/" + d);
}

Expand Down
3 changes: 1 addition & 2 deletions src/partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ class Partition
{
private:
string path;
bool override;

void scanDir(string path);

public:
Partition(string _path = "", bool override = false);
Partition(string _path = "");
void scan(vector<string> directories = {"", "boot"});
};

Expand Down

0 comments on commit 7ec5f6a

Please sign in to comment.