Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Inokinoki/QEFIEntryManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Inokinoki committed Jul 3, 2021
2 parents d0204b4 + d89f176 commit 9c26f2d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
33 changes: 31 additions & 2 deletions qefientry.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#include "qefientry.h"

#include <QDebug>

extern "C" {
#include <efivar/efivar.h>
#include <efivar/efiboot-loadopt.h>
#include <efivar/efivar-dp.h>
}

QString QEFIEntry::name() const
{
return m_name;
Expand All @@ -10,9 +18,14 @@ quint16 QEFIEntry::id() const
return m_id;
}

QEFIEntry::QEFIEntry(quint16 id, QString name)
QString QEFIEntry::devicePath() const
{
m_id = id; m_name = name;
return m_devicePath;
}

QEFIEntry::QEFIEntry(quint16 id, QString name, QString devicePath)
{
m_id = id; m_name = name; m_devicePath = devicePath;
}

QEFIEntry::QEFIEntry(quint16 id, QByteArray boot_data)
Expand All @@ -29,6 +42,22 @@ QEFIEntry::QEFIEntry(quint16 id, QByteArray boot_data)
}
}
m_name = entry_name;

// TODO: Move these code to qefi, add support for Windows
char text_path[4096];
size_t text_path_len = 4096;
uint16_t pathlen;
ssize_t rc;
efidp dp = NULL;

efi_load_option *load_option = (efi_load_option *)boot_data.data();
pathlen = efi_loadopt_pathlen(load_option, boot_data.size());
dp = efi_loadopt_path(load_option, boot_data.size());
rc = efidp_format_device_path(text_path, text_path_len, dp, pathlen);
qDebug() << "[" << rc << "]" << text_path;
if (rc > 0) {
m_devicePath = QString(text_path);
}
}

QEFIEntry::QEFIEntry() {}
4 changes: 3 additions & 1 deletion qefientry.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ class QEFIEntry
{
quint16 m_id;
QString m_name;
QString m_devicePath;

// TODO: Parse more information
public:
QEFIEntry();
QEFIEntry(quint16 id, QString name);
QEFIEntry(quint16 id, QString name, QString m_devicePath);
QEFIEntry(quint16 id, QByteArray byteArrayFromEFIVar);
QString name() const;
quint16 id() const;
QString devicePath() const;
};

#endif // QEFIENTRY_H
2 changes: 1 addition & 1 deletion qefientryrebootview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ QEFIEntryRebootView::QEFIEntryRebootView(QWidget *parent)
m_rebootItemIndex = -1;
for (int i = 0; i < m_entryIds.size(); i++) {
QEFIEntry &entry = m_entryItems[m_entryIds[i]];
m_entries->addItem(QString::asprintf("[%04X] ", entry.id()) + entry.name());
m_entries->addItem(QString::asprintf("[%04X] ", entry.id()) + entry.name() + "\n" + entry.devicePath());
}
QObject::connect(m_entries, &QListWidget::currentRowChanged,
this, &QEFIEntryRebootView::entryChanged);
Expand Down
2 changes: 1 addition & 1 deletion qefientrystaticlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void QEFIEntryStaticList::load()
}

// Add entry
QEFIEntry entry(*order_num, entry_name);
QEFIEntry entry(*order_num, boot_data);
m_entries.insert(*order_num, entry);

// Cache
Expand Down
2 changes: 1 addition & 1 deletion qefientryview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ QEFIEntryView::QEFIEntryView(QWidget *parent)
for (int i = 0; i < m_order.size(); i++) {
if (m_entryItems.contains(m_order[i])) {
QEFIEntry &entry = m_entryItems[m_order[i]];
m_entries->addItem(QString::asprintf("[%04X] ", entry.id()) + entry.name());
m_entries->addItem(QString::asprintf("[%04X] ", entry.id()) + entry.name() + "\n" + entry.devicePath());
}
}
QObject::connect(m_entries, &QListWidget::currentRowChanged,
Expand Down

0 comments on commit 9c26f2d

Please sign in to comment.