* Got rid of SetContentType(). It is set automatically now, to the
PrettyName() of the responsible disk system. * Added change counter support and changes tracking. * Added UninitializeContents(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4042 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -84,8 +84,8 @@ public:
|
|||||||
status_t SetType(const char *type);
|
status_t SetType(const char *type);
|
||||||
const char *Type() const;
|
const char *Type() const;
|
||||||
|
|
||||||
status_t SetContentType(const char *type);
|
|
||||||
const char *ContentType() const;
|
const char *ContentType() const;
|
||||||
|
// ContentType() == DiskSystem()->NamePretty()
|
||||||
|
|
||||||
// access to C style partition data
|
// access to C style partition data
|
||||||
partition_data *PartitionData();
|
partition_data *PartitionData();
|
||||||
@@ -153,6 +153,9 @@ public:
|
|||||||
void SetContentCookie(void *cookie);
|
void SetContentCookie(void *cookie);
|
||||||
void *ContentCookie() const;
|
void *ContentCookie() const;
|
||||||
|
|
||||||
|
void Changed(uint32 flags);
|
||||||
|
void UninitializeContents(bool logChanges = true);
|
||||||
|
|
||||||
virtual void WriteUserData(UserDataWriter &writer,
|
virtual void WriteUserData(UserDataWriter &writer,
|
||||||
user_partition_data *data);
|
user_partition_data *data);
|
||||||
|
|
||||||
@@ -170,6 +173,8 @@ protected:
|
|||||||
KDiskDevice *fDevice;
|
KDiskDevice *fDevice;
|
||||||
KPartition *fParent;
|
KPartition *fParent;
|
||||||
KDiskSystem *fDiskSystem;
|
KDiskSystem *fDiskSystem;
|
||||||
|
uint32 fChangeFlags;
|
||||||
|
int32 fChangeCounter;
|
||||||
int32 fReferenceCount;
|
int32 fReferenceCount;
|
||||||
bool fObsolete;
|
bool fObsolete;
|
||||||
static int32 fNextID;
|
static int32 fNextID;
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ KPartition::KPartition(partition_id id)
|
|||||||
fDevice(NULL),
|
fDevice(NULL),
|
||||||
fParent(NULL),
|
fParent(NULL),
|
||||||
fDiskSystem(NULL),
|
fDiskSystem(NULL),
|
||||||
|
fChangeFlags(0),
|
||||||
|
fChangeCounter(0),
|
||||||
fReferenceCount(0),
|
fReferenceCount(0),
|
||||||
fObsolete(false)
|
fObsolete(false)
|
||||||
{
|
{
|
||||||
@@ -61,7 +63,6 @@ KPartition::~KPartition()
|
|||||||
free(fPartitionData.name);
|
free(fPartitionData.name);
|
||||||
free(fPartitionData.content_name);
|
free(fPartitionData.content_name);
|
||||||
free(fPartitionData.type);
|
free(fPartitionData.type);
|
||||||
free(fPartitionData.content_type);
|
|
||||||
free(fPartitionData.parameters);
|
free(fPartitionData.parameters);
|
||||||
free(fPartitionData.content_parameters);
|
free(fPartitionData.content_parameters);
|
||||||
}
|
}
|
||||||
@@ -386,13 +387,6 @@ KPartition::Type() const
|
|||||||
return fPartitionData.type;
|
return fPartitionData.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetContentType
|
|
||||||
status_t
|
|
||||||
KPartition::SetContentType(const char *type)
|
|
||||||
{
|
|
||||||
return set_string(fPartitionData.content_type, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContentType
|
// ContentType
|
||||||
const char *
|
const char *
|
||||||
KPartition::ContentType() const
|
KPartition::ContentType() const
|
||||||
@@ -432,8 +426,7 @@ KPartition::ID() const
|
|||||||
int32
|
int32
|
||||||
KPartition::ChangeCounter() const
|
KPartition::ChangeCounter() const
|
||||||
{
|
{
|
||||||
// not implemented
|
return fChangeCounter;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPath
|
// GetPath
|
||||||
@@ -675,6 +668,7 @@ KPartition::SetDiskSystem(KDiskSystem *diskSystem)
|
|||||||
{
|
{
|
||||||
// unload former disk system
|
// unload former disk system
|
||||||
if (fDiskSystem) {
|
if (fDiskSystem) {
|
||||||
|
fPartitionData.content_type = NULL;
|
||||||
fDiskSystem->Unload();
|
fDiskSystem->Unload();
|
||||||
fDiskSystem = NULL;
|
fDiskSystem = NULL;
|
||||||
}
|
}
|
||||||
@@ -684,6 +678,7 @@ KPartition::SetDiskSystem(KDiskSystem *diskSystem)
|
|||||||
fDiskSystem->Load(); // can't fail, since it's already loaded
|
fDiskSystem->Load(); // can't fail, since it's already loaded
|
||||||
// update concerned partition flags
|
// update concerned partition flags
|
||||||
if (fDiskSystem) {
|
if (fDiskSystem) {
|
||||||
|
fPartitionData.content_type = fDiskSystem->PrettyName();
|
||||||
if (fDiskSystem->IsFileSystem())
|
if (fDiskSystem->IsFileSystem())
|
||||||
SetFlags(Flags() | B_PARTITION_FILE_SYSTEM);
|
SetFlags(Flags() | B_PARTITION_FILE_SYSTEM);
|
||||||
else
|
else
|
||||||
@@ -733,6 +728,43 @@ KPartition::ContentCookie() const
|
|||||||
return fPartitionData.content_cookie;
|
return fPartitionData.content_cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Changed
|
||||||
|
void
|
||||||
|
KPartition::Changed(uint32 flags)
|
||||||
|
{
|
||||||
|
fChangeFlags |= flags;
|
||||||
|
fChangeCounter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// UninitializeContents
|
||||||
|
void
|
||||||
|
KPartition::UninitializeContents(bool logChanges)
|
||||||
|
{
|
||||||
|
if (DiskSystem()) {
|
||||||
|
uint32 flags = B_PARTITION_CHANGED_CONTENT_TYPE
|
||||||
|
| B_PARTITION_CHANGED_STATUS
|
||||||
|
| B_PARTITION_CHANGED_FLAGS;
|
||||||
|
if (VolumeID() >= 0) {
|
||||||
|
// TODO: More? Unmounting would be a bit drastical for changes
|
||||||
|
// only on a shadow partition.
|
||||||
|
SetVolumeID(-1);
|
||||||
|
flags |= B_PARTITION_CHANGED_VOLUME;
|
||||||
|
}
|
||||||
|
if (ContentName()) {
|
||||||
|
SetContentName(NULL);
|
||||||
|
flags |= B_PARTITION_CHANGED_CONTENT_NAME;
|
||||||
|
}
|
||||||
|
if (ContentParameters()) {
|
||||||
|
SetContentParameters(NULL);
|
||||||
|
flags |= B_PARTITION_CHANGED_CONTENT_PARAMETERS;
|
||||||
|
}
|
||||||
|
DiskSystem()->FreeContentCookie(this);
|
||||||
|
SetDiskSystem(NULL);
|
||||||
|
if (logChanges)
|
||||||
|
Changed(flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WriteUserData
|
// WriteUserData
|
||||||
void
|
void
|
||||||
KPartition::WriteUserData(UserDataWriter &writer, user_partition_data *data)
|
KPartition::WriteUserData(UserDataWriter &writer, user_partition_data *data)
|
||||||
|
|||||||
Reference in New Issue
Block a user