From 6c36ad168e98c010774f57970c7deb03e9b98403 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 2 Jun 2013 19:11:39 +0200 Subject: [PATCH] Installer: Restrict entry filter to files from the BFS volume We generally want to skip the contents of the packagefs volumes (save for the shine-through directories). That makes Installer usable again. In what direction we want to develop it (e.g. integrate some PM support, so that a subset of packages can be selected) needs further discussion. --- src/apps/installer/InstallerDefs.cpp | 1 - src/apps/installer/InstallerDefs.h | 1 - src/apps/installer/WorkerThread.cpp | 24 +++++++++++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/apps/installer/InstallerDefs.cpp b/src/apps/installer/InstallerDefs.cpp index 4e99387398..a389547e45 100644 --- a/src/apps/installer/InstallerDefs.cpp +++ b/src/apps/installer/InstallerDefs.cpp @@ -9,4 +9,3 @@ const char* const kPackagesDirectoryPath = "_packages_"; const char* const kSourcesDirectoryPath = "_sources_"; -const char* const kSwapFilePath = "common/var/swap"; diff --git a/src/apps/installer/InstallerDefs.h b/src/apps/installer/InstallerDefs.h index 56470a3118..b8075c90ce 100644 --- a/src/apps/installer/InstallerDefs.h +++ b/src/apps/installer/InstallerDefs.h @@ -16,7 +16,6 @@ static const uint32 MSG_WRITE_BOOT_SECTOR = 'iWBS'; extern const char* const kPackagesDirectoryPath; extern const char* const kSourcesDirectoryPath; -extern const char* const kSwapFilePath; #endif // INSTALLER_DEFS_H diff --git a/src/apps/installer/WorkerThread.cpp b/src/apps/installer/WorkerThread.cpp index e22790f1e5..d2d1550186 100644 --- a/src/apps/installer/WorkerThread.cpp +++ b/src/apps/installer/WorkerThread.cpp @@ -86,6 +86,9 @@ private: class WorkerThread::EntryFilter : public CopyEngine::EntryFilter { public: EntryFilter(const char* sourceDirectory) + : + fIgnorePaths(), + fSourceDevice(-1) { try { fIgnorePaths.insert(kPackagesDirectoryPath); @@ -93,10 +96,18 @@ public: fIgnorePaths.insert("rr_moved"); fIgnorePaths.insert("boot.catalog"); fIgnorePaths.insert("haiku-boot-floppy.image"); - fIgnorePaths.insert(kSwapFilePath); + fIgnorePaths.insert("common/var/swap"); + fIgnorePaths.insert("common/var/shared_memory"); + + fPackageFSRootPaths.insert("system"); + fPackageFSRootPaths.insert("common"); + fPackageFSRootPaths.insert("home/config"); } catch (std::bad_alloc&) { } + struct stat st; + if (stat(sourceDirectory, &st) == 0) + fSourceDevice = st.st_dev; } virtual bool ShouldCopyEntry(const BEntry& entry, const char* path, @@ -106,6 +117,15 @@ public: printf("ignoring '%s'.\n", path); return false; } + + if (statInfo.st_dev != fSourceDevice) { + // Allow that only for the root of the packagefs mounts, since + // those contain directories that shine through from the + // underlying volume. + if (fPackageFSRootPaths.find(path) == fPackageFSRootPaths.end()) + return false; + } + return true; } @@ -123,6 +143,8 @@ public: private: std::set fIgnorePaths; + std::set fPackageFSRootPaths; + dev_t fSourceDevice; };