Added some ASSERTs that the Index::Update*/Insert*/Remove*() methods are used
only for inodes that maintain those indices. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19123 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/* Index - index access functions
|
/* Index - index access functions
|
||||||
*
|
*
|
||||||
* Copyright 2001-2004, Axel Dörfler, [email protected].
|
* Copyright 2001-2006, Axel Dörfler, [email protected].
|
||||||
* This file may be used under the terms of the MIT License.
|
* This file may be used under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -292,18 +292,23 @@ Index::RemoveName(Transaction &transaction, const char *name, Inode *inode)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Index::UpdateName(Transaction &transaction, const char *oldName, const char *newName, Inode *inode)
|
Index::UpdateName(Transaction &transaction, const char *oldName,
|
||||||
|
const char *newName, Inode *inode)
|
||||||
{
|
{
|
||||||
|
ASSERT(inode->IsRegularNode());
|
||||||
|
|
||||||
uint16 oldLength = oldName ? strlen(oldName) : 0;
|
uint16 oldLength = oldName ? strlen(oldName) : 0;
|
||||||
uint16 newLength = newName ? strlen(newName) : 0;
|
uint16 newLength = newName ? strlen(newName) : 0;
|
||||||
return Update(transaction, "name", B_STRING_TYPE, (uint8 *)oldName, oldLength,
|
return Update(transaction, "name", B_STRING_TYPE, (uint8 *)oldName,
|
||||||
(uint8 *)newName, newLength, inode);
|
oldLength, (uint8 *)newName, newLength, inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Index::InsertSize(Transaction &transaction, Inode *inode)
|
Index::InsertSize(Transaction &transaction, Inode *inode)
|
||||||
{
|
{
|
||||||
|
ASSERT(inode->IsFile());
|
||||||
|
|
||||||
off_t size = inode->Size();
|
off_t size = inode->Size();
|
||||||
return Update(transaction, "size", B_INT64_TYPE, NULL, 0, (uint8 *)&size, sizeof(int64), inode);
|
return Update(transaction, "size", B_INT64_TYPE, NULL, 0, (uint8 *)&size, sizeof(int64), inode);
|
||||||
}
|
}
|
||||||
@@ -312,6 +317,8 @@ Index::InsertSize(Transaction &transaction, Inode *inode)
|
|||||||
status_t
|
status_t
|
||||||
Index::RemoveSize(Transaction &transaction, Inode *inode)
|
Index::RemoveSize(Transaction &transaction, Inode *inode)
|
||||||
{
|
{
|
||||||
|
ASSERT(inode->IsFile());
|
||||||
|
|
||||||
// Inode::OldSize() is the size that's in the index
|
// Inode::OldSize() is the size that's in the index
|
||||||
off_t size = inode->OldSize();
|
off_t size = inode->OldSize();
|
||||||
return Update(transaction, "size", B_INT64_TYPE, (uint8 *)&size, sizeof(int64), NULL, 0, inode);
|
return Update(transaction, "size", B_INT64_TYPE, (uint8 *)&size, sizeof(int64), NULL, 0, inode);
|
||||||
@@ -321,6 +328,8 @@ Index::RemoveSize(Transaction &transaction, Inode *inode)
|
|||||||
status_t
|
status_t
|
||||||
Index::UpdateSize(Transaction &transaction, Inode *inode)
|
Index::UpdateSize(Transaction &transaction, Inode *inode)
|
||||||
{
|
{
|
||||||
|
ASSERT(inode->IsFile());
|
||||||
|
|
||||||
off_t oldSize = inode->OldSize();
|
off_t oldSize = inode->OldSize();
|
||||||
off_t newSize = inode->Size();
|
off_t newSize = inode->Size();
|
||||||
|
|
||||||
@@ -336,6 +345,8 @@ Index::UpdateSize(Transaction &transaction, Inode *inode)
|
|||||||
status_t
|
status_t
|
||||||
Index::InsertLastModified(Transaction &transaction, Inode *inode)
|
Index::InsertLastModified(Transaction &transaction, Inode *inode)
|
||||||
{
|
{
|
||||||
|
ASSERT(inode->IsFile() || inode->IsSymLink());
|
||||||
|
|
||||||
off_t modified = inode->LastModified();
|
off_t modified = inode->LastModified();
|
||||||
return Update(transaction, "last_modified", B_INT64_TYPE, NULL, 0,
|
return Update(transaction, "last_modified", B_INT64_TYPE, NULL, 0,
|
||||||
(uint8 *)&modified, sizeof(int64), inode);
|
(uint8 *)&modified, sizeof(int64), inode);
|
||||||
@@ -345,6 +356,8 @@ Index::InsertLastModified(Transaction &transaction, Inode *inode)
|
|||||||
status_t
|
status_t
|
||||||
Index::RemoveLastModified(Transaction &transaction, Inode *inode)
|
Index::RemoveLastModified(Transaction &transaction, Inode *inode)
|
||||||
{
|
{
|
||||||
|
ASSERT(inode->IsFile() || inode->IsSymLink());
|
||||||
|
|
||||||
// Inode::OldLastModified() is the value which is in the index
|
// Inode::OldLastModified() is the value which is in the index
|
||||||
off_t modified = inode->OldLastModified();
|
off_t modified = inode->OldLastModified();
|
||||||
return Update(transaction, "last_modified", B_INT64_TYPE, (uint8 *)&modified,
|
return Update(transaction, "last_modified", B_INT64_TYPE, (uint8 *)&modified,
|
||||||
@@ -355,6 +368,8 @@ Index::RemoveLastModified(Transaction &transaction, Inode *inode)
|
|||||||
status_t
|
status_t
|
||||||
Index::UpdateLastModified(Transaction &transaction, Inode *inode, off_t modified)
|
Index::UpdateLastModified(Transaction &transaction, Inode *inode, off_t modified)
|
||||||
{
|
{
|
||||||
|
ASSERT(inode->IsFile() || inode->IsSymLink());
|
||||||
|
|
||||||
off_t oldModified = inode->OldLastModified();
|
off_t oldModified = inode->OldLastModified();
|
||||||
if (modified == -1)
|
if (modified == -1)
|
||||||
modified = (bigtime_t)time(NULL) << INODE_TIME_SHIFT;
|
modified = (bigtime_t)time(NULL) << INODE_TIME_SHIFT;
|
||||||
|
|||||||
Reference in New Issue
Block a user