packagefs/daemon: Ignore packages/ entries without .hpkg suffix

This commit is contained in:
Ingo Weinhold 2013-04-08 15:45:47 +02:00
parent 379131d97d
commit def92c01ee
2 changed files with 17 additions and 0 deletions

View File

@ -807,6 +807,13 @@ Volume::_AddInitialPackages()
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
continue;
// also skip any entry without a ".hpkg" extension
size_t nameLength = strlen(entry->d_name);
if (nameLength < 5
|| memcmp(entry->d_name + nameLength - 5, ".hpkg", 5) != 0) {
continue;
}
Package* package;
if (_LoadPackage(entry->d_name, package) != B_OK)
continue;

View File

@ -26,6 +26,9 @@
#include "DebugSupport.h"
static const char* kPackageFileNameExtension = ".hpkg";
// #pragma mark - Listener
@ -338,6 +341,10 @@ Volume::_QueueNodeMonitorEvent(const BString& name, bool wasCreated)
return;
}
// ignore entries that don't have the ".hpkg" extension
if (!name.EndsWith(kPackageFileNameExtension))
return;
NodeMonitorEvent* event
= new(std::nothrow) NodeMonitorEvent(name, wasCreated);
if (event == NULL) {
@ -497,6 +504,9 @@ Volume::_ReadPackagesDirectory()
entry_ref entry;
while (directory.GetNextRef(&entry) == B_OK) {
if (!BString(entry.name).EndsWith(kPackageFileNameExtension))
continue;
Package* package = new(std::nothrow) Package;
if (package == NULL)
RETURN_ERROR(B_NO_MEMORY);