| 216 | } |
| 217 | |
| 218 | bool CLI::handleModifications() |
| 219 | { |
| 220 | QEFIEntryStaticList *list = QEFIEntryStaticList::instance(); |
| 221 | bool modified = false; |
| 222 | bool quiet = m_parser.isSet("quiet"); |
| 223 | QTextStream out(stdout); |
| 224 | QTextStream err(stderr); |
| 225 | |
| 226 | // Handle delete bootnum |
| 227 | if (m_parser.isSet("delete-bootnum")) { |
| 228 | if (!m_parser.isSet("bootnum")) { |
| 229 | err << "Error: --delete-bootnum requires --bootnum" << Qt::endl; |
| 230 | return false; |
| 231 | } |
| 232 | |
| 233 | QString bootnumStr = m_parser.value("bootnum"); |
| 234 | bool ok; |
| 235 | quint16 bootnum = bootnumStr.toUShort(&ok, 16); |
| 236 | if (!ok) { |
| 237 | err << "Error: Invalid bootnum format" << Qt::endl; |
| 238 | return false; |
| 239 | } |
| 240 | |
| 241 | // Delete by setting empty data |
| 242 | QString name = QStringLiteral("Boot%1").arg(bootnum, 4, 16, QLatin1Char('0')); |
| 243 | qefi_set_variable(g_efiUuid, name, QByteArray()); |
| 244 | |
| 245 | // Remove from boot order |
| 246 | QList<quint16> order = list->order(); |
| 247 | order.removeAll(bootnum); |
| 248 | list->setBootOrder(order); |
| 249 | |
| 250 | if (!quiet) { |
| 251 | out << "Deleted Boot" << QString::number(bootnum, 16).rightJustified(4, '0').toUpper() << Qt::endl; |
| 252 | } |
| 253 | modified = true; |
| 254 | } |
| 255 | |
| 256 | // Handle active/inactive |
| 257 | if (m_parser.isSet("active") || m_parser.isSet("inactive")) { |
| 258 | if (!m_parser.isSet("bootnum")) { |
| 259 | err << "Error: --active/--inactive requires --bootnum" << Qt::endl; |
| 260 | return false; |
| 261 | } |
| 262 | |
| 263 | if (m_parser.isSet("active") && m_parser.isSet("inactive")) { |
| 264 | err << "Error: Cannot specify both --active and --inactive" << Qt::endl; |
| 265 | return false; |
| 266 | } |
| 267 | |
| 268 | QString bootnumStr = m_parser.value("bootnum"); |
| 269 | bool ok; |
| 270 | quint16 bootnum = bootnumStr.toUShort(&ok, 16); |
| 271 | if (!ok) { |
| 272 | err << "Error: Invalid bootnum format" << Qt::endl; |
| 273 | return false; |
| 274 | } |
| 275 |
nothing calls this directly
no test coverage detected