* Added a method NeedsFileCache() that determines whether or not a file cache
should be allocated. * Inode::InitCheck() now fails if a file cache couldn't be allocated. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35272 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4e32bf0954
commit
c709a396cf
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2009, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Copyright 2001-2010, Axel Dörfler, axeld@pinc-software.de.
|
||||
* This file may be used under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -344,7 +344,7 @@ Inode::Inode(Volume* volume, ino_t id)
|
||||
|
||||
if (IsContainer())
|
||||
fTree = new BPlusTree(this);
|
||||
if (IsFile() || IsAttribute() || IsLongSymLink()) {
|
||||
if (NeedsFileCache()) {
|
||||
SetFileCache(file_cache_create(fVolume->ID(), ID(), Size()));
|
||||
SetMap(file_map_create(volume->ID(), ID(), Size()));
|
||||
}
|
||||
@ -430,6 +430,9 @@ Inode::InitCheck(bool checkNode)
|
||||
}
|
||||
}
|
||||
|
||||
if (NeedsFileCache() && (fCache == NULL || fMap == NULL))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -2671,7 +2674,7 @@ Inode::Create(Transaction& transaction, Inode* parent, const char* name,
|
||||
if (inode->InLastModifiedIndex())
|
||||
index.InsertLastModified(transaction, inode);
|
||||
|
||||
if (inode->IsFile() || inode->IsAttribute()) {
|
||||
if (inode->NeedsFileCache()) {
|
||||
inode->SetFileCache(file_cache_create(volume->ID(), inode->ID(),
|
||||
inode->Size()));
|
||||
inode->SetMap(file_map_create(volume->ID(), inode->ID(),
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2009, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Copyright 2001-2010, Axel Dörfler, axeld@pinc-software.de.
|
||||
* This file may be used under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef INODE_H
|
||||
@ -67,14 +67,18 @@ public:
|
||||
// a regular node in the standard namespace
|
||||
// (i.e. not an index or attribute)
|
||||
bool IsSymLink() const { return S_ISLNK(Mode()); }
|
||||
bool IsLongSymLink() const
|
||||
{ return (Flags() & INODE_LONG_SYMLINK) != 0; }
|
||||
|
||||
bool HasUserAccessableStream() const { return IsFile(); }
|
||||
// currently only files can be accessed with
|
||||
// bfs_read()/bfs_write()
|
||||
bool NeedsFileCache() const
|
||||
{ return IsFile() || IsAttribute()
|
||||
|| IsLongSymLink(); }
|
||||
|
||||
bool IsDeleted() const
|
||||
{ return (Flags() & INODE_DELETED) != 0; }
|
||||
bool IsLongSymLink() const
|
||||
{ return (Flags() & INODE_LONG_SYMLINK) != 0; }
|
||||
|
||||
mode_t Mode() const { return fNode.Mode(); }
|
||||
uint32 Type() const { return fNode.Type(); }
|
||||
|
Loading…
Reference in New Issue
Block a user