* Added BDiskSystem::ShortName() and everything needed to get it there.

* Added BDiskDeviceRoster::GetDiskSystem() method, that can get a disk system
  by short/pretty/module name - since they should all be unique, I put them
  in a single namespace, please complain if you don't like that :-)
* Cleaned up DiskSystem.h and DiskDeviceRoster.h according to the updated
  header guidelines.
* Renamed ntfs pretty name from "ntfs File System" to "Windows NT File System".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25414 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-05-10 11:44:00 +00:00
parent 36e12bef8f
commit 1da9f5cea5
28 changed files with 243 additions and 141 deletions
+1
View File
@@ -232,6 +232,7 @@ struct fs_vnode_ops {
typedef struct file_system_module_info {
struct module_info info;
const char* short_name;
const char* pretty_name;
uint32 flags; // DDM flags
@@ -266,6 +266,7 @@ struct fssh_fs_vnode_ops {
typedef struct fssh_file_system_module_info {
struct fssh_module_info info;
const char* short_name;
const char* pretty_name;
uint32_t flags; // DDM flags
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
* Copyright 2003-2008, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -8,6 +8,7 @@
#ifndef _K_DISK_DEVICE_SYSTEM_H
#define _K_DISK_DEVICE_SYSTEM_H
#include "disk_device_manager.h"
@@ -33,7 +34,8 @@ public:
disk_system_id ID() const;
const char* Name() const;
const char* PrettyName();
const char* ShortName() const;
const char* PrettyName() const;
uint32 Flags() const;
bool IsFileSystem() const;
@@ -97,6 +99,7 @@ protected:
virtual status_t LoadModule();
virtual void UnloadModule();
status_t SetShortName(const char* name);
status_t SetPrettyName(const char* name);
void SetFlags(uint32 flags);
@@ -105,6 +108,7 @@ protected:
private:
disk_system_id fID;
char* fName;
char* fShortName;
char* fPrettyName;
uint32 fFlags;
int32 fLoadCounter;
@@ -1,10 +1,12 @@
// ddm_modules.h
//
// Interface to be implemented by partitioning modules.
/*
* Copyright 2003-2008, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _K_DISK_DEVICE_MODULES_H
#define _K_DISK_DEVICE_MODULES_H
//! Interface to be implemented by partitioning modules.
#include <disk_device_manager.h>
#include <module.h>
#include <SupportDefs.h>
@@ -12,6 +14,7 @@
typedef struct partition_module_info {
module_info module;
const char* short_name;
const char* pretty_name;
uint32 flags;
@@ -1,5 +1,10 @@
// ddm_userland_interface.h
/*
* Copyright 2003-2008, Haiku Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ingo Weinhold, [email protected]
*/
#ifndef _DISK_DEVICE_MANAGER_USERLAND_INTERFACE_H
#define _DISK_DEVICE_MANAGER_USERLAND_INTERFACE_H
@@ -49,6 +54,7 @@ typedef struct user_disk_device_data {
typedef struct user_disk_system_info {
disk_system_id id;
char name[B_FILE_NAME_LENGTH]; // better B_PATH_NAME_LENGTH?
char short_name[B_OS_NAME_LENGTH];
char pretty_name[B_OS_NAME_LENGTH];
uint32 flags;
} user_disk_system_info;
+47 -41
View File
@@ -1,8 +1,7 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*
* Copyright 2003-2008, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _DISK_DEVICE_ROSTER_H
#define _DISK_DEVICE_ROSTER_H
@@ -85,44 +84,51 @@ enum {
class BDiskDeviceRoster {
public:
BDiskDeviceRoster();
~BDiskDeviceRoster();
status_t GetNextDevice(BDiskDevice *device);
status_t RewindDevices();
status_t GetNextDiskSystem(BDiskSystem *system);
status_t RewindDiskSystems();
BDiskDeviceRoster();
~BDiskDeviceRoster();
partition_id RegisterFileDevice(const char *filename);
// publishes: /dev/disk/virtual/files/<disk device ID>/raw
status_t UnregisterFileDevice(const char *filename);
status_t UnregisterFileDevice(partition_id device);
status_t GetNextDevice(BDiskDevice* device);
status_t RewindDevices();
bool VisitEachDevice(BDiskDeviceVisitor *visitor,
BDiskDevice *device = NULL);
bool VisitEachPartition(BDiskDeviceVisitor *visitor,
BDiskDevice *device = NULL,
BPartition **partition = NULL);
status_t GetNextDiskSystem(BDiskSystem* system);
status_t RewindDiskSystems();
bool VisitEachMountedPartition(BDiskDeviceVisitor *visitor,
BDiskDevice *device = NULL,
BPartition **partition = NULL);
bool VisitEachMountablePartition(BDiskDeviceVisitor *visitor,
BDiskDevice *device = NULL,
BPartition **partition = NULL);
status_t GetDeviceWithID(partition_id id, BDiskDevice *device) const;
status_t GetPartitionWithID(partition_id id, BDiskDevice *device,
BPartition **partition) const;
status_t GetDiskSystem(BDiskSystem* system, const char* name);
status_t GetDeviceForPath(const char *filename, BDiskDevice *device);
status_t GetPartitionForPath(const char *filename, BDiskDevice *device,
BPartition **partition);
partition_id RegisterFileDevice(const char* filename);
// publishes: /dev/disk/virtual/files/<disk device ID>/raw
status_t UnregisterFileDevice(const char* filename);
status_t UnregisterFileDevice(partition_id device);
status_t StartWatching(BMessenger target,
uint32 eventMask = B_DEVICE_REQUEST_ALL);
status_t StopWatching(BMessenger target);
bool VisitEachDevice(BDiskDeviceVisitor* visitor,
BDiskDevice* device = NULL);
bool VisitEachPartition(BDiskDeviceVisitor* visitor,
BDiskDevice* device = NULL,
BPartition** _partition = NULL);
bool VisitEachMountedPartition(
BDiskDeviceVisitor* visitor,
BDiskDevice* device = NULL,
BPartition** _partition = NULL);
bool VisitEachMountablePartition(
BDiskDeviceVisitor* visitor,
BDiskDevice* device = NULL,
BPartition** _partition = NULL);
status_t GetDeviceWithID(partition_id id,
BDiskDevice* device) const;
status_t GetPartitionWithID(partition_id id,
BDiskDevice* device,
BPartition** _partition) const;
status_t GetDeviceForPath(const char* filename,
BDiskDevice* device);
status_t GetPartitionForPath(const char* filename,
BDiskDevice* device, BPartition** _partition);
status_t StartWatching(BMessenger target,
uint32 eventMask = B_DEVICE_REQUEST_ALL);
status_t StopWatching(BMessenger target);
private:
#if 0
@@ -146,9 +152,9 @@ private:
BDiskScannerPartitionAddOn **addOn);
#endif // 0
private:
int32 fDeviceCookie;
int32 fDiskSystemCookie;
int32 fJobCookie;
int32 fDeviceCookie;
int32 fDiskSystemCookie;
int32 fJobCookie;
// BDirectory *fPartitionAddOnDir;
// BDirectory *fFSAddOnDir;
// int32 fPartitionAddOnDirIndex;
+45 -40
View File
@@ -1,15 +1,14 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*
* Copyright 2003-2008, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _DISK_SYSTEM_H
#define _DISK_SYSTEM_H
#include <DiskDeviceDefs.h>
#include <String.h>
class BPartition;
class BString;
struct user_disk_system_info;
@@ -17,52 +16,58 @@ struct user_disk_system_info;
class BDiskSystem {
public:
BDiskSystem();
BDiskSystem(const BDiskSystem& other);
~BDiskSystem();
BDiskSystem();
BDiskSystem(const BDiskSystem& other);
~BDiskSystem();
status_t InitCheck() const;
status_t InitCheck() const;
const char *Name() const;
const char *PrettyName() const;
const char* Name() const;
const char* ShortName() const;
const char* PrettyName() const;
bool SupportsDefragmenting(bool *whileMounted) const;
bool SupportsRepairing(bool checkOnly, bool *whileMounted) const;
bool SupportsResizing(bool *whileMounted) const;
bool SupportsResizingChild() const;
bool SupportsMoving(bool *whileMounted) const;
bool SupportsMovingChild() const;
bool SupportsName() const;
bool SupportsContentName() const;
bool SupportsSettingName() const;
bool SupportsSettingContentName(bool *whileMounted) const;
bool SupportsSettingType() const;
bool SupportsSettingParameters() const;
bool SupportsSettingContentParameters(bool *whileMounted) const;
bool SupportsCreatingChild() const;
bool SupportsDeletingChild() const;
bool SupportsInitializing() const;
bool SupportsDefragmenting(bool* whileMounted) const;
bool SupportsRepairing(bool checkOnly,
bool* whileMounted) const;
bool SupportsResizing(bool* whileMounted) const;
bool SupportsResizingChild() const;
bool SupportsMoving(bool* whileMounted) const;
bool SupportsMovingChild() const;
bool SupportsName() const;
bool SupportsContentName() const;
bool SupportsSettingName() const;
bool SupportsSettingContentName(
bool* whileMounted) const;
bool SupportsSettingType() const;
bool SupportsSettingParameters() const;
bool SupportsSettingContentParameters(
bool* whileMounted) const;
bool SupportsCreatingChild() const;
bool SupportsDeletingChild() const;
bool SupportsInitializing() const;
status_t GetTypeForContentType(const char *contentType,
BString* type) const;
status_t GetTypeForContentType(const char* contentType,
BString* type) const;
bool IsPartitioningSystem() const;
bool IsFileSystem() const;
bool IsPartitioningSystem() const;
bool IsFileSystem() const;
BDiskSystem& operator=(const BDiskSystem& other);
BDiskSystem& operator=(const BDiskSystem& other);
private:
status_t _SetTo(disk_system_id id);
status_t _SetTo(const user_disk_system_info *info);
void _Unset();
status_t _SetTo(disk_system_id id);
status_t _SetTo(const user_disk_system_info* info);
void _Unset();
private:
friend class BDiskDeviceRoster;
friend class BPartition;
disk_system_id fID;
BString fName;
BString fPrettyName;
uint32 fFlags;
disk_system_id fID;
BString fName;
BString fShortName;
BString fPrettyName;
uint32 fFlags;
};
#endif // _DISK_SYSTEM_H
@@ -2288,7 +2288,8 @@ static file_system_module_info sBeFileSystem = {
bfs_std_ops,
},
"Be File System",
"bfs", // short_name
"Be File System", // pretty_name
// DDM flags
0
@@ -2006,7 +2006,8 @@ static file_system_module_info sCDDAFileSystem = {
cdda_std_ops,
},
"CDDA File System",
"cdda", // short_name
"CDDA File System", // pretty_name
0, // DDM flags
cdda_identify_partition,
+2 -1
View File
@@ -1313,7 +1313,8 @@ static file_system_module_info sFATFileSystem = {
dos_std_ops,
},
"FAT32 File System",
"fat", // short_name
"FAT32 File System", // pretty_name
0, // DDM flags
// scanning
@@ -1619,7 +1619,8 @@ static file_system_module_info sGoogleFSModule = {
googlefs_std_ops,
},
GOOGLEFS_PRETTY_NAME,
"googlefs", // short_name
GOOGLEFS_PRETTY_NAME, // pretty_name
0, // DDM flags
// scanning
@@ -745,8 +745,9 @@ static file_system_module_info sISO660FileSystem = {
iso_std_ops,
},
"ISO9660 File System",
0, // DDM flags
"iso9660", // short_name
"ISO9660 File System", // pretty_name
0, // DDM flags
// scanning
fs_identify_partition,
@@ -84,8 +84,9 @@ static file_system_module_info sNTFSFileSystem = {
ntfs_std_ops,
},
"ntfs File System",
0, // DDM flags
"ntfs", // short_name
"Windows NT File System", // pretty_name
0, // DDM flags
// scanning
fs_identify_partition,
@@ -2069,8 +2069,9 @@ static file_system_module_info sRamFSModuleInfo = {
ramfs_std_ops,
},
"RAM File System",
0, // DDM flags
"ramfs", // short_name
"RAM File System", // pretty_name
0, // DDM flags
// scanning
NULL, // identify_partition()
@@ -649,8 +649,9 @@ static file_system_module_info sReiserFSModuleInfo = {
reiserfs_std_ops,
},
"Reiser File System",
0, // DDM flags
"reiserfs", // short_name
"Reiser File System", // pretty_name
0, // DDM flags
// scanning
NULL, // identify_partition()
@@ -218,6 +218,7 @@ partition_module_info gAmigaPartitionModule = {
0,
amiga_rdb_std_ops
},
"amiga", // short_name
AMIGA_PARTITION_NAME, // pretty_name
0, // flags
@@ -203,6 +203,7 @@ partition_module_info gApplePartitionModule = {
0,
apple_std_ops
},
"apple", // short_name
APPLE_PARTITION_NAME, // pretty_name
0, // flags
@@ -1,7 +1,7 @@
/*
** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License.
*/
* Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "atari.h"
@@ -222,6 +222,7 @@ partition_module_info gAtariPartitionModule = {
0,
atari_std_ops
},
"atari", // short_name
ATARI_PARTITION_NAME, // pretty_name
0, // flags
@@ -240,4 +241,3 @@ partition_module_info *modules[] = {
NULL
};
#endif
@@ -1,5 +1,5 @@
/*
* Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2007-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
@@ -399,6 +399,7 @@ partition_module_info gEFIPartitionModule = {
0,
efi_gpt_std_ops
},
"efi", // short_name
EFI_PARTITION_NAME, // pretty_name
0, // flags
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
* Copyright 2003-2008, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -427,6 +427,7 @@ static partition_module_info intel_partition_map_module =
0,
pm_std_ops
},
"intel", // short_name
INTEL_PARTITION_NAME, // pretty_name
// flags
@@ -513,6 +514,7 @@ static partition_module_info intel_extended_partition_module =
0,
ep_std_ops
},
"intel_extended", // short_name
INTEL_EXTENDED_PARTITION_NAME, // pretty_name
// flags
@@ -114,6 +114,7 @@ static partition_module_info sSessionModule = {
0,
standard_operations
},
"session", // short_name
SESSION_PARTITION_NAME, // pretty_name
0, // flags
@@ -1,7 +1,11 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*
* Copyright 2003-2008, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ingo Weinhold, bonefish@cs.tu-berlin.de
* Axel Dörfler, axeld@pinc-software.de
*/
#include <new>
@@ -82,7 +86,7 @@ BDiskDeviceRoster::GetNextDevice(BDiskDevice *device)
return B_BAD_VALUE;
size_t neededSize = 0;
partition_id id = _kern_get_next_disk_device_id(&fDeviceCookie,
&neededSize);
&neededSize);
if (id < 0)
return id;
return device->_SetTo(id, true, neededSize);
@@ -99,21 +103,21 @@ BDiskDeviceRoster::RewindDevices()
return B_OK;
}
// GetNextDiskSystem
status_t
BDiskDeviceRoster::GetNextDiskSystem(BDiskSystem *system)
BDiskDeviceRoster::GetNextDiskSystem(BDiskSystem* system)
{
if (!system)
return B_BAD_VALUE;
user_disk_system_info info;
status_t error = _kern_get_next_disk_system_info(&fDiskSystemCookie,
&info);
&info);
if (error == B_OK)
error = system->_SetTo(&info);
return error;
}
// RewindDiskSystems
status_t
BDiskDeviceRoster::RewindDiskSystems()
{
@@ -122,7 +126,25 @@ BDiskDeviceRoster::RewindDiskSystems()
}
// RegisterFileDevice
status_t
BDiskDeviceRoster::GetDiskSystem(BDiskSystem* system, const char* name)
{
if (!system)
return B_BAD_VALUE;
int32 cookie = 0;
user_disk_system_info info;
while (_kern_get_next_disk_system_info(&fDiskSystemCookie, &info) == B_OK) {
if (!strcmp(name, info.name)
|| !strcmp(name, info.short_name)
|| !strcmp(name, info.pretty_name))
return system->_SetTo(&info);
}
return B_ENTRY_NOT_FOUND;
}
partition_id
BDiskDeviceRoster::RegisterFileDevice(const char *filename)
{
+24 -13
View File
@@ -16,20 +16,21 @@
// constructor
BDiskSystem::BDiskSystem()
: fID(B_NO_INIT),
fName(),
fPrettyName(),
fFlags(0)
:
fID(B_NO_INIT),
fFlags(0)
{
}
// copy constructor
BDiskSystem::BDiskSystem(const BDiskSystem& other)
: fID(other.fID),
fName(other.fName),
fPrettyName(other.fPrettyName),
fFlags(other.fFlags)
:
fID(other.fID),
fName(other.fName),
fShortName(other.fShortName),
fPrettyName(other.fPrettyName),
fFlags(other.fFlags)
{
}
@@ -44,7 +45,7 @@ BDiskSystem::~BDiskSystem()
status_t
BDiskSystem::InitCheck() const
{
return (fID > 0 ? B_OK : fID);
return fID > 0 ? B_OK : fID;
}
@@ -56,6 +57,14 @@ BDiskSystem::Name() const
}
// ShortName
const char*
BDiskSystem::ShortName() const
{
return fShortName.String();
}
// PrettyName
const char*
BDiskSystem::PrettyName() const
@@ -76,8 +85,8 @@ BDiskSystem::SupportsDefragmenting(bool* whileMounted) const
}
if (whileMounted) {
*whileMounted = (IsFileSystem()
&& (fFlags & B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING_WHILE_MOUNTED));
*whileMounted = IsFileSystem() && (fFlags
& B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING_WHILE_MOUNTED) != 0;
}
return true;
@@ -310,7 +319,7 @@ BDiskSystem::GetTypeForContentType(const char* contentType, BString* type) const
bool
BDiskSystem::IsPartitioningSystem() const
{
return (InitCheck() == B_OK && !(fFlags & B_DISK_SYSTEM_IS_FILE_SYSTEM));
return InitCheck() == B_OK && !(fFlags & B_DISK_SYSTEM_IS_FILE_SYSTEM);
}
@@ -318,7 +327,7 @@ BDiskSystem::IsPartitioningSystem() const
bool
BDiskSystem::IsFileSystem() const
{
return (InitCheck() == B_OK && (fFlags & B_DISK_SYSTEM_IS_FILE_SYSTEM));
return InitCheck() == B_OK && (fFlags & B_DISK_SYSTEM_IS_FILE_SYSTEM);
}
@@ -328,6 +337,7 @@ BDiskSystem::operator=(const BDiskSystem& other)
{
fID = other.fID;
fName = other.fName;
fShortName = other.fShortName;
fPrettyName = other.fPrettyName;
fFlags = other.fFlags;
@@ -364,6 +374,7 @@ BDiskSystem::_SetTo(const user_disk_system_info* info)
fID = info->id;
fName = info->name;
fShortName = info->short_name;
fPrettyName = info->pretty_name;
fFlags = info->flags;
@@ -22,6 +22,7 @@
KDiskSystem::KDiskSystem(const char *name)
: fID(_NextID()),
fName(NULL),
fShortName(NULL),
fPrettyName(NULL),
fLoadCounter(0)
{
@@ -33,6 +34,8 @@ KDiskSystem::KDiskSystem(const char *name)
KDiskSystem::~KDiskSystem()
{
free(fName);
free(fShortName);
free(fPrettyName);
}
@@ -40,7 +43,7 @@ KDiskSystem::~KDiskSystem()
status_t
KDiskSystem::Init()
{
return (fName ? B_OK : B_NO_MEMORY);
return fName ? B_OK : B_NO_MEMORY;
}
@@ -68,9 +71,17 @@ KDiskSystem::Name() const
}
// ShortName
const char *
KDiskSystem::ShortName() const
{
return fShortName;
}
// PrettyName
const char *
KDiskSystem::PrettyName()
KDiskSystem::PrettyName() const
{
return fPrettyName;
}
@@ -106,9 +117,11 @@ KDiskSystem::GetInfo(user_disk_system_info *info)
{
if (!info)
return;
info->id = ID();
strcpy(info->name, Name());
strcpy(info->pretty_name, PrettyName());
strlcpy(info->name, Name(), sizeof(info->name));
strlcpy(info->short_name, ShortName(), sizeof(info->short_name));
strlcpy(info->pretty_name, PrettyName(), sizeof(info->pretty_name));
info->flags = Flags();
}
@@ -339,6 +352,14 @@ KDiskSystem::UnloadModule()
}
// SetShortName
status_t
KDiskSystem::SetShortName(const char *name)
{
return set_string(fShortName, name);
}
// SetPrettyName
status_t
KDiskSystem::SetPrettyName(const char *name)
@@ -43,7 +43,10 @@ KFileSystem::Init()
error = Load();
if (error != B_OK)
return error;
error = SetPrettyName(fModule->pretty_name);
error = SetShortName(fModule->short_name);
if (error == B_OK)
error = SetPrettyName(fModule->pretty_name);
SetFlags(fModule->flags | B_DISK_SYSTEM_IS_FILE_SYSTEM);
Unload();
return error;
@@ -49,7 +49,10 @@ KPartitioningSystem::Init()
error = Load();
if (error != B_OK)
return error;
error = SetPrettyName(fModule->pretty_name);
error = SetShortName(fModule->short_name);
if (error == B_OK)
error = SetPrettyName(fModule->pretty_name);
SetFlags(fModule->flags & ~(uint32)B_DISK_SYSTEM_IS_FILE_SYSTEM);
Unload();
return error;
+3 -2
View File
@@ -2655,8 +2655,9 @@ file_system_module_info gDeviceFileSystem = {
devfs_std_ops,
},
"Device File System",
0, // DDM flags
"devfs", // short_name
"Device File System", // pretty_name
0, // DDM flags
NULL, // identify_partition()
NULL, // scan_partition()
+4 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -1216,8 +1216,9 @@ file_system_module_info gRootFileSystem = {
rootfs_std_ops,
},
"Root File System",
0, // DDM flags
"rootfs", // short_name
"Root File System", // pretty_name
0, // DDM flags
NULL, // identify_partition()
NULL, // scan_partition()