From 18b90323d9f2b302f2083a0758a398075000d8db Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 18 Jul 2003 18:41:21 +0000 Subject: [PATCH] Added flags for disk systems. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4009 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/disk_device_manager/KDiskSystem.h | 7 ++-- .../kernel/disk_device_manager/KFileSystem.h | 2 -- .../disk_device_manager/KPartitioningSystem.h | 2 -- .../kernel/disk_device_manager/ddm_modules.h | 2 ++ .../ddm_userland_interface.h | 2 +- headers/private/storage/DiskDeviceDefs.h | 33 +++++++++++++++++++ src/add-ons/kernel/disk_scanner/fs/bfs.c | 1 + .../partitioning_systems/intel/intel.cpp | 2 ++ .../core/disk_device_manager/KDiskSystem.cpp | 21 +++++++++--- .../core/disk_device_manager/KFileSystem.cpp | 8 +---- .../KPartitioningSystem.cpp | 8 +---- 11 files changed, 63 insertions(+), 25 deletions(-) diff --git a/headers/private/kernel/disk_device_manager/KDiskSystem.h b/headers/private/kernel/disk_device_manager/KDiskSystem.h index 2335258c47..c780cddea8 100644 --- a/headers/private/kernel/disk_device_manager/KDiskSystem.h +++ b/headers/private/kernel/disk_device_manager/KDiskSystem.h @@ -23,9 +23,10 @@ public: // void SetID(disk_system_id id); disk_system_id ID() const; const char *Name() const; - virtual const char *PrettyName(); + const char *PrettyName(); + uint32 Flags() const; - virtual bool IsFileSystem() const; + bool IsFileSystem() const; bool IsPartitioningSystem() const; void GetInfo(user_disk_system_info *info); @@ -137,6 +138,7 @@ protected: virtual void UnloadModule(); status_t SetPrettyName(const char *name); + void SetFlags(uint32 flags); static int32 _NextID(); @@ -144,6 +146,7 @@ private: disk_system_id fID; char *fName; char *fPrettyName; + uint32 fFlags; int32 fLoadCounter; static int32 fNextID; diff --git a/headers/private/kernel/disk_device_manager/KFileSystem.h b/headers/private/kernel/disk_device_manager/KFileSystem.h index c90590ab16..39a0fa9ebe 100644 --- a/headers/private/kernel/disk_device_manager/KFileSystem.h +++ b/headers/private/kernel/disk_device_manager/KFileSystem.h @@ -20,8 +20,6 @@ public: virtual status_t Init(); - virtual bool IsFileSystem() const; - // Scanning virtual float Identify(KPartition *partition, void **cookie); diff --git a/headers/private/kernel/disk_device_manager/KPartitioningSystem.h b/headers/private/kernel/disk_device_manager/KPartitioningSystem.h index 6bd976c2e9..362471669e 100644 --- a/headers/private/kernel/disk_device_manager/KPartitioningSystem.h +++ b/headers/private/kernel/disk_device_manager/KPartitioningSystem.h @@ -17,8 +17,6 @@ public: virtual status_t Init(); - virtual bool IsFileSystem() const; - // Scanning virtual float Identify(KPartition *partition, void **cookie); diff --git a/headers/private/kernel/disk_device_manager/ddm_modules.h b/headers/private/kernel/disk_device_manager/ddm_modules.h index 642e4070d5..32d9ec84ff 100644 --- a/headers/private/kernel/disk_device_manager/ddm_modules.h +++ b/headers/private/kernel/disk_device_manager/ddm_modules.h @@ -117,6 +117,7 @@ typedef status_t (*partition_set_partition_content_parameters)(int fd, typedef struct partition_module_info { module_info module; const char *pretty_name; + uint32 flags; // scanning partition_identify_partition identify_partition; @@ -243,6 +244,7 @@ typedef status_t (*fs_set_partition_content_parameters)(int fd, typedef struct fs_module_info { module_info module; const char *pretty_name; + uint32 flags; // scanning fs_identify_partition identify_partition; diff --git a/headers/private/kernel/disk_device_manager/ddm_userland_interface.h b/headers/private/kernel/disk_device_manager/ddm_userland_interface.h index 27c12e9ac4..425b1ff64c 100644 --- a/headers/private/kernel/disk_device_manager/ddm_userland_interface.h +++ b/headers/private/kernel/disk_device_manager/ddm_userland_interface.h @@ -52,7 +52,7 @@ struct user_disk_system_info { disk_system_id id; char name[B_FILE_NAME_LENGTH]; // better B_PATH_NAME_LENGTH? char pretty_name[B_OS_NAME_LENGTH]; - bool file_system; + uint32 flags; }; // userland disk device job representation diff --git a/headers/private/storage/DiskDeviceDefs.h b/headers/private/storage/DiskDeviceDefs.h index 682e0b18e1..26f40af912 100644 --- a/headers/private/storage/DiskDeviceDefs.h +++ b/headers/private/storage/DiskDeviceDefs.h @@ -42,6 +42,39 @@ enum { B_DISK_DEVICE_WRITE_ONCE = 0x08, }; +// disk system flags +enum { + B_DISK_SYSTEM_IS_FILE_SYSTEM = 0x0001, + + // flags common for both file and partitioning systems + B_DISK_SYSTEM_SUPPORTS_CHECKING = 0x0002, + B_DISK_SYSTEM_SUPPORTS_REPAIRING = 0x0004, + B_DISK_SYSTEM_SUPPORTS_RESIZING = 0x0008, + B_DISK_SYSTEM_SUPPORTS_MOVING = 0x0010, + B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME = 0x0020, + B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_PARAMETERS = 0x0040, + + // file system specific flags + B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING = 0x0100, + B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING_WHILE_MOUNTED = 0x0200, + B_DISK_SYSTEM_SUPPORTS_CHECKING_WHILE_MOUNTED = 0x0400, + B_DISK_SYSTEM_SUPPORTS_REPAIRING_WHILE_MOUNTED = 0x0800, + B_DISK_SYSTEM_SUPPORTS_RESIZING_WHILE_MOUNTED = 0x1000, + B_DISK_SYSTEM_SUPPORTS_MOVING_WHILE_MOUNTED = 0x2000, + B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME_WHILE_MOUNTED = 0x4000, + B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_PARAMETERS_WHILE_MOUNTED = 0x8000, + + // partitioning system specific flags + B_DISK_SYSTEM_SUPPORTS_RESIZING_CHILD = 0x0100, + B_DISK_SYSTEM_SUPPORTS_MOVING_CHILD = 0x0200, + B_DISK_SYSTEM_SUPPORTS_SETTING_NAME = 0x0400, + B_DISK_SYSTEM_SUPPORTS_SETTING_TYPE = 0x0800, + B_DISK_SYSTEM_SUPPORTS_SETTING_PARAMETERS = 0x1000, + B_DISK_SYSTEM_SUPPORTS_CREATING_CHILD = 0x2000, + B_DISK_SYSTEM_SUPPORTS_DELETING_CHILD = 0x4000, + B_DISK_SYSTEM_SUPPORTS_INITIALIZING = 0x8000, +}; + #ifdef __cplusplus } #endif diff --git a/src/add-ons/kernel/disk_scanner/fs/bfs.c b/src/add-ons/kernel/disk_scanner/fs/bfs.c index e72efb9f39..2866cf3906 100644 --- a/src/add-ons/kernel/disk_scanner/fs/bfs.c +++ b/src/add-ons/kernel/disk_scanner/fs/bfs.c @@ -263,6 +263,7 @@ static fs_module_info bfs_module = { // B_PLAIN_C_ERROR: // kPartitionTypeBFS, // pretty_name "BFS Filesystem", // pretty_name + B_DISK_SYSTEM_IS_FILE_SYSTEM, // flags // scanning bfs_identify_partition, // identify_partition diff --git a/src/add-ons/kernel/partitioning_systems/intel/intel.cpp b/src/add-ons/kernel/partitioning_systems/intel/intel.cpp index 71393a2527..9b7f7c6568 100644 --- a/src/add-ons/kernel/partitioning_systems/intel/intel.cpp +++ b/src/add-ons/kernel/partitioning_systems/intel/intel.cpp @@ -298,6 +298,7 @@ static partition_module_info intel_partition_map_module = { pm_std_ops }, kPartitionTypeIntel, // pretty_name + 0, // flags // scanning pm_identify_partition, // identify_partition @@ -375,6 +376,7 @@ static partition_module_info intel_extended_partition_module = { ep_std_ops }, kPartitionTypeIntelExtended, // pretty_name + 0, // flags // scanning ep_identify_partition, // identify_partition diff --git a/src/kernel/core/disk_device_manager/KDiskSystem.cpp b/src/kernel/core/disk_device_manager/KDiskSystem.cpp index 945408f549..df83c8802b 100644 --- a/src/kernel/core/disk_device_manager/KDiskSystem.cpp +++ b/src/kernel/core/disk_device_manager/KDiskSystem.cpp @@ -64,19 +64,25 @@ KDiskSystem::PrettyName() return fPrettyName; } +// Flags +uint32 +KDiskSystem::Flags() const +{ + return fFlags; +} + // IsFileSystem bool KDiskSystem::IsFileSystem() const { - // to be implemented by derived classes - return false; + return (fFlags & B_DISK_SYSTEM_IS_FILE_SYSTEM); } // IsPartitioningSystem bool KDiskSystem::IsPartitioningSystem() const { - return !IsFileSystem(); + return !(fFlags & B_DISK_SYSTEM_IS_FILE_SYSTEM); } // GetInfo @@ -88,7 +94,7 @@ KDiskSystem::GetInfo(user_disk_system_info *info) info->id = ID(); strcpy(info->name, Name()); strcpy(info->pretty_name, PrettyName()); - info->file_system = IsFileSystem(); + info->flags = Flags(); } // Load @@ -549,6 +555,13 @@ KDiskSystem::SetPrettyName(const char *name) return set_string(fPrettyName, name); } +// SetFlags +void +KDiskSystem::SetFlags(uint32 flags) +{ + fFlags = flags; +} + // _NextID int32 KDiskSystem::_NextID() diff --git a/src/kernel/core/disk_device_manager/KFileSystem.cpp b/src/kernel/core/disk_device_manager/KFileSystem.cpp index 56de11db81..19d657beeb 100644 --- a/src/kernel/core/disk_device_manager/KFileSystem.cpp +++ b/src/kernel/core/disk_device_manager/KFileSystem.cpp @@ -32,17 +32,11 @@ KFileSystem::Init() if (error != B_OK) return error; error = SetPrettyName(fModule->pretty_name); + SetFlags(fModule->flags | B_DISK_SYSTEM_IS_FILE_SYSTEM); Unload(); return error; } -// IsFileSystem -bool -KFileSystem::IsFileSystem() const -{ - return true; -} - // Identify float KFileSystem::Identify(KPartition *partition, void **cookie) diff --git a/src/kernel/core/disk_device_manager/KPartitioningSystem.cpp b/src/kernel/core/disk_device_manager/KPartitioningSystem.cpp index 386421df46..1523e42cc3 100644 --- a/src/kernel/core/disk_device_manager/KPartitioningSystem.cpp +++ b/src/kernel/core/disk_device_manager/KPartitioningSystem.cpp @@ -32,17 +32,11 @@ KPartitioningSystem::Init() if (error != B_OK) return error; error = SetPrettyName(fModule->pretty_name); + SetFlags(fModule->flags & ~(uint32)B_DISK_SYSTEM_IS_FILE_SYSTEM); Unload(); return error; } -// IsFileSystem -bool -KPartitioningSystem::IsFileSystem() const -{ - return false; -} - // Identify float KPartitioningSystem::Identify(KPartition *partition, void **cookie)