Added some more support for tracking changes.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4067 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
073eb9aead
commit
1d8675355f
@ -94,8 +94,6 @@ public:
|
|||||||
virtual void SetID(partition_id id);
|
virtual void SetID(partition_id id);
|
||||||
partition_id ID() const;
|
partition_id ID() const;
|
||||||
|
|
||||||
int32 ChangeCounter() const;
|
|
||||||
|
|
||||||
virtual status_t GetPath(char *path) const;
|
virtual status_t GetPath(char *path) const;
|
||||||
// no setter (see BDiskDevice) -- built on the fly
|
// no setter (see BDiskDevice) -- built on the fly
|
||||||
|
|
||||||
@ -153,9 +151,18 @@ public:
|
|||||||
void SetContentCookie(void *cookie);
|
void SetContentCookie(void *cookie);
|
||||||
void *ContentCookie() const;
|
void *ContentCookie() const;
|
||||||
|
|
||||||
void Changed(uint32 flags);
|
// Change Tracking
|
||||||
|
|
||||||
|
void Changed(uint32 flags, uint32 clearFlags = 0);
|
||||||
|
void SetChangeFlags(uint32 flags);
|
||||||
|
uint32 ChangeFlags() const;
|
||||||
|
int32 ChangeCounter() const;
|
||||||
void UninitializeContents(bool logChanges = true);
|
void UninitializeContents(bool logChanges = true);
|
||||||
|
|
||||||
|
void SetAlgorithmData(uint32 data);
|
||||||
|
uint32 AlgorithmData() const;
|
||||||
|
// temporary storage freely usable by algorithms
|
||||||
|
|
||||||
virtual void WriteUserData(UserDataWriter &writer,
|
virtual void WriteUserData(UserDataWriter &writer,
|
||||||
user_partition_data *data);
|
user_partition_data *data);
|
||||||
|
|
||||||
@ -175,6 +182,7 @@ protected:
|
|||||||
KDiskSystem *fDiskSystem;
|
KDiskSystem *fDiskSystem;
|
||||||
uint32 fChangeFlags;
|
uint32 fChangeFlags;
|
||||||
int32 fChangeCounter;
|
int32 fChangeCounter;
|
||||||
|
uint32 fAlgorithmData;
|
||||||
int32 fReferenceCount;
|
int32 fReferenceCount;
|
||||||
bool fObsolete;
|
bool fObsolete;
|
||||||
static int32 fNextID;
|
static int32 fNextID;
|
||||||
|
@ -34,6 +34,7 @@ KPartition::KPartition(partition_id id)
|
|||||||
fDiskSystem(NULL),
|
fDiskSystem(NULL),
|
||||||
fChangeFlags(0),
|
fChangeFlags(0),
|
||||||
fChangeCounter(0),
|
fChangeCounter(0),
|
||||||
|
fAlgorithmData(0),
|
||||||
fReferenceCount(0),
|
fReferenceCount(0),
|
||||||
fObsolete(false)
|
fObsolete(false)
|
||||||
{
|
{
|
||||||
@ -422,13 +423,6 @@ KPartition::ID() const
|
|||||||
return fPartitionData.id;
|
return fPartitionData.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeCounter
|
|
||||||
int32
|
|
||||||
KPartition::ChangeCounter() const
|
|
||||||
{
|
|
||||||
return fChangeCounter;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPath
|
// GetPath
|
||||||
status_t
|
status_t
|
||||||
KPartition::GetPath(char *path) const
|
KPartition::GetPath(char *path) const
|
||||||
@ -730,10 +724,34 @@ KPartition::ContentCookie() const
|
|||||||
|
|
||||||
// Changed
|
// Changed
|
||||||
void
|
void
|
||||||
KPartition::Changed(uint32 flags)
|
KPartition::Changed(uint32 flags, uint32 clearFlags)
|
||||||
{
|
{
|
||||||
|
fChangeFlags &= ~clearFlags;
|
||||||
fChangeFlags |= flags;
|
fChangeFlags |= flags;
|
||||||
fChangeCounter++;
|
fChangeCounter++;
|
||||||
|
if (Parent())
|
||||||
|
Parent()->Changed(B_PARTITION_CHANGED_DESCENDANTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetChangeFlags
|
||||||
|
void
|
||||||
|
KPartition::SetChangeFlags(uint32 flags)
|
||||||
|
{
|
||||||
|
fChangeFlags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChangeFlags
|
||||||
|
uint32
|
||||||
|
KPartition::ChangeFlags() const
|
||||||
|
{
|
||||||
|
return fChangeFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChangeCounter
|
||||||
|
int32
|
||||||
|
KPartition::ChangeCounter() const
|
||||||
|
{
|
||||||
|
return fChangeCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UninitializeContents
|
// UninitializeContents
|
||||||
@ -741,29 +759,69 @@ void
|
|||||||
KPartition::UninitializeContents(bool logChanges)
|
KPartition::UninitializeContents(bool logChanges)
|
||||||
{
|
{
|
||||||
if (DiskSystem()) {
|
if (DiskSystem()) {
|
||||||
uint32 flags = B_PARTITION_CHANGED_CONTENT_TYPE
|
uint32 flags = B_PARTITION_CHANGED_INITIALIZATION
|
||||||
|
| B_PARTITION_CHANGED_CONTENT_TYPE
|
||||||
| B_PARTITION_CHANGED_STATUS
|
| B_PARTITION_CHANGED_STATUS
|
||||||
| B_PARTITION_CHANGED_FLAGS;
|
| B_PARTITION_CHANGED_FLAGS;
|
||||||
|
// children
|
||||||
|
if (CountChildren() > 0) {
|
||||||
|
RemoveAllChildren();
|
||||||
|
flags |= B_PARTITION_CHANGED_CHILDREN;
|
||||||
|
}
|
||||||
|
// volume
|
||||||
if (VolumeID() >= 0) {
|
if (VolumeID() >= 0) {
|
||||||
// TODO: More? Unmounting would be a bit drastical for changes
|
// TODO: More? Unmounting would be a bit drastical for changes
|
||||||
// only on a shadow partition.
|
// only on a shadow partition.
|
||||||
SetVolumeID(-1);
|
SetVolumeID(-1);
|
||||||
flags |= B_PARTITION_CHANGED_VOLUME;
|
flags |= B_PARTITION_CHANGED_VOLUME;
|
||||||
}
|
}
|
||||||
|
// content name
|
||||||
if (ContentName()) {
|
if (ContentName()) {
|
||||||
SetContentName(NULL);
|
SetContentName(NULL);
|
||||||
flags |= B_PARTITION_CHANGED_CONTENT_NAME;
|
flags |= B_PARTITION_CHANGED_CONTENT_NAME;
|
||||||
}
|
}
|
||||||
|
// content parameters
|
||||||
if (ContentParameters()) {
|
if (ContentParameters()) {
|
||||||
SetContentParameters(NULL);
|
SetContentParameters(NULL);
|
||||||
flags |= B_PARTITION_CHANGED_CONTENT_PARAMETERS;
|
flags |= B_PARTITION_CHANGED_CONTENT_PARAMETERS;
|
||||||
}
|
}
|
||||||
|
// block size
|
||||||
|
if (Parent() && Parent()->BlockSize() != BlockSize()) {
|
||||||
|
SetBlockSize(Parent()->BlockSize());
|
||||||
|
flags |= B_PARTITION_CHANGED_BLOCK_SIZE;
|
||||||
|
}
|
||||||
|
// disk system
|
||||||
DiskSystem()->FreeContentCookie(this);
|
DiskSystem()->FreeContentCookie(this);
|
||||||
SetDiskSystem(NULL);
|
SetDiskSystem(NULL);
|
||||||
if (logChanges)
|
// status
|
||||||
Changed(flags);
|
SetStatus(B_PARTITION_UNINITIALIZED);
|
||||||
|
// flags
|
||||||
|
SetFlags(Flags() & ~uint32(B_PARTITION_FILE_SYSTEM
|
||||||
|
| B_PARTITION_PARTITIONING_SYSTEM));
|
||||||
|
if (!Device()->IsReadOnlyMedia())
|
||||||
|
SetFlags(Flags() & ~(uint32)B_PARTITION_READ_ONLY);
|
||||||
|
// log changes
|
||||||
|
if (logChanges) {
|
||||||
|
Changed(flags, B_PARTITION_CHANGED_DEFRAGMENTATION
|
||||||
|
| B_PARTITION_CHANGED_CHECK
|
||||||
|
| B_PARTITION_CHANGED_REPAIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAlgorithmData
|
||||||
|
void
|
||||||
|
KPartition::SetAlgorithmData(uint32 data)
|
||||||
|
{
|
||||||
|
fAlgorithmData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AlgorithmData
|
||||||
|
uint32
|
||||||
|
KPartition::AlgorithmData() const
|
||||||
|
{
|
||||||
|
return fAlgorithmData;
|
||||||
|
}
|
||||||
|
|
||||||
// WriteUserData
|
// WriteUserData
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user