From 560961ee2a8044537147b4cebdbfd0de13ccaa58 Mon Sep 17 00:00:00 2001 From: Murai Takashi Date: Wed, 12 Aug 2020 12:04:20 +0900 Subject: [PATCH] Bootloader: replace blacklist with blocklist Various projects, both commercial and OSS, began to use inclusive terminology. There is no reason to not do it. In Haiku, bootloader uses Blacklist, which is recommended to replace with Denylist or Blocklist. I think Blocklist is appropriate here, since it's a list used to block offending driver at boot. Some strings remain unchanged for compatibility with previous naming, but this change prepares for later removal of these (once everyone has updated their kernel and bootloader). Change-Id: Id9105ff5e9fcb866000355089b5ef97bf63ee854 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3145 Reviewed-by: Adrien Destugues --- .../boot/{PathBlacklist.h => PathBlocklist.h} | 24 ++-- .../packagefs/package/Package.cpp | 6 +- .../packagefs/volume/PackageSettings.cpp | 13 +- .../packagefs/volume/PackageSettings.h | 14 +- src/system/boot/loader/Jamfile | 2 +- .../{PathBlacklist.cpp => PathBlocklist.cpp} | 62 ++++----- .../packagefs/PackageSettingsItem.cpp | 6 +- .../packagefs/PackageSettingsItem.h | 14 +- .../file_systems/packagefs/packagefs.cpp | 14 +- .../loader/file_systems/packagefs/packagefs.h | 6 +- src/system/boot/loader/main.cpp | 12 +- src/system/boot/loader/menu.cpp | 130 ++++++++++-------- src/system/boot/loader/menu.h | 4 +- 13 files changed, 162 insertions(+), 145 deletions(-) rename headers/private/kernel/boot/{PathBlacklist.h => PathBlocklist.h} (66%) rename src/system/boot/loader/{PathBlacklist.cpp => PathBlocklist.cpp} (60%) diff --git a/headers/private/kernel/boot/PathBlacklist.h b/headers/private/kernel/boot/PathBlocklist.h similarity index 66% rename from headers/private/kernel/boot/PathBlacklist.h rename to headers/private/kernel/boot/PathBlocklist.h index 851a785ca5..dc92c30db1 100644 --- a/headers/private/kernel/boot/PathBlacklist.h +++ b/headers/private/kernel/boot/PathBlocklist.h @@ -2,8 +2,8 @@ * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ -#ifndef KERNEL_BOOT_PATH_BLACKLIST_H -#define KERNEL_BOOT_PATH_BLACKLIST_H +#ifndef KERNEL_BOOT_PATH_BLOCKLIST_H +#define KERNEL_BOOT_PATH_BLOCKLIST_H #include @@ -11,10 +11,10 @@ #include -class BlacklistedPath : public SinglyLinkedListLinkImpl { +class BlockedPath : public SinglyLinkedListLinkImpl { public: - BlacklistedPath(); - ~BlacklistedPath(); + BlockedPath(); + ~BlockedPath(); bool SetTo(const char* path); @@ -39,13 +39,13 @@ private: }; -class PathBlacklist { +class PathBlocklist { public: - typedef SinglyLinkedList::Iterator Iterator; + typedef SinglyLinkedList::Iterator Iterator; public: - PathBlacklist(); - ~PathBlacklist(); + PathBlocklist(); + ~PathBlocklist(); bool Add(const char* path); void Remove(const char* path); @@ -59,14 +59,14 @@ public: { return fPaths.GetIterator(); } private: - BlacklistedPath* _FindPath(const char* path) const; + BlockedPath* _FindPath(const char* path) const; private: - typedef SinglyLinkedList PathList; + typedef SinglyLinkedList PathList; private: PathList fPaths; }; -#endif // KERNEL_BOOT_PATH_BLACKLIST_H +#endif // KERNEL_BOOT_PATH_BLOCKLIST_H diff --git a/src/add-ons/kernel/file_systems/packagefs/package/Package.cpp b/src/add-ons/kernel/file_systems/packagefs/package/Package.cpp index bcb34e18a6..f5a714edfb 100644 --- a/src/add-ons/kernel/file_systems/packagefs/package/Package.cpp +++ b/src/add-ons/kernel/file_systems/packagefs/package/Package.cpp @@ -108,7 +108,7 @@ struct Package::LoaderContentHandler : BPackageContentHandler { { if (fErrorOccurred || (fLastSettingsEntry != NULL - && fLastSettingsEntry->IsBlackListed())) { + && fLastSettingsEntry->IsBlocked())) { return B_OK; } @@ -128,7 +128,7 @@ struct Package::LoaderContentHandler : BPackageContentHandler { if (settingsEntry != NULL) { fLastSettingsEntry = settingsEntry; fLastSettingsEntryEntry = entry; - if (fLastSettingsEntry->IsBlackListed()) + if (fLastSettingsEntry->IsBlocked()) return B_OK; } } @@ -191,7 +191,7 @@ struct Package::LoaderContentHandler : BPackageContentHandler { { if (fErrorOccurred || (fLastSettingsEntry != NULL - && fLastSettingsEntry->IsBlackListed())) { + && fLastSettingsEntry->IsBlocked())) { return B_OK; } diff --git a/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.cpp b/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.cpp index e7889f6a07..10d8f77ebf 100644 --- a/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.cpp +++ b/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.cpp @@ -16,7 +16,8 @@ #include "DebugSupport.h" -static const char* const kEntryBlacklistParameterName = "EntryBlacklist"; +static const char* const kBlockedEntriesParameterName = "BlockedEntries"; +static const char* const kLegacyBlockedEntriesParameterName = "EntryBlacklist"; // #pragma mark - PackageSettingsItem @@ -56,10 +57,12 @@ PackageSettingsItem::ApplySettings(const driver_parameter* parameters, { for (int i = 0; i < parameterCount; i++) { const driver_parameter& subParameter = parameters[i]; - if (strcmp(subParameter.name, kEntryBlacklistParameterName) != 0) + if (strcmp(subParameter.name, kBlockedEntriesParameterName) != 0 + && strcmp(subParameter.name, kLegacyBlockedEntriesParameterName) + != 0) continue; - status_t error = _AddBlackListedEntries(subParameter); + status_t error = _AddBlockedEntries(subParameter); // abort only in case of serious issues (memory shortage) if (error == B_NO_MEMORY) return error; @@ -130,7 +133,7 @@ PackageSettingsItem::FindEntry(Entry* parent, const char* name) const status_t -PackageSettingsItem::_AddBlackListedEntries(const driver_parameter& parameter) +PackageSettingsItem::_AddBlockedEntries(const driver_parameter& parameter) { for (int i = 0; i < parameter.parameter_count; i++) { Entry* entry; @@ -139,7 +142,7 @@ PackageSettingsItem::_AddBlackListedEntries(const driver_parameter& parameter) if (error == B_NO_MEMORY) return error; - entry->SetBlackListed(true); + entry->SetBlocked(true); } return B_OK; diff --git a/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.h b/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.h index eea56e1271..f5b5c5fb58 100644 --- a/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.h +++ b/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.h @@ -23,7 +23,7 @@ public: : fParent(parent), fName(name), - fIsBlackListed(false) + fIsBlocked(false) { } @@ -37,14 +37,14 @@ public: return fName; } - bool IsBlackListed() const + bool IsBlocked() const { - return fIsBlackListed; + return fIsBlocked; } - void SetBlackListed(bool blackListed) + void SetBlocked(bool blocked) { - fIsBlackListed = blackListed; + fIsBlocked = blocked; } Entry*& HashNext() @@ -55,7 +55,7 @@ public: private: Entry* fParent; String fName; - bool fIsBlackListed; + bool fIsBlocked; Entry* fHashNext; }; @@ -150,7 +150,7 @@ private: typedef BOpenHashTable EntryTable; private: - status_t _AddBlackListedEntries( + status_t _AddBlockedEntries( const driver_parameter& parameter); private: diff --git a/src/system/boot/loader/Jamfile b/src/system/boot/loader/Jamfile index 81d06d3113..a1bc9e7651 100644 --- a/src/system/boot/loader/Jamfile +++ b/src/system/boot/loader/Jamfile @@ -104,7 +104,7 @@ for platform in [ MultiBootSubDirSetup ] { BootStaticLibrary [ MultiBootGristFiles boot_loader ] : - PathBlacklist.cpp + PathBlocklist.cpp elf.cpp heap.cpp kernel_args.cpp diff --git a/src/system/boot/loader/PathBlacklist.cpp b/src/system/boot/loader/PathBlocklist.cpp similarity index 60% rename from src/system/boot/loader/PathBlacklist.cpp rename to src/system/boot/loader/PathBlocklist.cpp index 82822ccf86..9ef5e957c3 100644 --- a/src/system/boot/loader/PathBlacklist.cpp +++ b/src/system/boot/loader/PathBlocklist.cpp @@ -4,17 +4,17 @@ */ -#include +#include #include #include -// #pragma mark - BlacklistedPath +// #pragma mark - BlockedPath -BlacklistedPath::BlacklistedPath() +BlockedPath::BlockedPath() : fPath(NULL), fLength(0), @@ -23,14 +23,14 @@ BlacklistedPath::BlacklistedPath() } -BlacklistedPath::~BlacklistedPath() +BlockedPath::~BlockedPath() { free(fPath); } bool -BlacklistedPath::SetTo(const char* path) +BlockedPath::SetTo(const char* path) { size_t length = strlen(path); if (length > 0 && path[length - 1] == '/') @@ -49,7 +49,7 @@ BlacklistedPath::SetTo(const char* path) bool -BlacklistedPath::Append(const char* component) +BlockedPath::Append(const char* component) { size_t componentLength = strlen(component); if (componentLength > 0 && component[componentLength - 1] == '/') @@ -70,7 +70,7 @@ BlacklistedPath::Append(const char* component) bool -BlacklistedPath::_Resize(size_t length, bool keepData) +BlockedPath::_Resize(size_t length, bool keepData) { if (length == 0) { free(fPath); @@ -109,71 +109,71 @@ BlacklistedPath::_Resize(size_t length, bool keepData) } -// #pragma mark - PathBlacklist +// #pragma mark - PathBlocklist -PathBlacklist::PathBlacklist() +PathBlocklist::PathBlocklist() { } -PathBlacklist::~PathBlacklist() +PathBlocklist::~PathBlocklist() { MakeEmpty(); } bool -PathBlacklist::Add(const char* path) +PathBlocklist::Add(const char* path) { - BlacklistedPath* blacklistedPath = _FindPath(path); - if (blacklistedPath != NULL) + BlockedPath* blockedPath = _FindPath(path); + if (blockedPath != NULL) return true; - blacklistedPath = new(std::nothrow) BlacklistedPath; - if (blacklistedPath == NULL || !blacklistedPath->SetTo(path)) { - delete blacklistedPath; + blockedPath = new(std::nothrow) BlockedPath; + if (blockedPath == NULL || !blockedPath->SetTo(path)) { + delete blockedPath; return false; } - fPaths.Add(blacklistedPath); + fPaths.Add(blockedPath); return true; } void -PathBlacklist::Remove(const char* path) +PathBlocklist::Remove(const char* path) { - BlacklistedPath* blacklistedPath = _FindPath(path); - if (blacklistedPath != NULL) { - fPaths.Remove(blacklistedPath); - delete blacklistedPath; + BlockedPath* blockedPath = _FindPath(path); + if (blockedPath != NULL) { + fPaths.Remove(blockedPath); + delete blockedPath; } } bool -PathBlacklist::Contains(const char* path) const +PathBlocklist::Contains(const char* path) const { return _FindPath(path) != NULL; } void -PathBlacklist::MakeEmpty() +PathBlocklist::MakeEmpty() { - while (BlacklistedPath* blacklistedPath = fPaths.RemoveHead()) - delete blacklistedPath; + while (BlockedPath* blockedPath = fPaths.RemoveHead()) + delete blockedPath; } -BlacklistedPath* -PathBlacklist::_FindPath(const char* path) const +BlockedPath* +PathBlocklist::_FindPath(const char* path) const { for (PathList::Iterator it = fPaths.GetIterator(); it.HasNext();) { - BlacklistedPath* blacklistedPath = it.Next(); - if (*blacklistedPath == path) - return blacklistedPath; + BlockedPath* blockedPath = it.Next(); + if (*blockedPath == path) + return blockedPath; } return NULL; diff --git a/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.cpp b/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.cpp index 771c8f9ebd..85e9f4be38 100644 --- a/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.cpp +++ b/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.cpp @@ -90,7 +90,7 @@ PackageSettingsItem::Init(const driver_parameter& parameter) if (strcmp(subParameter.name, "EntryBlacklist") != 0) continue; - status_t error = _AddBlackListedEntries(subParameter); + status_t error = _AddBlockedEntries(subParameter); // abort only in case of serious issues (memory shortage) if (error == B_NO_MEMORY) return error; @@ -163,7 +163,7 @@ PackageSettingsItem::FindEntry(Entry* parent, const char* name, status_t -PackageSettingsItem::_AddBlackListedEntries(const driver_parameter& parameter) +PackageSettingsItem::_AddBlockedEntries(const driver_parameter& parameter) { for (int i = 0; i < parameter.parameter_count; i++) { Entry* entry; @@ -172,7 +172,7 @@ PackageSettingsItem::_AddBlackListedEntries(const driver_parameter& parameter) if (error == B_NO_MEMORY) return error; - entry->SetBlackListed(true); + entry->SetBlocked(true); } return B_OK; diff --git a/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.h b/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.h index 3a0b6bbba9..bc874d6350 100644 --- a/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.h +++ b/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.h @@ -27,7 +27,7 @@ public: : fParent(parent), fName(NULL), - fIsBlackListed(false), + fIsBlocked(false), fHashNext(NULL) { } @@ -58,14 +58,14 @@ public: return fName; } - bool IsBlackListed() const + bool IsBlocked() const { - return fIsBlackListed; + return fIsBlocked; } - void SetBlackListed(bool blackListed) + void SetBlocked(bool blocked) { - fIsBlackListed = blackListed; + fIsBlocked = blocked; } Entry*& HashNext() @@ -76,7 +76,7 @@ public: private: Entry* fParent; char* fName; - bool fIsBlackListed; + bool fIsBlocked; Entry* fHashNext; }; @@ -176,7 +176,7 @@ private: typedef BOpenHashTable EntryTable; private: - status_t _AddBlackListedEntries( + status_t _AddBlockedEntries( const driver_parameter& parameter); private: diff --git a/src/system/boot/loader/file_systems/packagefs/packagefs.cpp b/src/system/boot/loader/file_systems/packagefs/packagefs.cpp index a7f37c6608..9177b0feef 100644 --- a/src/system/boot/loader/file_systems/packagefs/packagefs.cpp +++ b/src/system/boot/loader/file_systems/packagefs/packagefs.cpp @@ -24,7 +24,7 @@ #include -#include +#include #include #include "PackageSettingsItem.h" @@ -390,7 +390,7 @@ struct PackageLoaderContentHandler : BPackageContentHandler { { if (fErrorOccurred || (fLastSettingsEntry != NULL - && fLastSettingsEntry->IsBlackListed())) { + && fLastSettingsEntry->IsBlocked())) { return B_OK; } @@ -411,7 +411,7 @@ struct PackageLoaderContentHandler : BPackageContentHandler { if (settingsEntry != NULL) { fLastSettingsEntry = settingsEntry; fLastSettingsEntryEntry = entry; - if (fLastSettingsEntry->IsBlackListed()) + if (fLastSettingsEntry->IsBlocked()) return B_OK; } } @@ -885,14 +885,14 @@ packagefs_mount_file(int fd, ::Directory* systemDirectory, void -packagefs_apply_path_blacklist(::Directory* systemDirectory, - const PathBlacklist& pathBlacklist) +packagefs_apply_path_blocklist(::Directory* systemDirectory, + const PathBlocklist& pathBlocklist) { PackageFS::Directory* directory = static_cast(systemDirectory); - for (PathBlacklist::Iterator it = pathBlacklist.GetIterator(); - BlacklistedPath* path = it.Next();) { + for (PathBlocklist::Iterator it = pathBlocklist.GetIterator(); + BlockedPath* path = it.Next();) { directory->RemoveEntry(path->Path()); } } diff --git a/src/system/boot/loader/file_systems/packagefs/packagefs.h b/src/system/boot/loader/file_systems/packagefs/packagefs.h index be51060c68..12819ae905 100644 --- a/src/system/boot/loader/file_systems/packagefs/packagefs.h +++ b/src/system/boot/loader/file_systems/packagefs/packagefs.h @@ -11,7 +11,7 @@ #include -class PathBlacklist; +class PathBlocklist; class Directory; class Node; @@ -19,8 +19,8 @@ class Node; status_t packagefs_mount_file(int fd, Directory* systemDirectory, Directory*& _mountedDirectory); -void packagefs_apply_path_blacklist(Directory* systemDirectory, - const PathBlacklist& pathBlacklist); +void packagefs_apply_path_blocklist(Directory* systemDirectory, + const PathBlocklist& pathBlocklist); #endif // BOOT_LOADER_FILE_SYSTEMS_PACKAGEFS_H diff --git a/src/system/boot/loader/main.cpp b/src/system/boot/loader/main.cpp index cf470e8f0c..85c5466a26 100644 --- a/src/system/boot/loader/main.cpp +++ b/src/system/boot/loader/main.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -62,7 +62,7 @@ main(stage2_args *args) bool mountedAllVolumes = false; BootVolume bootVolume; - PathBlacklist pathBlacklist; + PathBlocklist pathBlocklist; if (get_boot_file_system(args, bootVolume) != B_OK || (platform_boot_options() & BOOT_OPTION_MENU) != 0) { @@ -79,7 +79,7 @@ main(stage2_args *args) mountedAllVolumes = true; - if (user_menu(bootVolume, pathBlacklist) < B_OK) { + if (user_menu(bootVolume, pathBlocklist) < B_OK) { // user requested to quit the loader goto out; } @@ -103,7 +103,7 @@ main(stage2_args *args) mountedAllVolumes = true; } - if (user_menu(bootVolume, pathBlacklist) != B_OK + if (user_menu(bootVolume, pathBlocklist) != B_OK || !bootVolume.IsValid()) { // user requested to quit the loader goto out; @@ -115,8 +115,8 @@ main(stage2_args *args) // know our boot volume, too if (status == B_OK) { if (bootVolume.IsPackaged()) { - packagefs_apply_path_blacklist(bootVolume.SystemDirectory(), - pathBlacklist); + packagefs_apply_path_blocklist(bootVolume.SystemDirectory(), + pathBlocklist); } register_boot_file_system(bootVolume); diff --git a/src/system/boot/loader/menu.cpp b/src/system/boot/loader/menu.cpp index 3ae809bbf1..2f23d08eb1 100644 --- a/src/system/boot/loader/menu.cpp +++ b/src/system/boot/loader/menu.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -46,9 +46,9 @@ // only set while in user_menu() static Menu* sMainMenu = NULL; -static Menu* sBlacklistRootMenu = NULL; +static Menu* sBlocklistRootMenu = NULL; static BootVolume* sBootVolume = NULL; -static PathBlacklist* sPathBlacklist; +static PathBlocklist* sPathBlocklist; MenuItem::MenuItem(const char *label, Menu *subMenu) @@ -518,12 +518,12 @@ size_to_string(off_t size, char* buffer, size_t bufferSize) } -// #pragma mark - blacklist menu +// #pragma mark - blocklist menu -class BlacklistMenuItem : public MenuItem { +class BlocklistMenuItem : public MenuItem { public: - BlacklistMenuItem(char* label, Node* node, Menu* subMenu) + BlocklistMenuItem(char* label, Node* node, Menu* subMenu) : MenuItem(label, subMenu), fNode(node), @@ -533,7 +533,7 @@ public: SetType(MENU_ITEM_MARKABLE); } - ~BlacklistMenuItem() + ~BlocklistMenuItem() { fNode->Release(); @@ -546,12 +546,12 @@ public: return fNode->Type() == S_IFDIR; } - bool GetPath(BlacklistedPath& _path) const + bool GetPath(BlockedPath& _path) const { Menu* menu = Supermenu(); - if (menu != NULL && menu != sBlacklistRootMenu + if (menu != NULL && menu != sBlocklistRootMenu && menu->Superitem() != NULL) { - return static_cast(menu->Superitem()) + return static_cast(menu->Superitem()) ->GetPath(_path) && _path.Append(Label()); } @@ -559,11 +559,11 @@ public: return _path.SetTo(Label()); } - void UpdateBlacklisted() + void UpdateBlocked() { - BlacklistedPath path; + BlockedPath path; if (GetPath(path)) - _SetMarked(sPathBlacklist->Contains(path.Path()), false); + _SetMarked(sPathBlocklist->Contains(path.Path()), false); } virtual void SetMarked(bool marked) @@ -573,10 +573,10 @@ public: static bool Less(const MenuItem* a, const MenuItem* b) { - const BlacklistMenuItem* item1 - = static_cast(a); - const BlacklistMenuItem* item2 - = static_cast(b); + const BlocklistMenuItem* item1 + = static_cast(a); + const BlocklistMenuItem* item2 + = static_cast(b); // directories come first if (item1->IsDirectoryItem() != item2->IsDirectoryItem()) @@ -587,7 +587,7 @@ public: } private: - void _SetMarked(bool marked, bool updateBlacklist) + void _SetMarked(bool marked, bool updateBlocklist) { if (marked == IsMarked()) return; @@ -596,13 +596,13 @@ private: if (IsDirectoryItem()) SetSubmenu(marked ? NULL : fSubMenu); - if (updateBlacklist) { - BlacklistedPath path; + if (updateBlocklist) { + BlockedPath path; if (GetPath(path)) { if (marked) - sPathBlacklist->Add(path.Path()); + sPathBlocklist->Add(path.Path()); else - sPathBlacklist->Remove(path.Path()); + sPathBlocklist->Remove(path.Path()); } } @@ -615,16 +615,16 @@ private: }; -class BlacklistMenu : public Menu { +class BlocklistMenu : public Menu { public: - BlacklistMenu() + BlocklistMenu() : Menu(STANDARD_MENU, kDefaultMenuTitle), fDirectory(NULL) { } - ~BlacklistMenu() + ~BlocklistMenu() { SetDirectory(NULL); } @@ -638,19 +638,19 @@ public: if (fDirectory->Open(&cookie, O_RDONLY) == B_OK) { Node* node; while (fDirectory->GetNextNode(cookie, &node) == B_OK) { - BlacklistMenuItem* item = _CreateItem(node); + BlocklistMenuItem* item = _CreateItem(node); node->Release(); if (item == NULL) break; AddItem(item); - item->UpdateBlacklisted(); + item->UpdateBlocked(); } fDirectory->Close(cookie); } - SortItems(&BlacklistMenuItem::Less); + SortItems(&BlocklistMenuItem::Less); } if (CountItems() > 0) @@ -676,7 +676,7 @@ protected: } private: - static BlacklistMenuItem* _CreateItem(Node* node) + static BlocklistMenuItem* _CreateItem(Node* node) { // Get the node name and duplicate it, so we can use it as a label. char name[B_FILE_NAME_LENGTH]; @@ -689,17 +689,17 @@ private: strlcat(name, "/", sizeof(name)); // If this is a directory, create the submenu. - BlacklistMenu* subMenu = NULL; + BlocklistMenu* subMenu = NULL; if (isDirectory) { - subMenu = new(std::nothrow) BlacklistMenu; + subMenu = new(std::nothrow) BlocklistMenu; if (subMenu != NULL) subMenu->SetDirectory(static_cast(node)); } - ObjectDeleter subMenuDeleter(subMenu); + ObjectDeleter subMenuDeleter(subMenu); // create the menu item - BlacklistMenuItem* item = new(std::nothrow) BlacklistMenuItem(name, + BlocklistMenuItem* item = new(std::nothrow) BlocklistMenuItem(name, node, subMenu); if (item == NULL) return NULL; @@ -723,22 +723,22 @@ protected: }; -const char* const BlacklistMenu::kDefaultMenuTitle - = "Mark the entries to blacklist"; +const char* const BlocklistMenu::kDefaultMenuTitle + = "Mark the entries to blocklist"; -class BlacklistRootMenu : public BlacklistMenu { +class BlocklistRootMenu : public BlocklistMenu { public: - BlacklistRootMenu() + BlocklistRootMenu() : - BlacklistMenu() + BlocklistMenu() { } virtual void Entered() { // Get the system directory, but only if this is a packaged Haiku. - // Otherwise blacklisting isn't supported. + // Otherwise blocklisting isn't supported. if (sBootVolume != NULL && sBootVolume->IsValid() && sBootVolume->IsPackaged()) { SetDirectory(sBootVolume->SystemDirectory()); @@ -746,11 +746,11 @@ public: } else { SetDirectory(NULL); SetTitle(sBootVolume != NULL && sBootVolume->IsValid() - ? "The selected boot volume doesn't support blacklisting!" + ? "The selected boot volume doesn't support blocklisting!" : "No boot volume selected!"); } - BlacklistMenu::Entered(); + BlocklistMenu::Entered(); // rename last item if (MenuItem* item = ItemAt(CountItems() - 1)) @@ -759,7 +759,7 @@ public: virtual void Exited() { - BlacklistMenu::Exited(); + BlocklistMenu::Exited(); SetDirectory(NULL); } }; @@ -952,7 +952,7 @@ user_menu_boot_volume(Menu* menu, MenuItem* item) if (sBootVolume->IsValid() && sBootVolume->RootDirectory() == item->Data()) return true; - sPathBlacklist->MakeEmpty(); + sPathBlocklist->MakeEmpty(); status_t status = sBootVolume->SetTo((Directory*)item->Data()); update_continue_booting_menu_item(status); @@ -978,7 +978,7 @@ user_menu_boot_volume_state(Menu* menu, MenuItem* _item) volumeItem->Select(true); volumeItem->UpdateStateName(item->VolumeState()); - sPathBlacklist->MakeEmpty(); + sPathBlocklist->MakeEmpty(); status_t status = sBootVolume->SetTo((Directory*)item->Data(), item->VolumeInfo(), item->VolumeState()); @@ -1336,9 +1336,9 @@ add_safe_mode_menu() platform_add_menus(safeMenu); safeMenu->AddSeparatorItem(); - sBlacklistRootMenu = new(std::nothrow) BlacklistRootMenu; - safeMenu->AddItem(item = new(std::nothrow) MenuItem("Blacklist entries", - sBlacklistRootMenu)); + sBlocklistRootMenu = new(std::nothrow) BlocklistRootMenu; + safeMenu->AddItem(item = new(std::nothrow) MenuItem("Blocklist entries", + sBlocklistRootMenu)); item->SetHelpText("Allows to select system files that shall be ignored. " "Useful e.g. to disable drivers temporarily."); @@ -1542,15 +1542,29 @@ apply_safe_mode_options(Menu* menu) static void -apply_safe_mode_path_blacklist() +apply_safe_mode_path_blocklist() { - if (sPathBlacklist->IsEmpty()) + if (sPathBlocklist->IsEmpty()) return; - bool success = sSafeModeOptionsBuffer.Append("EntryBlacklist {\n"); + bool success = sSafeModeOptionsBuffer.Append("BlockedEntries {\n"); - for (PathBlacklist::Iterator it = sPathBlacklist->GetIterator(); - BlacklistedPath* path = it.Next();) { + for (PathBlocklist::Iterator it = sPathBlocklist->GetIterator(); + BlockedPath* path = it.Next();) { + success &= sSafeModeOptionsBuffer.Append(path->Path()); + success &= sSafeModeOptionsBuffer.Append("\n", 1); + } + + success &= sSafeModeOptionsBuffer.Append("}\n"); + + // Append the option a second time using the legacy name, so it also works + // for older kernel. + // TODO remove this after R1 beta3 is released and no one is using older + // kernels anymore. + success &= sSafeModeOptionsBuffer.Append("EntryBlacklist {\n"); + + for (PathBlocklist::Iterator it = sPathBlocklist->GetIterator(); + BlockedPath* path = it.Next();) { success &= sSafeModeOptionsBuffer.Append(path->Path()); success &= sSafeModeOptionsBuffer.Append("\n", 1); } @@ -1559,7 +1573,7 @@ apply_safe_mode_path_blacklist() if (!success) { dprintf("apply_safe_mode_options(): failed to append path " - "blacklist to buffer\n"); + "blocklist to buffer\n"); } } @@ -1573,14 +1587,14 @@ user_menu_reboot(Menu* menu, MenuItem* item) status_t -user_menu(BootVolume& _bootVolume, PathBlacklist& _pathBlacklist) +user_menu(BootVolume& _bootVolume, PathBlocklist& _pathBlocklist) { Menu* menu = new(std::nothrow) Menu(MAIN_MENU); sMainMenu = menu; sBootVolume = &_bootVolume; - sPathBlacklist = &_pathBlacklist; + sPathBlocklist = &_pathBlocklist; Menu* safeModeMenu = NULL; Menu* debugMenu = NULL; @@ -1621,7 +1635,7 @@ user_menu(BootVolume& _bootVolume, PathBlacklist& _pathBlacklist) apply_safe_mode_options(safeModeMenu); apply_safe_mode_options(debugMenu); - apply_safe_mode_path_blacklist(); + apply_safe_mode_path_blocklist(); add_safe_mode_settings(sSafeModeOptionsBuffer.String()); delete menu; @@ -1629,8 +1643,8 @@ user_menu(BootVolume& _bootVolume, PathBlacklist& _pathBlacklist) TRACE(("user_menu: leave\n")); sMainMenu = NULL; - sBlacklistRootMenu = NULL; + sBlocklistRootMenu = NULL; sBootVolume = NULL; - sPathBlacklist = NULL; + sPathBlocklist = NULL; return B_OK; } diff --git a/src/system/boot/loader/menu.h b/src/system/boot/loader/menu.h index bf2be20102..faabaa70fa 100644 --- a/src/system/boot/loader/menu.h +++ b/src/system/boot/loader/menu.h @@ -9,11 +9,11 @@ #include -class PathBlacklist; +class PathBlocklist; extern status_t user_menu(BootVolume& _bootVolume, - PathBlacklist& _pathBlacklist); + PathBlocklist& _pathBlocklist); #endif /* MENU_H */