From 2b5451f1642e72a8bd34ccabac5c0b670f09f664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 17 Sep 2002 01:26:18 +0000 Subject: [PATCH] Added private non-implemented copy constructor and assignment operators for many classes for the sake of completeness. Added a Transaction::IsStarted() method to not let it look like as if the transaction is started more than once. Changes made after suggestions from Mike Nordell, again :-) git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1067 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/bfs/BPlusTree.h | 24 +++++++++++-------- .../file_systems/bfs/BlockAllocator.cpp | 1 + src/add-ons/kernel/file_systems/bfs/Index.h | 4 ++++ src/add-ons/kernel/file_systems/bfs/Inode.h | 9 +++++++ src/add-ons/kernel/file_systems/bfs/Journal.h | 7 +++++- src/add-ons/kernel/file_systems/bfs/Query.cpp | 17 +++++++++---- src/add-ons/kernel/file_systems/bfs/Query.h | 4 ++++ src/add-ons/kernel/file_systems/bfs/Stream.h | 7 ++++-- .../file_systems/bfs/kernel_interface.cpp | 4 ++-- 9 files changed, 58 insertions(+), 19 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/BPlusTree.h b/src/add-ons/kernel/file_systems/bfs/BPlusTree.h index 402db41f84..d3bd8ecf3a 100644 --- a/src/add-ons/kernel/file_systems/bfs/BPlusTree.h +++ b/src/add-ons/kernel/file_systems/bfs/BPlusTree.h @@ -162,7 +162,7 @@ class CachedNode { class BPlusTree { public: - BPlusTree(Transaction *transaction,Inode *stream,int32 nodeSize = BPLUSTREE_NODE_SIZE); + BPlusTree(Transaction *transaction, Inode *stream, int32 nodeSize = BPLUSTREE_NODE_SIZE); BPlusTree(Inode *stream); BPlusTree(); ~BPlusTree(); @@ -174,16 +174,16 @@ class BPlusTree { status_t InitCheck(); status_t Validate(); - status_t Remove(Transaction *transaction,const uint8 *key, uint16 keyLength, off_t value); - status_t Insert(Transaction *transaction,const uint8 *key, uint16 keyLength, off_t value); + status_t Remove(Transaction *transaction, const uint8 *key, uint16 keyLength, off_t value); + status_t Insert(Transaction *transaction, const uint8 *key, uint16 keyLength, off_t value); - status_t Insert(Transaction *transaction,const char *key, off_t value); - status_t Insert(Transaction *transaction,int32 key, off_t value); - status_t Insert(Transaction *transaction,uint32 key, off_t value); - status_t Insert(Transaction *transaction,int64 key, off_t value); - status_t Insert(Transaction *transaction,uint64 key, off_t value); - status_t Insert(Transaction *transaction,float key, off_t value); - status_t Insert(Transaction *transaction,double key, off_t value); + status_t Insert(Transaction *transaction, const char *key, off_t value); + status_t Insert(Transaction *transaction, int32 key, off_t value); + status_t Insert(Transaction *transaction, uint32 key, off_t value); + status_t Insert(Transaction *transaction, int64 key, off_t value); + status_t Insert(Transaction *transaction, uint64 key, off_t value); + status_t Insert(Transaction *transaction, float key, off_t value); + status_t Insert(Transaction *transaction, double key, off_t value); status_t Replace(Transaction *transaction, const uint8 *key, uint16 keyLength, off_t value); status_t Find(const uint8 *key, uint16 keyLength, off_t *value); @@ -192,6 +192,10 @@ class BPlusTree { static int32 ModeToKeyType(mode_t mode); private: + BPlusTree(const BPlusTree &); + BPlusTree &operator=(const BPlusTree &); + // no implementation + int32 CompareKeys(const void *key1, int keylength1, const void *key2, int keylength2); status_t FindKey(bplustree_node *node, const uint8 *key, uint16 keyLength, uint16 *index = NULL, off_t *next = NULL); status_t SeekDown(Stack &stack, const uint8 *key, uint16 keyLength); diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp index 4e8c5435b9..0fe8e2754d 100644 --- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp @@ -92,6 +92,7 @@ AllocationBlock::IsUsed(uint16 block) { if (block > fNumBits) return true; + // the block bitmap is accessed in 32-bit blocks return ((uint32 *)fBlock)[block >> 5] & (1UL << (block % 32)); } diff --git a/src/add-ons/kernel/file_systems/bfs/Index.h b/src/add-ons/kernel/file_systems/bfs/Index.h index 5e65953614..2cd91cfaf1 100644 --- a/src/add-ons/kernel/file_systems/bfs/Index.h +++ b/src/add-ons/kernel/file_systems/bfs/Index.h @@ -43,6 +43,10 @@ class Index { status_t UpdateLastModified(Transaction *transaction, Inode *inode,off_t modified = -1); private: + Index(const Index &); + Index &operator=(const Index &); + // no implementation + Volume *fVolume; Inode *fNode; const char *fName; diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.h b/src/add-ons/kernel/file_systems/bfs/Inode.h index 52d9f242d8..692bbf3c08 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.h +++ b/src/add-ons/kernel/file_systems/bfs/Inode.h @@ -110,6 +110,11 @@ class CachedBlock { uint32 BlockSize() const { return fVolume->BlockSize(); } uint32 BlockShift() const { return fVolume->BlockShift(); } + private: + CachedBlock(const CachedBlock &); + CachedBlock &operator=(const CachedBlock &); + // no implementation + protected: Volume *fVolume; off_t fBlockNumber; @@ -198,6 +203,10 @@ class Inode : public CachedBlock { off_t OldLastModified() { return fOldLastModified; } private: + Inode(const Inode &); + Inode &operator=(const Inode &); + // no implementation + friend AttributeIterator; status_t RemoveSmallData(small_data *item,int32 index); diff --git a/src/add-ons/kernel/file_systems/bfs/Journal.h b/src/add-ons/kernel/file_systems/bfs/Journal.h index 1370932aa2..55e6dc96eb 100644 --- a/src/add-ons/kernel/file_systems/bfs/Journal.h +++ b/src/add-ons/kernel/file_systems/bfs/Journal.h @@ -125,6 +125,7 @@ class Transaction { } status_t Start(Volume *volume, off_t refBlock); + bool IsStarted() const { return fJournal != NULL; } void Done() { @@ -143,7 +144,11 @@ class Transaction { Volume *GetVolume() { return fJournal != NULL ? fJournal->GetVolume() : NULL; } - protected: + private: + Transaction(const Transaction &); + Transaction &operator=(const Transaction &); + // no implementation + Journal *fJournal; }; diff --git a/src/add-ons/kernel/file_systems/bfs/Query.cpp b/src/add-ons/kernel/file_systems/bfs/Query.cpp index cc55613072..5e919ea3c4 100644 --- a/src/add-ons/kernel/file_systems/bfs/Query.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Query.cpp @@ -141,6 +141,10 @@ class Equation : public Term { #endif private: + Equation(const Equation &); + Equation &operator=(const Equation &); + // no implementation + status_t ConvertValue(type_code type); bool CompareTo(const uint8 *value, uint16 size); uint8 *Value() const { return (uint8 *)&fValue; } @@ -166,12 +170,13 @@ class Operator : public Term { Term *Left() const { return fLeft; } Term *Right() const { return fRight; } - virtual status_t Match(Inode *inode,const char *attribute = NULL,int32 type = 0,const uint8 *key = NULL,size_t size = 0); + virtual status_t Match(Inode *inode, const char *attribute = NULL, int32 type = 0, + const uint8 *key = NULL, size_t size = 0); virtual void Complement(); - + virtual void CalculateScore(Index &index); virtual int32 Score() const; - + virtual status_t InitCheck(); //Term *Copy() const; @@ -179,7 +184,11 @@ class Operator : public Term { virtual void PrintToStream(); #endif - protected: + private: + Operator(const Operator &); + Operator &operator=(const Operator &); + // no implementation + Term *fLeft,*fRight; }; diff --git a/src/add-ons/kernel/file_systems/bfs/Query.h b/src/add-ons/kernel/file_systems/bfs/Query.h index 50f3779063..f361721e9a 100644 --- a/src/add-ons/kernel/file_systems/bfs/Query.h +++ b/src/add-ons/kernel/file_systems/bfs/Query.h @@ -37,6 +37,10 @@ class Expression { bool IsOperator(char **expr,char op); private: + Expression(const Expression &); + Expression &operator=(const Expression &); + // no implementation + char *fPosition; Term *fTerm; }; diff --git a/src/add-ons/kernel/file_systems/bfs/Stream.h b/src/add-ons/kernel/file_systems/bfs/Stream.h index 76e6fc6120..fd21381854 100644 --- a/src/add-ons/kernel/file_systems/bfs/Stream.h +++ b/src/add-ons/kernel/file_systems/bfs/Stream.h @@ -496,7 +496,9 @@ Stream::WriteAt(Transaction *transaction, off_t pos, const uint8 *buffer, return B_BAD_VALUE; // the transaction doesn't have to be started already - if ((Flags() & INODE_NO_TRANSACTION) == 0) + // ToDo: what's that INODE_NO_TRANSACTION flag good for again? + if ((Flags() & INODE_NO_TRANSACTION) == 0 + && !transaction->IsStarted()) transaction->Start(fVolume, BlockNumber()); // let's grow the data stream to the size needed @@ -519,7 +521,8 @@ Stream::WriteAt(Transaction *transaction, off_t pos, const uint8 *buffer, } bool logStream = (Flags() & INODE_LOGGED) == INODE_LOGGED; - if (logStream) + if (logStream + && !transaction->IsStarted()) transaction->Start(fVolume, BlockNumber()); uint32 bytesWritten = 0; diff --git a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp index 6ae7aa0dd6..a977939ebb 100644 --- a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp @@ -1170,7 +1170,7 @@ bfs_write(void *_ns, void *_node, void *_cookie, off_t pos, const void *buffer, // it might not be needed at all status_t status = inode->WriteAt(&transaction,pos,(const uint8 *)buffer,_length); - + if (status == B_OK) transaction.Done(); @@ -1186,7 +1186,7 @@ bfs_write(void *_ns, void *_node, void *_cookie, off_t pos, const void *buffer, cookie->last_size = inode->Size(); cookie->last_notification = system_time(); } - + // This will flush the dirty blocks to disk from time to time. // It's done here and not in Inode::WriteAt() so that it won't // add to the duration of a transaction - it might even be a