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 <pulkomandy@gmail.com>
This commit is contained in:
Murai Takashi 2020-08-12 12:04:20 +09:00 committed by Adrien Destugues
parent a78899d40a
commit 560961ee2a
13 changed files with 162 additions and 145 deletions

View File

@ -2,8 +2,8 @@
* Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef KERNEL_BOOT_PATH_BLACKLIST_H #ifndef KERNEL_BOOT_PATH_BLOCKLIST_H
#define KERNEL_BOOT_PATH_BLACKLIST_H #define KERNEL_BOOT_PATH_BLOCKLIST_H
#include <string.h> #include <string.h>
@ -11,10 +11,10 @@
#include <util/SinglyLinkedList.h> #include <util/SinglyLinkedList.h>
class BlacklistedPath : public SinglyLinkedListLinkImpl<BlacklistedPath> { class BlockedPath : public SinglyLinkedListLinkImpl<BlockedPath> {
public: public:
BlacklistedPath(); BlockedPath();
~BlacklistedPath(); ~BlockedPath();
bool SetTo(const char* path); bool SetTo(const char* path);
@ -39,13 +39,13 @@ private:
}; };
class PathBlacklist { class PathBlocklist {
public: public:
typedef SinglyLinkedList<BlacklistedPath>::Iterator Iterator; typedef SinglyLinkedList<BlockedPath>::Iterator Iterator;
public: public:
PathBlacklist(); PathBlocklist();
~PathBlacklist(); ~PathBlocklist();
bool Add(const char* path); bool Add(const char* path);
void Remove(const char* path); void Remove(const char* path);
@ -59,14 +59,14 @@ public:
{ return fPaths.GetIterator(); } { return fPaths.GetIterator(); }
private: private:
BlacklistedPath* _FindPath(const char* path) const; BlockedPath* _FindPath(const char* path) const;
private: private:
typedef SinglyLinkedList<BlacklistedPath> PathList; typedef SinglyLinkedList<BlockedPath> PathList;
private: private:
PathList fPaths; PathList fPaths;
}; };
#endif // KERNEL_BOOT_PATH_BLACKLIST_H #endif // KERNEL_BOOT_PATH_BLOCKLIST_H

View File

@ -108,7 +108,7 @@ struct Package::LoaderContentHandler : BPackageContentHandler {
{ {
if (fErrorOccurred if (fErrorOccurred
|| (fLastSettingsEntry != NULL || (fLastSettingsEntry != NULL
&& fLastSettingsEntry->IsBlackListed())) { && fLastSettingsEntry->IsBlocked())) {
return B_OK; return B_OK;
} }
@ -128,7 +128,7 @@ struct Package::LoaderContentHandler : BPackageContentHandler {
if (settingsEntry != NULL) { if (settingsEntry != NULL) {
fLastSettingsEntry = settingsEntry; fLastSettingsEntry = settingsEntry;
fLastSettingsEntryEntry = entry; fLastSettingsEntryEntry = entry;
if (fLastSettingsEntry->IsBlackListed()) if (fLastSettingsEntry->IsBlocked())
return B_OK; return B_OK;
} }
} }
@ -191,7 +191,7 @@ struct Package::LoaderContentHandler : BPackageContentHandler {
{ {
if (fErrorOccurred if (fErrorOccurred
|| (fLastSettingsEntry != NULL || (fLastSettingsEntry != NULL
&& fLastSettingsEntry->IsBlackListed())) { && fLastSettingsEntry->IsBlocked())) {
return B_OK; return B_OK;
} }

View File

@ -16,7 +16,8 @@
#include "DebugSupport.h" #include "DebugSupport.h"
static const char* const kEntryBlacklistParameterName = "EntryBlacklist"; static const char* const kBlockedEntriesParameterName = "BlockedEntries";
static const char* const kLegacyBlockedEntriesParameterName = "EntryBlacklist";
// #pragma mark - PackageSettingsItem // #pragma mark - PackageSettingsItem
@ -56,10 +57,12 @@ PackageSettingsItem::ApplySettings(const driver_parameter* parameters,
{ {
for (int i = 0; i < parameterCount; i++) { for (int i = 0; i < parameterCount; i++) {
const driver_parameter& subParameter = parameters[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; continue;
status_t error = _AddBlackListedEntries(subParameter); status_t error = _AddBlockedEntries(subParameter);
// abort only in case of serious issues (memory shortage) // abort only in case of serious issues (memory shortage)
if (error == B_NO_MEMORY) if (error == B_NO_MEMORY)
return error; return error;
@ -130,7 +133,7 @@ PackageSettingsItem::FindEntry(Entry* parent, const char* name) const
status_t status_t
PackageSettingsItem::_AddBlackListedEntries(const driver_parameter& parameter) PackageSettingsItem::_AddBlockedEntries(const driver_parameter& parameter)
{ {
for (int i = 0; i < parameter.parameter_count; i++) { for (int i = 0; i < parameter.parameter_count; i++) {
Entry* entry; Entry* entry;
@ -139,7 +142,7 @@ PackageSettingsItem::_AddBlackListedEntries(const driver_parameter& parameter)
if (error == B_NO_MEMORY) if (error == B_NO_MEMORY)
return error; return error;
entry->SetBlackListed(true); entry->SetBlocked(true);
} }
return B_OK; return B_OK;

View File

@ -23,7 +23,7 @@ public:
: :
fParent(parent), fParent(parent),
fName(name), fName(name),
fIsBlackListed(false) fIsBlocked(false)
{ {
} }
@ -37,14 +37,14 @@ public:
return fName; 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() Entry*& HashNext()
@ -55,7 +55,7 @@ public:
private: private:
Entry* fParent; Entry* fParent;
String fName; String fName;
bool fIsBlackListed; bool fIsBlocked;
Entry* fHashNext; Entry* fHashNext;
}; };
@ -150,7 +150,7 @@ private:
typedef BOpenHashTable<EntryHashDefinition> EntryTable; typedef BOpenHashTable<EntryHashDefinition> EntryTable;
private: private:
status_t _AddBlackListedEntries( status_t _AddBlockedEntries(
const driver_parameter& parameter); const driver_parameter& parameter);
private: private:

View File

@ -104,7 +104,7 @@ for platform in [ MultiBootSubDirSetup ] {
BootStaticLibrary [ MultiBootGristFiles boot_loader ] : BootStaticLibrary [ MultiBootGristFiles boot_loader ] :
PathBlacklist.cpp PathBlocklist.cpp
elf.cpp elf.cpp
heap.cpp heap.cpp
kernel_args.cpp kernel_args.cpp

View File

@ -4,17 +4,17 @@
*/ */
#include <boot/PathBlacklist.h> #include <boot/PathBlocklist.h>
#include <stdlib.h> #include <stdlib.h>
#include <algorithm> #include <algorithm>
// #pragma mark - BlacklistedPath // #pragma mark - BlockedPath
BlacklistedPath::BlacklistedPath() BlockedPath::BlockedPath()
: :
fPath(NULL), fPath(NULL),
fLength(0), fLength(0),
@ -23,14 +23,14 @@ BlacklistedPath::BlacklistedPath()
} }
BlacklistedPath::~BlacklistedPath() BlockedPath::~BlockedPath()
{ {
free(fPath); free(fPath);
} }
bool bool
BlacklistedPath::SetTo(const char* path) BlockedPath::SetTo(const char* path)
{ {
size_t length = strlen(path); size_t length = strlen(path);
if (length > 0 && path[length - 1] == '/') if (length > 0 && path[length - 1] == '/')
@ -49,7 +49,7 @@ BlacklistedPath::SetTo(const char* path)
bool bool
BlacklistedPath::Append(const char* component) BlockedPath::Append(const char* component)
{ {
size_t componentLength = strlen(component); size_t componentLength = strlen(component);
if (componentLength > 0 && component[componentLength - 1] == '/') if (componentLength > 0 && component[componentLength - 1] == '/')
@ -70,7 +70,7 @@ BlacklistedPath::Append(const char* component)
bool bool
BlacklistedPath::_Resize(size_t length, bool keepData) BlockedPath::_Resize(size_t length, bool keepData)
{ {
if (length == 0) { if (length == 0) {
free(fPath); 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(); MakeEmpty();
} }
bool bool
PathBlacklist::Add(const char* path) PathBlocklist::Add(const char* path)
{ {
BlacklistedPath* blacklistedPath = _FindPath(path); BlockedPath* blockedPath = _FindPath(path);
if (blacklistedPath != NULL) if (blockedPath != NULL)
return true; return true;
blacklistedPath = new(std::nothrow) BlacklistedPath; blockedPath = new(std::nothrow) BlockedPath;
if (blacklistedPath == NULL || !blacklistedPath->SetTo(path)) { if (blockedPath == NULL || !blockedPath->SetTo(path)) {
delete blacklistedPath; delete blockedPath;
return false; return false;
} }
fPaths.Add(blacklistedPath); fPaths.Add(blockedPath);
return true; return true;
} }
void void
PathBlacklist::Remove(const char* path) PathBlocklist::Remove(const char* path)
{ {
BlacklistedPath* blacklistedPath = _FindPath(path); BlockedPath* blockedPath = _FindPath(path);
if (blacklistedPath != NULL) { if (blockedPath != NULL) {
fPaths.Remove(blacklistedPath); fPaths.Remove(blockedPath);
delete blacklistedPath; delete blockedPath;
} }
} }
bool bool
PathBlacklist::Contains(const char* path) const PathBlocklist::Contains(const char* path) const
{ {
return _FindPath(path) != NULL; return _FindPath(path) != NULL;
} }
void void
PathBlacklist::MakeEmpty() PathBlocklist::MakeEmpty()
{ {
while (BlacklistedPath* blacklistedPath = fPaths.RemoveHead()) while (BlockedPath* blockedPath = fPaths.RemoveHead())
delete blacklistedPath; delete blockedPath;
} }
BlacklistedPath* BlockedPath*
PathBlacklist::_FindPath(const char* path) const PathBlocklist::_FindPath(const char* path) const
{ {
for (PathList::Iterator it = fPaths.GetIterator(); it.HasNext();) { for (PathList::Iterator it = fPaths.GetIterator(); it.HasNext();) {
BlacklistedPath* blacklistedPath = it.Next(); BlockedPath* blockedPath = it.Next();
if (*blacklistedPath == path) if (*blockedPath == path)
return blacklistedPath; return blockedPath;
} }
return NULL; return NULL;

View File

@ -90,7 +90,7 @@ PackageSettingsItem::Init(const driver_parameter& parameter)
if (strcmp(subParameter.name, "EntryBlacklist") != 0) if (strcmp(subParameter.name, "EntryBlacklist") != 0)
continue; continue;
status_t error = _AddBlackListedEntries(subParameter); status_t error = _AddBlockedEntries(subParameter);
// abort only in case of serious issues (memory shortage) // abort only in case of serious issues (memory shortage)
if (error == B_NO_MEMORY) if (error == B_NO_MEMORY)
return error; return error;
@ -163,7 +163,7 @@ PackageSettingsItem::FindEntry(Entry* parent, const char* name,
status_t status_t
PackageSettingsItem::_AddBlackListedEntries(const driver_parameter& parameter) PackageSettingsItem::_AddBlockedEntries(const driver_parameter& parameter)
{ {
for (int i = 0; i < parameter.parameter_count; i++) { for (int i = 0; i < parameter.parameter_count; i++) {
Entry* entry; Entry* entry;
@ -172,7 +172,7 @@ PackageSettingsItem::_AddBlackListedEntries(const driver_parameter& parameter)
if (error == B_NO_MEMORY) if (error == B_NO_MEMORY)
return error; return error;
entry->SetBlackListed(true); entry->SetBlocked(true);
} }
return B_OK; return B_OK;

View File

@ -27,7 +27,7 @@ public:
: :
fParent(parent), fParent(parent),
fName(NULL), fName(NULL),
fIsBlackListed(false), fIsBlocked(false),
fHashNext(NULL) fHashNext(NULL)
{ {
} }
@ -58,14 +58,14 @@ public:
return fName; 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() Entry*& HashNext()
@ -76,7 +76,7 @@ public:
private: private:
Entry* fParent; Entry* fParent;
char* fName; char* fName;
bool fIsBlackListed; bool fIsBlocked;
Entry* fHashNext; Entry* fHashNext;
}; };
@ -176,7 +176,7 @@ private:
typedef BOpenHashTable<EntryHashDefinition> EntryTable; typedef BOpenHashTable<EntryHashDefinition> EntryTable;
private: private:
status_t _AddBlackListedEntries( status_t _AddBlockedEntries(
const driver_parameter& parameter); const driver_parameter& parameter);
private: private:

View File

@ -24,7 +24,7 @@
#include <Referenceable.h> #include <Referenceable.h>
#include <boot/PathBlacklist.h> #include <boot/PathBlocklist.h>
#include <boot/platform.h> #include <boot/platform.h>
#include "PackageSettingsItem.h" #include "PackageSettingsItem.h"
@ -390,7 +390,7 @@ struct PackageLoaderContentHandler : BPackageContentHandler {
{ {
if (fErrorOccurred if (fErrorOccurred
|| (fLastSettingsEntry != NULL || (fLastSettingsEntry != NULL
&& fLastSettingsEntry->IsBlackListed())) { && fLastSettingsEntry->IsBlocked())) {
return B_OK; return B_OK;
} }
@ -411,7 +411,7 @@ struct PackageLoaderContentHandler : BPackageContentHandler {
if (settingsEntry != NULL) { if (settingsEntry != NULL) {
fLastSettingsEntry = settingsEntry; fLastSettingsEntry = settingsEntry;
fLastSettingsEntryEntry = entry; fLastSettingsEntryEntry = entry;
if (fLastSettingsEntry->IsBlackListed()) if (fLastSettingsEntry->IsBlocked())
return B_OK; return B_OK;
} }
} }
@ -885,14 +885,14 @@ packagefs_mount_file(int fd, ::Directory* systemDirectory,
void void
packagefs_apply_path_blacklist(::Directory* systemDirectory, packagefs_apply_path_blocklist(::Directory* systemDirectory,
const PathBlacklist& pathBlacklist) const PathBlocklist& pathBlocklist)
{ {
PackageFS::Directory* directory PackageFS::Directory* directory
= static_cast<PackageFS::Directory*>(systemDirectory); = static_cast<PackageFS::Directory*>(systemDirectory);
for (PathBlacklist::Iterator it = pathBlacklist.GetIterator(); for (PathBlocklist::Iterator it = pathBlocklist.GetIterator();
BlacklistedPath* path = it.Next();) { BlockedPath* path = it.Next();) {
directory->RemoveEntry(path->Path()); directory->RemoveEntry(path->Path());
} }
} }

View File

@ -11,7 +11,7 @@
#include <SupportDefs.h> #include <SupportDefs.h>
class PathBlacklist; class PathBlocklist;
class Directory; class Directory;
class Node; class Node;
@ -19,8 +19,8 @@ class Node;
status_t packagefs_mount_file(int fd, Directory* systemDirectory, status_t packagefs_mount_file(int fd, Directory* systemDirectory,
Directory*& _mountedDirectory); Directory*& _mountedDirectory);
void packagefs_apply_path_blacklist(Directory* systemDirectory, void packagefs_apply_path_blocklist(Directory* systemDirectory,
const PathBlacklist& pathBlacklist); const PathBlocklist& pathBlocklist);
#endif // BOOT_LOADER_FILE_SYSTEMS_PACKAGEFS_H #endif // BOOT_LOADER_FILE_SYSTEMS_PACKAGEFS_H

View File

@ -12,7 +12,7 @@
#include <boot/vfs.h> #include <boot/vfs.h>
#include <boot/platform.h> #include <boot/platform.h>
#include <boot/heap.h> #include <boot/heap.h>
#include <boot/PathBlacklist.h> #include <boot/PathBlocklist.h>
#include <boot/stdio.h> #include <boot/stdio.h>
#include <boot/net/NetStack.h> #include <boot/net/NetStack.h>
@ -62,7 +62,7 @@ main(stage2_args *args)
bool mountedAllVolumes = false; bool mountedAllVolumes = false;
BootVolume bootVolume; BootVolume bootVolume;
PathBlacklist pathBlacklist; PathBlocklist pathBlocklist;
if (get_boot_file_system(args, bootVolume) != B_OK if (get_boot_file_system(args, bootVolume) != B_OK
|| (platform_boot_options() & BOOT_OPTION_MENU) != 0) { || (platform_boot_options() & BOOT_OPTION_MENU) != 0) {
@ -79,7 +79,7 @@ main(stage2_args *args)
mountedAllVolumes = true; mountedAllVolumes = true;
if (user_menu(bootVolume, pathBlacklist) < B_OK) { if (user_menu(bootVolume, pathBlocklist) < B_OK) {
// user requested to quit the loader // user requested to quit the loader
goto out; goto out;
} }
@ -103,7 +103,7 @@ main(stage2_args *args)
mountedAllVolumes = true; mountedAllVolumes = true;
} }
if (user_menu(bootVolume, pathBlacklist) != B_OK if (user_menu(bootVolume, pathBlocklist) != B_OK
|| !bootVolume.IsValid()) { || !bootVolume.IsValid()) {
// user requested to quit the loader // user requested to quit the loader
goto out; goto out;
@ -115,8 +115,8 @@ main(stage2_args *args)
// know our boot volume, too // know our boot volume, too
if (status == B_OK) { if (status == B_OK) {
if (bootVolume.IsPackaged()) { if (bootVolume.IsPackaged()) {
packagefs_apply_path_blacklist(bootVolume.SystemDirectory(), packagefs_apply_path_blocklist(bootVolume.SystemDirectory(),
pathBlacklist); pathBlocklist);
} }
register_boot_file_system(bootVolume); register_boot_file_system(bootVolume);

View File

@ -17,7 +17,7 @@
#include <AutoDeleter.h> #include <AutoDeleter.h>
#include <boot/menu.h> #include <boot/menu.h>
#include <boot/PathBlacklist.h> #include <boot/PathBlocklist.h>
#include <boot/stage2.h> #include <boot/stage2.h>
#include <boot/vfs.h> #include <boot/vfs.h>
#include <boot/platform.h> #include <boot/platform.h>
@ -46,9 +46,9 @@
// only set while in user_menu() // only set while in user_menu()
static Menu* sMainMenu = NULL; static Menu* sMainMenu = NULL;
static Menu* sBlacklistRootMenu = NULL; static Menu* sBlocklistRootMenu = NULL;
static BootVolume* sBootVolume = NULL; static BootVolume* sBootVolume = NULL;
static PathBlacklist* sPathBlacklist; static PathBlocklist* sPathBlocklist;
MenuItem::MenuItem(const char *label, Menu *subMenu) 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: public:
BlacklistMenuItem(char* label, Node* node, Menu* subMenu) BlocklistMenuItem(char* label, Node* node, Menu* subMenu)
: :
MenuItem(label, subMenu), MenuItem(label, subMenu),
fNode(node), fNode(node),
@ -533,7 +533,7 @@ public:
SetType(MENU_ITEM_MARKABLE); SetType(MENU_ITEM_MARKABLE);
} }
~BlacklistMenuItem() ~BlocklistMenuItem()
{ {
fNode->Release(); fNode->Release();
@ -546,12 +546,12 @@ public:
return fNode->Type() == S_IFDIR; return fNode->Type() == S_IFDIR;
} }
bool GetPath(BlacklistedPath& _path) const bool GetPath(BlockedPath& _path) const
{ {
Menu* menu = Supermenu(); Menu* menu = Supermenu();
if (menu != NULL && menu != sBlacklistRootMenu if (menu != NULL && menu != sBlocklistRootMenu
&& menu->Superitem() != NULL) { && menu->Superitem() != NULL) {
return static_cast<BlacklistMenuItem*>(menu->Superitem()) return static_cast<BlocklistMenuItem*>(menu->Superitem())
->GetPath(_path) ->GetPath(_path)
&& _path.Append(Label()); && _path.Append(Label());
} }
@ -559,11 +559,11 @@ public:
return _path.SetTo(Label()); return _path.SetTo(Label());
} }
void UpdateBlacklisted() void UpdateBlocked()
{ {
BlacklistedPath path; BlockedPath path;
if (GetPath(path)) if (GetPath(path))
_SetMarked(sPathBlacklist->Contains(path.Path()), false); _SetMarked(sPathBlocklist->Contains(path.Path()), false);
} }
virtual void SetMarked(bool marked) virtual void SetMarked(bool marked)
@ -573,10 +573,10 @@ public:
static bool Less(const MenuItem* a, const MenuItem* b) static bool Less(const MenuItem* a, const MenuItem* b)
{ {
const BlacklistMenuItem* item1 const BlocklistMenuItem* item1
= static_cast<const BlacklistMenuItem*>(a); = static_cast<const BlocklistMenuItem*>(a);
const BlacklistMenuItem* item2 const BlocklistMenuItem* item2
= static_cast<const BlacklistMenuItem*>(b); = static_cast<const BlocklistMenuItem*>(b);
// directories come first // directories come first
if (item1->IsDirectoryItem() != item2->IsDirectoryItem()) if (item1->IsDirectoryItem() != item2->IsDirectoryItem())
@ -587,7 +587,7 @@ public:
} }
private: private:
void _SetMarked(bool marked, bool updateBlacklist) void _SetMarked(bool marked, bool updateBlocklist)
{ {
if (marked == IsMarked()) if (marked == IsMarked())
return; return;
@ -596,13 +596,13 @@ private:
if (IsDirectoryItem()) if (IsDirectoryItem())
SetSubmenu(marked ? NULL : fSubMenu); SetSubmenu(marked ? NULL : fSubMenu);
if (updateBlacklist) { if (updateBlocklist) {
BlacklistedPath path; BlockedPath path;
if (GetPath(path)) { if (GetPath(path)) {
if (marked) if (marked)
sPathBlacklist->Add(path.Path()); sPathBlocklist->Add(path.Path());
else else
sPathBlacklist->Remove(path.Path()); sPathBlocklist->Remove(path.Path());
} }
} }
@ -615,16 +615,16 @@ private:
}; };
class BlacklistMenu : public Menu { class BlocklistMenu : public Menu {
public: public:
BlacklistMenu() BlocklistMenu()
: :
Menu(STANDARD_MENU, kDefaultMenuTitle), Menu(STANDARD_MENU, kDefaultMenuTitle),
fDirectory(NULL) fDirectory(NULL)
{ {
} }
~BlacklistMenu() ~BlocklistMenu()
{ {
SetDirectory(NULL); SetDirectory(NULL);
} }
@ -638,19 +638,19 @@ public:
if (fDirectory->Open(&cookie, O_RDONLY) == B_OK) { if (fDirectory->Open(&cookie, O_RDONLY) == B_OK) {
Node* node; Node* node;
while (fDirectory->GetNextNode(cookie, &node) == B_OK) { while (fDirectory->GetNextNode(cookie, &node) == B_OK) {
BlacklistMenuItem* item = _CreateItem(node); BlocklistMenuItem* item = _CreateItem(node);
node->Release(); node->Release();
if (item == NULL) if (item == NULL)
break; break;
AddItem(item); AddItem(item);
item->UpdateBlacklisted(); item->UpdateBlocked();
} }
fDirectory->Close(cookie); fDirectory->Close(cookie);
} }
SortItems(&BlacklistMenuItem::Less); SortItems(&BlocklistMenuItem::Less);
} }
if (CountItems() > 0) if (CountItems() > 0)
@ -676,7 +676,7 @@ protected:
} }
private: 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. // Get the node name and duplicate it, so we can use it as a label.
char name[B_FILE_NAME_LENGTH]; char name[B_FILE_NAME_LENGTH];
@ -689,17 +689,17 @@ private:
strlcat(name, "/", sizeof(name)); strlcat(name, "/", sizeof(name));
// If this is a directory, create the submenu. // If this is a directory, create the submenu.
BlacklistMenu* subMenu = NULL; BlocklistMenu* subMenu = NULL;
if (isDirectory) { if (isDirectory) {
subMenu = new(std::nothrow) BlacklistMenu; subMenu = new(std::nothrow) BlocklistMenu;
if (subMenu != NULL) if (subMenu != NULL)
subMenu->SetDirectory(static_cast<Directory*>(node)); subMenu->SetDirectory(static_cast<Directory*>(node));
} }
ObjectDeleter<BlacklistMenu> subMenuDeleter(subMenu); ObjectDeleter<BlocklistMenu> subMenuDeleter(subMenu);
// create the menu item // create the menu item
BlacklistMenuItem* item = new(std::nothrow) BlacklistMenuItem(name, BlocklistMenuItem* item = new(std::nothrow) BlocklistMenuItem(name,
node, subMenu); node, subMenu);
if (item == NULL) if (item == NULL)
return NULL; return NULL;
@ -723,22 +723,22 @@ protected:
}; };
const char* const BlacklistMenu::kDefaultMenuTitle const char* const BlocklistMenu::kDefaultMenuTitle
= "Mark the entries to blacklist"; = "Mark the entries to blocklist";
class BlacklistRootMenu : public BlacklistMenu { class BlocklistRootMenu : public BlocklistMenu {
public: public:
BlacklistRootMenu() BlocklistRootMenu()
: :
BlacklistMenu() BlocklistMenu()
{ {
} }
virtual void Entered() virtual void Entered()
{ {
// Get the system directory, but only if this is a packaged Haiku. // 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() if (sBootVolume != NULL && sBootVolume->IsValid()
&& sBootVolume->IsPackaged()) { && sBootVolume->IsPackaged()) {
SetDirectory(sBootVolume->SystemDirectory()); SetDirectory(sBootVolume->SystemDirectory());
@ -746,11 +746,11 @@ public:
} else { } else {
SetDirectory(NULL); SetDirectory(NULL);
SetTitle(sBootVolume != NULL && sBootVolume->IsValid() 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!"); : "No boot volume selected!");
} }
BlacklistMenu::Entered(); BlocklistMenu::Entered();
// rename last item // rename last item
if (MenuItem* item = ItemAt(CountItems() - 1)) if (MenuItem* item = ItemAt(CountItems() - 1))
@ -759,7 +759,7 @@ public:
virtual void Exited() virtual void Exited()
{ {
BlacklistMenu::Exited(); BlocklistMenu::Exited();
SetDirectory(NULL); SetDirectory(NULL);
} }
}; };
@ -952,7 +952,7 @@ user_menu_boot_volume(Menu* menu, MenuItem* item)
if (sBootVolume->IsValid() && sBootVolume->RootDirectory() == item->Data()) if (sBootVolume->IsValid() && sBootVolume->RootDirectory() == item->Data())
return true; return true;
sPathBlacklist->MakeEmpty(); sPathBlocklist->MakeEmpty();
status_t status = sBootVolume->SetTo((Directory*)item->Data()); status_t status = sBootVolume->SetTo((Directory*)item->Data());
update_continue_booting_menu_item(status); update_continue_booting_menu_item(status);
@ -978,7 +978,7 @@ user_menu_boot_volume_state(Menu* menu, MenuItem* _item)
volumeItem->Select(true); volumeItem->Select(true);
volumeItem->UpdateStateName(item->VolumeState()); volumeItem->UpdateStateName(item->VolumeState());
sPathBlacklist->MakeEmpty(); sPathBlocklist->MakeEmpty();
status_t status = sBootVolume->SetTo((Directory*)item->Data(), status_t status = sBootVolume->SetTo((Directory*)item->Data(),
item->VolumeInfo(), item->VolumeState()); item->VolumeInfo(), item->VolumeState());
@ -1336,9 +1336,9 @@ add_safe_mode_menu()
platform_add_menus(safeMenu); platform_add_menus(safeMenu);
safeMenu->AddSeparatorItem(); safeMenu->AddSeparatorItem();
sBlacklistRootMenu = new(std::nothrow) BlacklistRootMenu; sBlocklistRootMenu = new(std::nothrow) BlocklistRootMenu;
safeMenu->AddItem(item = new(std::nothrow) MenuItem("Blacklist entries", safeMenu->AddItem(item = new(std::nothrow) MenuItem("Blocklist entries",
sBlacklistRootMenu)); sBlocklistRootMenu));
item->SetHelpText("Allows to select system files that shall be ignored. " item->SetHelpText("Allows to select system files that shall be ignored. "
"Useful e.g. to disable drivers temporarily."); "Useful e.g. to disable drivers temporarily.");
@ -1542,15 +1542,29 @@ apply_safe_mode_options(Menu* menu)
static void static void
apply_safe_mode_path_blacklist() apply_safe_mode_path_blocklist()
{ {
if (sPathBlacklist->IsEmpty()) if (sPathBlocklist->IsEmpty())
return; return;
bool success = sSafeModeOptionsBuffer.Append("EntryBlacklist {\n"); bool success = sSafeModeOptionsBuffer.Append("BlockedEntries {\n");
for (PathBlacklist::Iterator it = sPathBlacklist->GetIterator(); for (PathBlocklist::Iterator it = sPathBlocklist->GetIterator();
BlacklistedPath* path = it.Next();) { 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(path->Path());
success &= sSafeModeOptionsBuffer.Append("\n", 1); success &= sSafeModeOptionsBuffer.Append("\n", 1);
} }
@ -1559,7 +1573,7 @@ apply_safe_mode_path_blacklist()
if (!success) { if (!success) {
dprintf("apply_safe_mode_options(): failed to append path " 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 status_t
user_menu(BootVolume& _bootVolume, PathBlacklist& _pathBlacklist) user_menu(BootVolume& _bootVolume, PathBlocklist& _pathBlocklist)
{ {
Menu* menu = new(std::nothrow) Menu(MAIN_MENU); Menu* menu = new(std::nothrow) Menu(MAIN_MENU);
sMainMenu = menu; sMainMenu = menu;
sBootVolume = &_bootVolume; sBootVolume = &_bootVolume;
sPathBlacklist = &_pathBlacklist; sPathBlocklist = &_pathBlocklist;
Menu* safeModeMenu = NULL; Menu* safeModeMenu = NULL;
Menu* debugMenu = NULL; Menu* debugMenu = NULL;
@ -1621,7 +1635,7 @@ user_menu(BootVolume& _bootVolume, PathBlacklist& _pathBlacklist)
apply_safe_mode_options(safeModeMenu); apply_safe_mode_options(safeModeMenu);
apply_safe_mode_options(debugMenu); apply_safe_mode_options(debugMenu);
apply_safe_mode_path_blacklist(); apply_safe_mode_path_blocklist();
add_safe_mode_settings(sSafeModeOptionsBuffer.String()); add_safe_mode_settings(sSafeModeOptionsBuffer.String());
delete menu; delete menu;
@ -1629,8 +1643,8 @@ user_menu(BootVolume& _bootVolume, PathBlacklist& _pathBlacklist)
TRACE(("user_menu: leave\n")); TRACE(("user_menu: leave\n"));
sMainMenu = NULL; sMainMenu = NULL;
sBlacklistRootMenu = NULL; sBlocklistRootMenu = NULL;
sBootVolume = NULL; sBootVolume = NULL;
sPathBlacklist = NULL; sPathBlocklist = NULL;
return B_OK; return B_OK;
} }

View File

@ -9,11 +9,11 @@
#include <boot/vfs.h> #include <boot/vfs.h>
class PathBlacklist; class PathBlocklist;
extern status_t user_menu(BootVolume& _bootVolume, extern status_t user_menu(BootVolume& _bootVolume,
PathBlacklist& _pathBlacklist); PathBlocklist& _pathBlocklist);
#endif /* MENU_H */ #endif /* MENU_H */