file_cache_create() fails when it's called before the vnode is created.

Inode::SetFileSize() now changes the size of the cache as well.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10197 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-11-23 01:40:44 +00:00
parent 41eca62b69
commit 48f8c4e477
+5 -15
View File
@@ -226,23 +226,9 @@ Inode::Inode(Volume *volume, Transaction &transaction, vnode_id id, mode_t mode,
fTree = NULL;
fCache = NULL;
if (IsFile())
SetFileCache(file_cache_create(fVolume->ID(), ID(), Size(), fVolume->Device()));
}
/*
Inode::Inode(CachedBlock *cached)
:
fLock()
{
PRINT(("Inode::Inode(cached = %p) @ %p\n", cached, this));
Initialize();
}
*/
Inode::~Inode()
{
PRINT(("Inode::~Inode() @ %p\n", this));
@@ -1837,6 +1823,7 @@ Inode::SetFileSize(Transaction &transaction, off_t size)
if (status < B_OK)
return status;
file_cache_set_size(FileCache(), size);
return WriteBack(transaction);
}
@@ -2083,7 +2070,7 @@ status_t
Inode::Create(Transaction &transaction, Inode *parent, const char *name, int32 mode,
int openMode, uint32 type, off_t *_id, Inode **_inode)
{
FUNCTION();
FUNCTION_START(("name = %s, mode = %ld\n", name, mode));
block_run parentRun = parent ? parent->BlockRun() : block_run::Run(0, 0, 0);
Volume *volume = transaction.GetVolume();
@@ -2246,6 +2233,9 @@ Inode::Create(Transaction &transaction, Inode *parent, const char *name, int32 m
DIE(("new_vnode() failed for inode!"));
}
if (inode->IsFile())
inode->SetFileCache(file_cache_create(volume->ID(), inode->ID(), inode->Size(), volume->Device()));
if (_id != NULL)
*_id = inode->ID();
if (_inode != NULL)