Author: axeld Date: 2010-01-24 14:02:18 +0100 (Sun, 24 Jan 2010) New Revision: 35272 Changeset: http://dev.haiku-os.org/changeset/35272/haiku Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h Log: * 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. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2010-01-24 12:15:31 UTC (rev 35271) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2010-01-24 13:02:18 UTC (rev 35272) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx + * Copyright 2001-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx * This file may be used under the terms of the MIT License. */ @@ -344,7 +344,7 @@ 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 @@ } } + if (NeedsFileCache() && (fCache == NULL || fMap == NULL)) + return B_NO_MEMORY; + return B_OK; } @@ -2671,7 +2674,7 @@ 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(), Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h 2010-01-24 12:15:31 UTC (rev 35271) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h 2010-01-24 13:02:18 UTC (rev 35272) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx + * Copyright 2001-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx * This file may be used under the terms of the MIT License. */ #ifndef INODE_H @@ -67,14 +67,18 @@ // 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(); }