* 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:
@@ -410,8 +410,7 @@ BPlusTree::SetTo(Transaction& transaction, Inode* stream, int32 nodeSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fHeader = header;
|
fHeader = header;
|
||||||
fAllowDuplicates = ((stream->Mode() & S_INDEX_DIR) == S_INDEX_DIR
|
fAllowDuplicates = stream->IsIndex()
|
||||||
&& stream->BlockRun() != stream->Parent())
|
|
||||||
|| (stream->Mode() & S_ALLOW_DUPS) != 0;
|
|| (stream->Mode() & S_ALLOW_DUPS) != 0;
|
||||||
|
|
||||||
fNodeSize = nodeSize;
|
fNodeSize = nodeSize;
|
||||||
@@ -494,8 +493,7 @@ BPlusTree::SetTo(Inode* stream)
|
|||||||
|
|
||||||
// although it's in stat.h, the S_ALLOW_DUPS flag is obviously unused
|
// although it's in stat.h, the S_ALLOW_DUPS flag is obviously unused
|
||||||
// in the original BFS code - we will honour it nevertheless
|
// in the original BFS code - we will honour it nevertheless
|
||||||
fAllowDuplicates = ((stream->Mode() & S_INDEX_DIR) == S_INDEX_DIR
|
fAllowDuplicates = stream->IsIndex()
|
||||||
&& stream->BlockRun() != stream->Parent())
|
|
||||||
|| (stream->Mode() & S_ALLOW_DUPS) != 0;
|
|| (stream->Mode() & S_ALLOW_DUPS) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1713,11 +1711,11 @@ BPlusTree::Remove(Transaction& transaction, const uint8* key, uint16 keyLength,
|
|||||||
if (fAllowDuplicates) {
|
if (fAllowDuplicates) {
|
||||||
return _RemoveDuplicate(transaction, node, cached,
|
return _RemoveDuplicate(transaction, node, cached,
|
||||||
nodeAndKey.keyIndex, value);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,16 +23,6 @@ class InodeReadLocker;
|
|||||||
class NodeGetter;
|
class NodeGetter;
|
||||||
class Transaction;
|
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> {
|
class Inode : public SinglyLinkedListLinkImpl<Inode> {
|
||||||
public:
|
public:
|
||||||
@@ -61,16 +51,16 @@ public:
|
|||||||
{ return is_index(Mode()); }
|
{ return is_index(Mode()); }
|
||||||
|
|
||||||
bool IsAttributeDirectory() const
|
bool IsAttributeDirectory() const
|
||||||
{ return (Mode() & S_ATTR_DIR) != 0; }
|
{ return (Mode() & S_EXTENDED_TYPES)
|
||||||
|
== S_ATTR_DIR; }
|
||||||
bool IsAttribute() const
|
bool IsAttribute() const
|
||||||
{ return (Mode() & S_ATTR) != 0; }
|
{ return (Mode() & S_EXTENDED_TYPES)
|
||||||
|
== S_ATTR; }
|
||||||
bool IsFile() const
|
bool IsFile() const
|
||||||
{ return (Mode()
|
{ return (Mode()
|
||||||
& (S_IFMT | S_ATTR)) == S_FILE; }
|
& (S_IFMT | S_EXTENDED_TYPES)) == S_FILE; }
|
||||||
bool IsRegularNode() const
|
bool IsRegularNode() const
|
||||||
{ return (Mode()
|
{ return (Mode() & S_EXTENDED_TYPES) == 0; }
|
||||||
& (S_ATTR_DIR | S_INDEX_DIR | S_ATTR))
|
|
||||||
== 0; }
|
|
||||||
// a regular node in the standard namespace
|
// a regular node in the standard namespace
|
||||||
// (i.e. not an index or attribute)
|
// (i.e. not an index or attribute)
|
||||||
bool IsSymLink() const { return S_ISLNK(Mode()); }
|
bool IsSymLink() const { return S_ISLNK(Mode()); }
|
||||||
|
|||||||
@@ -9,6 +9,19 @@
|
|||||||
#include "system_dependencies.h"
|
#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
|
// Simple array, used for the duplicate handling in the B+Tree
|
||||||
// TODO: this is not endian safe!!!
|
// TODO: this is not endian safe!!!
|
||||||
|
|
||||||
@@ -46,15 +59,16 @@ round_up(const IntType& value, const RoundType& to)
|
|||||||
inline bool
|
inline bool
|
||||||
is_index(int mode)
|
is_index(int mode)
|
||||||
{
|
{
|
||||||
return (mode & (S_INDEX_DIR | 0777)) == S_INDEX_DIR;
|
return (mode & (S_EXTENDED_TYPES | 0777)) == S_INDEX_DIR;
|
||||||
// That's a stupid check, but AFAIK the only possible method...
|
// That's a stupid check, but the only method to differentiate the
|
||||||
|
// index root from an index.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
is_directory(int mode)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user