* Moved the inode_types into Utilities.h.

* Added a S_EXTENDED_TYPES constant to simplify some checks.
* Simplified the fAllowDuplicates computation in BPlusTree::SetTo().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27625 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-09-18 15:22:29 +00:00
parent aecd884e05
commit 35a16d8f5e
3 changed files with 29 additions and 27 deletions
@@ -410,8 +410,7 @@ BPlusTree::SetTo(Transaction& transaction, Inode* stream, int32 nodeSize)
}
fHeader = header;
fAllowDuplicates = ((stream->Mode() & S_INDEX_DIR) == S_INDEX_DIR
&& stream->BlockRun() != stream->Parent())
fAllowDuplicates = stream->IsIndex()
|| (stream->Mode() & S_ALLOW_DUPS) != 0;
fNodeSize = nodeSize;
@@ -494,8 +493,7 @@ BPlusTree::SetTo(Inode* stream)
// although it's in stat.h, the S_ALLOW_DUPS flag is obviously unused
// in the original BFS code - we will honour it nevertheless
fAllowDuplicates = ((stream->Mode() & S_INDEX_DIR) == S_INDEX_DIR
&& stream->BlockRun() != stream->Parent())
fAllowDuplicates = stream->IsIndex()
|| (stream->Mode() & S_ALLOW_DUPS) != 0;
}
@@ -1713,11 +1711,11 @@ BPlusTree::Remove(Transaction& transaction, const uint8* key, uint16 keyLength,
if (fAllowDuplicates) {
return _RemoveDuplicate(transaction, node, cached,
nodeAndKey.keyIndex, value);
} else {
FATAL(("dupliate node found where no duplicates are "
"allowed!\n"));
RETURN_ERROR(B_ERROR);
}
FATAL(("dupliate node found where no duplicates are "
"allowed!\n"));
RETURN_ERROR(B_ERROR);
}
}
+6 -16
View File
@@ -23,16 +23,6 @@ class InodeReadLocker;
class NodeGetter;
class Transaction;
enum inode_type {
S_DIRECTORY = S_IFDIR,
S_FILE = S_IFREG,
S_SYMLINK = S_IFLNK,
S_INDEX_TYPES = (S_STR_INDEX | S_INT_INDEX | S_UINT_INDEX
| S_LONG_LONG_INDEX | S_ULONG_LONG_INDEX
| S_FLOAT_INDEX | S_DOUBLE_INDEX)
};
class Inode : public SinglyLinkedListLinkImpl<Inode> {
public:
@@ -61,16 +51,16 @@ public:
{ return is_index(Mode()); }
bool IsAttributeDirectory() const
{ return (Mode() & S_ATTR_DIR) != 0; }
{ return (Mode() & S_EXTENDED_TYPES)
== S_ATTR_DIR; }
bool IsAttribute() const
{ return (Mode() & S_ATTR) != 0; }
{ return (Mode() & S_EXTENDED_TYPES)
== S_ATTR; }
bool IsFile() const
{ return (Mode()
& (S_IFMT | S_ATTR)) == S_FILE; }
& (S_IFMT | S_EXTENDED_TYPES)) == S_FILE; }
bool IsRegularNode() const
{ return (Mode()
& (S_ATTR_DIR | S_INDEX_DIR | S_ATTR))
== 0; }
{ return (Mode() & S_EXTENDED_TYPES) == 0; }
// a regular node in the standard namespace
// (i.e. not an index or attribute)
bool IsSymLink() const { return S_ISLNK(Mode()); }
+17 -3
View File
@@ -9,6 +9,19 @@
#include "system_dependencies.h"
enum inode_type {
S_DIRECTORY = S_IFDIR,
S_FILE = S_IFREG,
S_SYMLINK = S_IFLNK,
S_INDEX_TYPES = (S_STR_INDEX | S_INT_INDEX | S_UINT_INDEX
| S_LONG_LONG_INDEX | S_ULONG_LONG_INDEX
| S_FLOAT_INDEX | S_DOUBLE_INDEX),
S_EXTENDED_TYPES = (S_ATTR_DIR | S_ATTR | S_INDEX_DIR)
};
// Simple array, used for the duplicate handling in the B+Tree
// TODO: this is not endian safe!!!
@@ -46,15 +59,16 @@ round_up(const IntType& value, const RoundType& to)
inline bool
is_index(int mode)
{
return (mode & (S_INDEX_DIR | 0777)) == S_INDEX_DIR;
// That's a stupid check, but AFAIK the only possible method...
return (mode & (S_EXTENDED_TYPES | 0777)) == S_INDEX_DIR;
// That's a stupid check, but the only method to differentiate the
// index root from an index.
}
inline bool
is_directory(int mode)
{
return (mode & (S_INDEX_DIR | S_ATTR_DIR | S_IFDIR)) == S_IFDIR;
return (mode & (S_EXTENDED_TYPES | S_IFDIR)) == S_IFDIR;
}