History log of /haiku/src/add-ons/kernel/file_systems/bfs/Inode.cpp
Revision Date Author Comments
# 53bc9ad0 28-Nov-2023 Alexander von Gluck IV <kallisti5@unixzen.com>

bfs: Reduce potential for garbage value ingestion

* Pointed out by clang static analysis. These are
later read while not being completely validated.

Change-Id: I4546526535d6e011aee40c74136f992962ab8cff
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7159
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 425ac1b6 20-Jun-2023 Alexander von Gluck IV <kallisti5@unixzen.com>

refactor: Swap %Ld for %lld in all format usages

* %Ld is an undocumented alias for %lld in glibc.
* muslc doesn't implement it for this reason.
* While we will likely never drop %Ld support,
lets clean house and set a better example.

Change-Id: Id46dad3104abae483e80cc5c05d1464d3ecd8030
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6636
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 3d43a905 30-Aug-2020 John Scipione <jscipione@gmail.com>

bfs: Enable logging on DEBUG build

Fix DEBUG build errors by using B_PRI macros in BlockAllocator.cpp,
CheckVisitor.cpp, Inode.cpp, Journal.cpp, and kernel_interface.cpp

Add optional type parameter from BlockAllocator::IsValidBlockRun()
and actually PRINT it, type parameter is already optional on
BlockAllocator::CheckBlockRun().

Remove a couple of casts as we are printing the expected type, int32.

Cast mode_t to (unsigned int) and use %u because 32-bit Haiku didn't
like B_PRIu32.

Verified to compile on both regular and DEBUG builds on both 32-bit
and 64-bit.

Change-Id: I8bb39afd400768b7f69d36384974f0b91b3ef48c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3184
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: John Scipione <jscipione@gmail.com>


# 93845aec 11-Jun-2020 Axel Dörfler <axeld@pinc-software.de>

block_cache: Change signature of *_etc() functions

* This allows file systems to retrieve the actual error code on a
failure, and report it to the user.
* All affected file systems have been adjusted to the API change.
This is a binary incompatible change.

Change-Id: Id73392aaf9c6cb7d643ff9adcb8bf80f3037874c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2913
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 5d17f05f 19-Feb-2020 X512 <danger_mail@list.ru>

BFS: allow deleting "bad data" files

"bad data" files now can be deleted with "rm --force <name>".

Fixes #15730.

Change-Id: I44bda91f3c2198d30212b4d7791a9b55f947c926
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2257
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 097bbc7f 29-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

file_systems: Remove now-redundant bounds checks before file_cache_read().

Change-Id: Iafb7d188c7e7cb4406d924eb3354a7ede40c6641
Reviewed-on: https://review.haiku-os.org/c/1421
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Michael Lotz <mmlr@mlotz.ch>


# 79707fef 08-Jan-2018 Jérôme Duval <jerome.duval@gmail.com>

bfs: INode::ReadAttribute() and WriteAttribute() used the user buffer directly

They now use user_memcpy(). Also copy the user buffer used to update the index.


# 4069e1f3 08-Apr-2017 Axel Dörfler <axeld@pinc-software.de>

BFS: Fixed maximum index key length.

* The maximum key length of the B+tree, and the one BFS uses are now
separated. This allows to stay BeOS compatible to only put a maximum
of 255 bytes into the index, but also to handle the already existing
larger keys (we did allow 256 bytes) without issue.
* TreeIterator::Traverse() now always cuts off string keys at the
maximum buffer length, and only reports a B_BUFFER_OVERFLOW for the
fixed length types.
* This fixes the important part of #13254.


# 91cdfd96 19-Jan-2017 Axel Dörfler <axeld@pinc-software.de>

bfs: Never publish the index root node.

* This caused the volume to be un-unmountable when you created an index
on a non-indexed volume.


# 39f437f7 04-Jan-2017 Axel Dörfler <axeld@pinc-software.de>

bfs: Always check if NodeGetter succeeded.

* There were quite a few cases that just assumed that the disk access
would succeed.
* This also fixes bug #12962.


# 9bcf23b1 04-Jan-2017 Axel Dörfler <axeld@pinc-software.de>

bfs: Made stream code more robust against bad data.

* Avoid divisions by zero. This closes ticket #13094.


# 5a95af70 25-Oct-2014 Axel Dörfler <axeld@pinc-software.de>

vfs/{b|btr|package|b}fs/ext2/exfat: common access check.

* Added VFS helper function check_access_permissions() that combines
several partially correct versions to the one true version (tm).
* All but BFS (since recently) missed the S_IXOTH for root on directories,
and all but packagefs missed proper group handling.


# 49c31016 25-Oct-2014 Axel Dörfler <axeld@pinc-software.de>

bfs: root may always enter directories.

* If you're root, you can now always enter directories, even if they
don't have the X permission.


# de9c0613 03-Jul-2014 Axel Dörfler <axeld@pinc-software.de>

bfs: Use the QueryParserUtils instead of its own copy.

* Ingo copied the methods into a shared location, and then obviously
"forgot" to let BFS use them. As a side note for Ingo: the complete
error GCC reported was "std::fssh_size_t" not defined with the macro
wrapper as code location. The actual problem was a "using std::size_t"
in some C++ header that accidentally got included after the wrapper.
* The shared Query code is not yet used. That'll be done another time.
* Renamed BFS_SHELL define to FS_SHELL, such that QueryParserUtils can be
used in any file system shell, not just the bfs_shell.


# aeee1f7e 14-Oct-2013 Axel Dörfler <axeld@pinc-software.de>

bfs: Fixed removing a listener that was never added.

* When the tree constructor failed, the InodeAllocator would try to remove
the tree from the transaction. However, in that case, it was never added
to it.
* Inode::fTree is no longer set if the tree constructor failed.
* This fixes bug #10089.


# a1566b06 06-May-2013 Axel Dörfler <axeld@pinc-software.de>

bfs: removed kernel_cpp.h's new operator.

* This fixes bug #9715 from the POV of BFS, ie. the new operator seems
to call the constructor on a NULL object on failure.


# 27aafb14 22-Mar-2013 Alex Smith <alex@alex-smith.me.uk>

CID 712421: Missed some other occurrences, fixed them as well.


# ee8f0ab0 22-Mar-2013 Alex Smith <alex@alex-smith.me.uk>

CID 712421: Fix unintended sign extension.


# 46cf7a5a 14-Nov-2012 Przemysław Buczkowski <przemub@yahoo.pl>

Fix typos: super block -> superblock (#8974)

Signed-off-by: Przemysław Buczkowski <przemub@yahoo.pl>
Signed-off-by: Matt Madia <mattmadia@gmail.com>


# caa1e8b7 31-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fix CID 712419, 712420, 712421, 712422: Unintentional sign extension to 64 bits.


# 3cd66dda 31-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fix CID 712419, 712420, 712421, 712422: Unintentional sign extension to 64 bits.


# 8f7ec006 01-Apr-2012 Axel Dörfler <axeld@pinc-software.de>

We need to remove the tree from the transaction. Fixes #3159.

* The tree does keep a reference to the inode as well as long as it is part
of a transaction.
* Even if it wouldn't have done it (and would not have triggered the panic),
Haiku would likely have crashed, as the inode (and therefore its tree) was
already deleted at the time when the transaction discarded its listeners.


# 439495d8 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Inode was leaking its small data lock.

* This should not have harmed normal operation (as an Inode is only destroyed
when it is no longer being used), but the fs_shell could run out of
semaphores easily.


# 48ec4fbb 09-Nov-2010 Axel Dörfler <axeld@pinc-software.de>

* Applied patch by Rohit Yadav that fixes #6750, thanks a lot!
* This changes Inode::CheckPermissions(), and bfs_write_stat() based on Ingo's
solution in his file corruption test file system.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39378 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 386be45a 24-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed 64 bit warnings.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36928 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 709b3525 07-May-2010 Axel Dörfler <axeld@pinc-software.de>

* No longer keep the write lock when accessing the attribute data; instead, we
now make sure no one else touched it in the mean time (in order to retrieve
consistent data for the index update). This should fix bug #5878.
* Squashed a TODO by locking the inode in the transaction as well.
* Fixed a quasi bug that would not have read the attribute data if there was no
live query for it; "fortunately", Volume::CheckForLiveQuery() is not
implemented yet, and always returns true.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36707 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f3cf9af6 14-Apr-2010 Axel Dörfler <axeld@pinc-software.de>

* Fill the gap between a write and the former file size with zeros, too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36263 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fd91cf4d 16-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* Replaced the specialized inode in transaction mechanism with a generic one.
That costs 12 more bytes per inode on 32 bit platforms, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35491 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3c50a646 24-Jan-2010 Axel Dörfler <axeld@pinc-software.de>

* Inode::Create() should also better check if creating the file cache succeeded.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35273 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c709a396 24-Jan-2010 Axel Dörfler <axeld@pinc-software.de>

* 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


# 27bb89ca 18-Jan-2010 Rene Gollent <anevilyak@gmail.com>

BFS needs to also allocate a file cache when dealing with a long symlink inode. Fixes ticket #5282.

Axel and/or Ingo, please review.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35147 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f2505b15 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Implemented O_DIRECTORY in BFS.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34280 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8859eeab 24-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced "%Ld" and "%lld" in printf()s by the new B_PRI* macros to avoid
warnings when building with a 64 bit compiler.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34216 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b6670723 11-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Only remove the inode from the Volume::RemovedNodes() list when it has gone
through the VFS.
* This fixes bug #4942.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34007 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c07fb644 04-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Since we know the address of the lock in question, there is no need to waste
memory by naming it individually.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33881 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1b944eec 29-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Improved the status_change time check to actually filter out invalid times,
before, st_ctim was never updated; since you cannot change st_ctim via an API,
'0' cannot ever be set, either.
* Inode::WriteAttribute(), and Attribute::Write() now return whether they
created an attribute or not, and thus B_ATTR_CREATED is now correctly set.
* Moved status_change update from bfs_write_attr() into Inode::WriteAttribute()
where it can be handled more efficiently.
* Likewise, Inode::RemoveAttribute() now updates the status_change time as well,
I simply forgot this before.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33832 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3637e0e0 19-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed double indirect ranges again: I've messed them up when I tried to make
them more BeOS compatible while still keeping them somewhat flexible.
* _GrowStream() did actually not check if the double indirect region was already
filled up - this caused it to overwrite innocent memory. This fixes the bug
Rudolf showed me on this laptop that happened while copying a large file.
* Loosened file size restriction on a heavy fragmented disk: the indirect block
does not require a minimum array size anymore; before, you just couldn't let
a stream grow into the indirect range if it couldn't allocate NUM_ARRAY_BLOCKS
(4) blocks in a row. This considerably reduced the maximum file size in this
case.
* Removed no longer valid TODO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33675 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 361f5cdf 12-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Build fix for the boot loader (it's now using the new utility functions as
well). Sorry!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33560 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 16a821d9 12-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Inode::FindBlockRun() now checks the block run size of double indirect runs,
and stops processing if it finds something wrong.
* The default indirect/double array size differs from BeOS' BFS. I've changed
the size for double indirect arrays only, since the other size should work
either way (not tested yet, this change has a negative effect on the maximum
file size, but improves BeOS compatibility).
* The read/write path of BFS is now double indirect block size agnostic, and
should work with what it finds.
* Merged all double indirect size computation into some utility inline
functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33551 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1a60fd72 06-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Replaced the Inode::GetTree() method with a simple getter - the tree is
always created for directories since quite some time now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32158 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 134e1b04 06-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Somehow I forgot to update the parent directory's time stamps on file
creation, removal, and name changes...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32157 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 121805b4 28-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* We need to update the status change time as well with each write, as required
by POSIX semantics.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31872 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0bad8397 28-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* When aborting a transaction, we also need to revert any changes made to the
cached bfs_inode of all changes inodes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31859 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e66295e5 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* The inode may actually not be known when calling _RemoveInvalidNode(), this
could cause a KDL.
* Added a "force" argument to Inode::Remove() which should make it remove inodes
more reliably for checkfs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31773 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a4f9af2a 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

Fixed a number of issues with double indirect blocks:
* The "index" was not correctly updated when the next indirect block was about
to be used, which lead the code to write the runs to a wrong block, causing
slight corruption, as well as the known invalid block_run(0,0,0) problem.
* blocksRequested is now always a multiple of "minimum" as well.
* When the file size grew beyond the max_double_indirect_range, the minimum was
not adjusted, leading to too many extra allocations that had to be reverted
afterwards again.
* If an allocation was not a multiple of NUM_ARRAY_BLOCKS, but also smaller than
this limit (could happen due to the bug above), an endless loop could be
entered. This was actually a regression introduced in r974.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31767 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b49a46a7 29-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Inode::_AddSmallData() now supports writing at an arbitrary position.
However, Inode::WriteAttribute() still has a number of problems when this is
actually used; contents could get lost when an attribute is moved from the
small data section to an attribute file, and the index might not be updated
correctly when you write within the first 256 bytes, but not at position 0.
Since these problems aren't exposed with how we're using BFS right now, it's
not that bad, though (Inode::WriteAttribute() supports everything correctly
that it had to under BeOS).
* Added test application for certain fs_attr functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31313 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5e088159 26-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Allow more waste on index directories.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31254 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c1b4d0ec 26-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Directories now only preallocate 4 KB.
* Reworked how preallocations are chosen, and also take the grow rate into
account.
* Also, the preallocation is now rounded to the next multiple of the
preallocation size (previously, a 64K write would only allocate 64K).
* This should also close bug #2573.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31253 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e4944941 15-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup of how the time is converted between bfs_inode and the outside world:
there is now a couple of conversion functions, and I changed the type from
bigtime_t to int64, as it's not what a bigtime_t would usually contain, but
some shift magic in order to make duplicate index entries less likely.
* We now correctly fill in the timespec in struct stat as good as possible; the
12 of the 16 possible bits are used for the nano second value. The lower 8
bits are used to avoid the duplicate index entries. Only if the nano second
time is 0, the lower 12 bits are used to achieve that.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31057 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 33203f67 25-May-2009 Oliver Tappe <zooey@hirschkaefer.de>

* added support for ctime to BFS by grabbing two of the pad-fields
* added TODO about a sanity check that should perhaps be dropped
I checked this change with both a haiku-BFS partition and one from R5

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30852 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 24b822d8 17-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* No longer hold the write lock when calling Inode::FillGapWithZeros(), as this
potentially deadlocks as described in bug #3768. The system is still
completely unresponsive, but gets back to a working state after some time now.
* Since the rw_lock is public, Transaction and InodeReadLocker no longer need to
be friends with Inode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30221 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 992fba36 16-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* There is now a list of removed vnodes in Volume - while asking the VFS for
this seemed to be a good idea, there is one race condition that cannot be
solved otherwise (the vnode must be added/removed to that list while holding
the transaction lock, and we cannot guarantee that in the VFS).
* We are using an unused area of the in-memory bfs_inode to store the list
links (bfs_inode::pad - this will also work on 64 bit platforms).
* Inode no longer adds a singly linked list link - the transaction list now
shares the doubly linked list with the removed vnodes list.
* Added an in-memory flag INODE_IN_TRANSACTION to avoid searching an inode
to be added in the list.
* Removing an attribute directory did not hold its write lock.
* If removing an attribute failed for some reason, the INODE_DELETED flag
was not removed (the transaction would not have failed because of that).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30203 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 41a6cf82 12-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* The InodeAllocator must remove the inode from the transaction before deleting
it, otherwise the transaction would access already freed memory when trying
to release its write lock of the inode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29481 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 31cb93ad 12-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29479 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49004dc7 19-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Remove the additional fs_vnode_ops arugment from get_vnode() again as it's not
needed at all when used as intended. Thanks Ingo for the explanation on how this
is intended to work. Adjusted the overlay fs accordingly and updated/reverted
the changes to the other filesystems.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29250 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 00405f22 09-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Add an additional argument to get_vnode() that gets the fs_vnode_ops of the
node. That is needed for a layered filesystem to be able to construct a full
fs_vnode out of a volume/inode pair.
* Adapt places where get_vnode is used. Sadly this is a C API and we can't just
use a default NULL for that argument.
* Introduce a flag B_VNODE_WANTS_OVERLAY_SUB_NODE that can be returned in the
flags field of a fs get_vnode call. A filesystem can use this flag to indicate
that it doesn't support the full set of fs features (attributes, write support)
and it'd like to have unsupported calls emulated by an overlay sub node.
* Add a perliminary overlay filesystem that emulates file attributes using files
on a filesystem where attributes aren't supported. It does currently only
support reading attributes/attribute directories though. All other calls are
just passed through to the super filesystem.
* Adjust places where a HAS_FS_CALL() is taken as a guarantee that the operation
is supported. For the overlay filesystem we may later return a B_UNSUPPORTED,
so make sure that in that case proper fallback options are taken.
* Make the iso9660 filesystem request overlay sub nodes. This can be fine tuned
later to only trigger where there are features on a CD that need emulation
at all.

If you happened to know the attribute file format and location you could build
an iso with read-only attribute support now. Note that this won't be enough to
get a bootable iso-only image as the query and index support is yet missing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29177 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 528b69d5 24-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed bug #2727: symlinks usually "abuse" the data stream part of a
bfs_inode to store the link path (up to a certain length). If this was long
enough to clobber the data_stream::size field (which luckily was the last
field of struct data_stream), Inode::Free() would mistakenly assume this to
be a valid data stream to be freed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28311 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b2ec044c 30-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Added stat::st_blocks field as required by POSIX. This also closes ticket
#2261.
* Made at least BFS report it more or less correctly (the attributes are
ignored, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27791 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 57b9debf 13-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Some index updating functions did not take into account that not all nodes
are put into all indices. For example, symlinks aren't part of the size
index. This fixes bug #2704.
* Also, Inode::NeedsTrimming() now ignores symlinks that have no data stream,
it's const now, too.
* Added helper methods Inode::In{Name|Size|LastModified}Index(), and use it
where appropriate.
* Clarified Inode::Create() description with regards to name vs. parent.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27471 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fa23653d 12-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Improved reported inode number to the be actual index.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27444 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c4b2fd5b 12-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Reverted r27196 and solved it differently (in a more robust way): instead of
guessing that the first attribute will be a name attribute, fCurrentSmallData
now takes hidden attributes into account.
* I haven't tested this change, though, so if it messes things up again, please
yell at me :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27441 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e1d9b813 24-Aug-2008 Bruno G. Albuquerque <bga@bug-br.org.br>

- AttributeIterator::Update() now take into account differences between its
view of the small data section and the outside view.

Long version:

AttributeIterator is a higher level class designed to make it easy to iterate
through attributes in the small data section. The first attribute in the small
data section is the special "name" attribute that is used to reconstruct the
node path when you only have a node handy. As this attribute is not user
visible nor user modifiable (except by changing a node name of course), it is
considered a special attribute so the AttributeIterator class ignores it and
starts iterating from the second attribute on.

As opposed to this, internally the Inode class accesses the small data section
directly without using the AttributeIterator class so whenever it indexes items
in the small data section, it takes into account the special "name" attribute.

This creates a off-by-one relationship between those 2 representations and this
was a problem because whenever the small data section changed, all iterators
had to be updated (through a call to AttributeIterator::Update() having an
index parameter that represented the outside view and not the AttributeIterator
view, so iterators would not be adjusted correctly and the end result is that
every other attribute was not removed from the index. This would cause all
types of havoc with indexes, the simplest one being that entries in indexes
would point to non-existing nodes.

Ingo, pleased now? ;)



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e07a4b3b 23-Aug-2008 Bruno G. Albuquerque <bga@bug-br.org.br>

- Correct the index number when calling _RemoveSmallDat() with an index.
This may be masking out a different bug.
- This fixes part of bug #2614. It may even fix all of it but I have to
test.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27180 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34d496f8 04-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* For regular files, BFS will now preallocate much more than the previous 64 KB,
which are now only used for directories and for files smaller than 1 MB.
* For files between 1 MB and 32 MB 512 KB are used as preallocation size,
everything beyond that will get a 1/16 of their file size, ie. 4 MB with a
file size of 64 MB, 64 MB with a file size of 1 GB.
* This should help a lot with fragmentation of large files when they are written
synchronously.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26794 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d172ee84 02-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed recently introduced write lock leak, when something failed
before file_cache_write() or nothing had to be written.
* Fixed race condition. While neither transaction nor read lock are
held, the file size can change.
* Add the inode to the transaction whenever possible, i.e. on error
before file_cache_write() and after it as well. This should prevent
readers from seeing inconsistent blocks when the transaction has to be
rolled back.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26736 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 02c8f6c8 02-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Coding style cleanups, no functional changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26728 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2accd07b 01-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Replaced Chain with the new SinglyLinkedList.
* Renamed openModeToAccess() to open_mode_to_access().
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26718 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2e3477e3 31-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Changed the inode write locking to be held as long as the transaction is
running - this fixes several cases where someone could see outdated data
when a transaction had to be reverted (the time between unlocking the inode
and actually reverting the blocks). For that, Inodes can now be put into a
singly linked list.
* Added a TODO in Inode::WriteAt() which explains why it cannot use the above
method: seems that our VFS/VM locking model isn't really that good.
* Fixed a possible deadlock in Attribute::_Truncate() where the inode write
lock was held before starting the transaction.
* Added an InodeReadLocker convenience class, that should be used instead
of ReadLocker - Inode::Lock() only still exists because of the needs of
bfs_io().
* Moved the bfs_io() callback hooks out of the exported module API region,
and removed their bfs_ prefix.
* Added a Volume::IsInitializing() method that should be used rather than
checking if Volume::ID() is >= 0.
* Removed the MultiInodeLocker again, as it's pretty much superfluous now.
* Moved openModeToAccess() to the Utility.h header.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b99521f2 30-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

First round of locking fixes:
* Moved locking the data stream out of the BPlusTree methods; this fixes at
least two locations where another thread could have seen outdated/incorrect
data.
* Removed some superfluous code in bfs_rename(): we don't have to revert to the
previous situation, the transaction does this for us automatically.
* Added a simple MultiWriteLocker, even though it's not really necessary anymore
(since we always hold the transaction lock first when we lock more than one
inode at a time).
* Inode::Create() called InodeAllocator::Keep() a bit too early, the file cache
and map wasn't created and assigned yet.
* InodeAllocator now keeps the inode write locked.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26689 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 082bae1a 23-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* bfs_fsync() no longer grabs the Inode's read lock - instead, Inode::Sync()
will take care of the locking.
* Use new(std::nothrow) over new, and malloc (only in kernel_interface.cpp);
the kernel_cpp.h header isn't really necessary anymore, so there is no reason
BFS should continue to use it.
* Removed superfluous NULL checks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26574 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9083840f 20-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

bonefish + mmlr + axeld:
* Fixed a bug that could easily corrupt your disks (yeah, one of those
again): bfs_get_file_map() truncated the last vec incorrectly and
would potentially return a too large file size -- which was later
happily overwritten with file data, but could have belonged to
anything but that file (like inodes, B+trees, etc.).
* Renamed previous round_up() function to key_align().
* Added round_up() template function, and used it where appropriate.
* The latter actually fixed two bugs where the and mask was computed in
32 bit where it should have been in 64 bit.
* Inode::FindBlockRun() should have checked the max indirect size
instead of the direct size - this didn't cause any problems, though.
* White space cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26531 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1bde8b03 08-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Replaced BFS's ReadWriteLock implementation with the kernel's rw_lock.
* The BlockAllocator now uses the new mutex_transfer_lock() function instead
of clobbering the mutex directly.
* Removed Lock.h - it's no longer needed.
* Minor white space cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26317 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 03fa417b 07-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Removed the home-brewn locking classes in BFS besides the read/write lock
(for now).
* Inode::fSmallDataLock is now a recursive_lock, Journal::fLock is now
a recursive_lock, too, Journal::fEntriesLock is now a mutex, as is
BPlusTree::fIteratorLock.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26298 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bcd30708 28-Jun-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a deadlock found by Salvatore; the volume lock is now only used to
protect the bfs_read_fs_stat() and bfs_write_fs_stat() functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26154 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 536f5d51 09-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Don't create anything in a removed directory. Axel, please review. I
don't see how the locking in Remove()/Create() works.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25404 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e8edffc 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed at least the "dd" part of bug #2148: the second double indirect array
block would be incorrectly addressed when allocating a stream - this could
cause random blocks to be overwritten, and therefore could cause many sorts
of problems.
* Moved BFS_TRACING macro to the tracing_config.h file, and let it follow the
new semantics of those other macros in there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25249 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d11e733f 24-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Allow passing sub vnode ops and publish flags to Inode::Create().
* Implemented create_special_node() hook.
* Fixed Inode::IsContainer()/IsDirectory().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25140 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 701d1966 24-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Inode::_GrowStream() did not make the double indirect block writable before
adding a block to its array. This could cause all kinds of trouble, and
fixes at least a part of #2148.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25125 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7ffafac8 05-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reorganized the FS interface a little:
- Moved most file_system_module_info hooks into separate structures.
Those that operate on mounted volumes to fs_volume_ops, those
operating on a vnode to fs_vnode_ops.
- Got rid of the fs_volume, fs_cookie, fs_vnode typedefs. We use void*
again.
- Instead of a void* volume and node cookie hooks are passed a
fs_volume and fs_vnode structure pointer, which contain the cookie
and an ops pointer (fs_volume a few more things).
- The VFS {new,publish,get,...}_vnode() functions take a fs_volume*
instead of the volume ID. So does vfs_get_fs_node_from_path().
- Added type and flags arguments to publish_vnode() and the
get_vnode() hook and removed the type argument from lookup() hook.
Added vnode::type using formerly unused bits to store the node type.
Simplified a few things in the VFS due to the now always available
node type.
- Added fs_volume_ops::{create,delete}_sub_vnode() and
fs_vnode_ops::get_super_vnode() hooks. They are used to support file
system layers, e.g. allowing to extend an FS not supporting BeOS
attribute with attribute support. Needs some more work in the VFS.
- Added fs_vnode_ops::create_special_node() hook for creating special
nodes (e.g. FIFOs).
* Adjusted the built-in file systems and BFS according to the interface
changes. Removed all other FSs from the image for the time being.
We'll see whether further API changes are necessary before porting
them.
* Adjusted the bfs_shell accordingly.
* Implemented create_special_node() in rootfs to support special nodes.
* Added support for FIFOs:
- Added syscall _kern_create_fifo() (used by mkfifo()), which creates
a special node (type S_IFIFO) in the respective file system.
- When a special node is published the VFS creates a respective sub
node. Currently only FIFOs are supported.
- Added a little support for FIFO subnodes by using functionality from
the pipefs.
- Added mkfifo to the image. It can create FIFOs in the rootfs, but
the FIFOs aren't really usable ATM, since they still work like
pipes, i.e. readers and writers need to have them open at the same
time.
* Some smaller changes in the VFS:
- Made the *_CALL macros nicer to use (vargs).
- Refactored FS entry lookup into new function lookup_dir_entry().
- create_vnode() no longer just calls the FS create() hook. First it
looks up the entry and uses open_vnode(), if it already exists. This
is necessary for two reasons: 1) The FS might not support create()
while still allowing to open() entries. 2) When the FS has other
layers on to of it (or the respective node) it might not be
responsible for opening the node.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24816 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e63c1170 03-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

Looks like some bloke forgot to commit *some* files that should have been part
of r24768 (block cache notification mechanism rewrite).
Thanks for the note, Vasilis!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24772 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8af46ac8 25-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24576 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2f20bf15 25-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Added "bfs" prefix to tracing output.
* When an inode is trimmed, it now also traces the previous internal
size as well as the target size.
* Remove extraneous white space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24575 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a121b8c8 24-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Added a new flag for write stat: B_STAT_SIZE_INSECURE that allows a
file system to not fill newly created space with zeros.
BFile::SetSize() now uses this, while [f]truncate() does not. This
is only a temporary work-around until BFS supports sparse files.
* Apps that want to reserve space to fill up later should use
BFile::SetSize() for now, as this will be a lot faster than
[f]truncate().
* cache_io() and the functions below now use a special mode when you
pass in a NULL buffer: for read access, the cache is only populated
(useful for prefetching), for write access, the file is filled with
zeros.
* Implemented BFS's Inode::FillGapWithZeros() using this method now.
* Removed extraneous white space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24555 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 18a83f09 16-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Root is allowed to cd into any directory, regardless of the directory
permissions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c6f752c0 06-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

Corrected patch to fix warnings when compiled with GCC 4, thanks Vasilis!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24279 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 351b7a2d 25-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Added B_WATCH_INTERIM_STAT, and B_STAT_INTERIM_UPDATE definitions to
NodeMonitor.h.
* The latter will be set in "statFields" for interim updates when you have
asked to get them via the former.
* BFS now uses the B_STAT_INTERIM_UPDATE flag for sending updates to actively
written files.
* This makes us more compatible with BeOS again; if you only asked for
B_WATCH_STAT, you will now only receive a notification if the file in
question has been closed.
* Tracker now uses B_WATCH_INTERIM_STAT to always get all updates (ie.
downloading a file will update its size and modification time in Tracker
periodically during the download).
* Wether "needsTrimming" was true or not has no influence on wether or not
the size index needs to be updated in BFS - only the actual file size is
stored there, not the on-disk size.
* Added a TODO comment in Inode::WriteAt() that it would actually need to
update the size index when changing the file size, not when the file has
been closed (but that's probably too slow).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24114 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7a5d9c5 19-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed TraceEntry::Dump() to take a TraceOutput& and removed
AbstractTraceEntry::AddDump(char*, size_t).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23655 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d62f7435 19-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Inode::_FreeStreamArray() kept one block it should have freed when the
new size fell on a block boundary.
* Removed newline from Inode::Remove() tracing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23652 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5d8d6d9a 19-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Improved tracing output a bit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23643 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4fc4f2c8 13-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Added a transaction listener mechanism to be notified when a
transaction ends or has been aborted.
* BFS now listens for transactions when it created an inode to see if
the transaction will be aborted without freeing the inode (in which
case it will panic for now).
* Started implementing tracing support, but it's not working yet.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23492 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e43ece8 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Some more work on the tracing API:
* Added function to allocate space in the buffer.
* Dump() now fills a buffer instead of printing its data directly.
* This allows the new "#pattern" argument of the "traced" command to
work. When you're using that, the index of the trace entry is printed
out, too, so that you can then get a full dump around the hits.
* Added an AddDump() method to the AbstractTraceEntry class so that
there is no need to call the inherited function anymore.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23479 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d7477802 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Made the additions of the KDL debugger commands independant from the
DEBUG macro; they are now added only if BFS_DEBUGGER_COMMANDS is
defined (which is now done by default in the Jamfile).
* Added "bfs" KDL command which dumps volume information and the super
block.
* Made use of the new tracing API to trace block and inode actions
(and the new AbstractTraceEntry class I forgot to mention in the last
commit). Is compiled in only when BFS_TRACING is enabled (defaults to
off in the standard builds).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23464 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4a31d30e 13-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* The file map needs to know the actual file size to be able to know if it has
the complete extent info or not.
* file_map_translate() now cuts down the request to the file bounds.
* Adjusted BFS and FAT to the API changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22913 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f0d93820 11-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* The previous locking order "inode write" -> "journal" was not only not
honoured (in the Inode attribute code), it also couldn't be honoured there.
Therefore, the locking order is now reversed, that is "journal" comes first,
then the Inode write lock. This should also help with the lock ups that
appeared after r22886.
* Got rid of INODE_NO_TRANSACTION; it doesn't make any sense to use.
* When Inode::WriteAttribute() changed the type, the type field was actually
never written back within the current transaction.
* If the attribute data fit into the inode again, the attribute's write lock
was never released.
* Since r22886, Inode::ReadAt() does its own locking, so we must no longer lock
the inode before calling it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22897 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3d268eda 10-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* Extracted file_map API out of the file cache - it's now an optional service
that can be used by file systems.
* Changed the way the file cache works: instead of reading/writing to the
underlying device directly, it can now be used for any data source, ie.
also network file systems.
* As a result, the former pages_io() moved to the VFS layer, and can now be
called by a file system via {read|write}_file_io_vec_pages() (naming
suggestions are always welcomed :-)). It now gets an FD, and uses that to
communicate with the device (via its fs_{read|write}_pages() hooks).
* The file_cache_{read|write}() functions must now be called without holding
an I/O relevant file system lock. That allows the file cache to prepare the
pages without colliding with the page writer, IOW the "mayBlock" flag can
go into the attic again (yay!).
* This also results in a much better performance when the system does I/O and
is low on memory, as the page writer can now finally write back some pages,
and that even without maxing out the CPU :)
* The API changes put slightly more burden on the fs_{read|write}_pages()
hooks, but in combination with the file_map it's still pretty straight
forward. It just will have to dispatch the call to the underlying device
directly, usually it will just call its fs_{read|write}_pages() hooks
via the above mentioned calls.
* Ported BFS and FAT to the new API, the latter has not been tested, though.
* Also ported the API changes to the fs_shell. I also completely removed its
file cache level page handling - the downside is that device access is no
longer cached (ie. depends on the host OS now), the upside is that the code
is greatly simplified.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22886 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 85b65f75 20-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

The AttributeIterator was returning the size of the attribute data rather than
the length of the attribute name in GetNext() for attributes that are actual
inodes. Found by Robert Szeleney, thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21674 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 245aecda 21-Jun-2007 Axel Dörfler <axeld@pinc-software.de>

Got rid of vnode_id and mount_id, replaced with ino_t and dev_t.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21485 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 065e3184 22-May-2007 Axel Dörfler <axeld@pinc-software.de>

* Inode::Create() now has a "_created" parameter that will be set to true in case a
node has been created - this is now used in bfs_create() to suppress the new entry
notification in case the file already existed.
* Implemented parameter parsing in bfs_initialize() - does not work in the new bfs_shell
though, as it currently misses driver_settings functionality.
* Attribute::Create() and Attribute::Open() will now honour O_TRUNC correctly.
* Note: Inode::WriteAttribute() still follows R5 semantics for small_data attributes
in this regard and must be fixed (I've opened ticket #1242 for this).
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21204 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9d6c014f 29-Apr-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added very basic volume initialization support.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20899 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c391f84b 26-Apr-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Prepared the BFS sources to be used with the new FS shell:
- Moved all inclusions of system headers into a new
system_dependencies.h header, which conditionally either includes
these or the FS shell headers.
- Fixed compiler warnings related to printf-like functions (int32 is
int, not long on non-BeOS platforms).
* Build a new bfs_shell. Compiles and links, but does nothing ATM.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20860 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c845a296 25-Apr-2007 Axel Dörfler <axeld@pinc-software.de>

Don't try to write back symlinks that don't have a data stream. This fixes bug #1179.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20813 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1d63cfdc 24-Apr-2007 Axel Dörfler <axeld@pinc-software.de>

Now makes use of the new block_cache_etc() function to sync data streams without a file cache attached.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20812 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb0572ca 25-Apr-2007 Axel Dörfler <axeld@pinc-software.de>

* Changed Inode::WriteAttribute() so that it no longer reads from the old
attribute when its size was 0 - this also fixes calling Index::Update()
with invalid values, and therefore bug #1178.
* Style cleanup: honour 80 column limit a bit more, use doxygen style comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20809 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ecd0171 07-Feb-2007 Axel Dörfler <axeld@pinc-software.de>

* Fixed a bug that would not remove an existing attribute from the small data section
when the new attribute data was too large to fit into the small data section at all.
This fixes the Trash icon update with a block size of 1024 bytes.
* This also fixes a bug where AddSmallData() required you to write back the inode even
if it failed with B_DEVICE_FULL, but no one did it.
* _RemoveSmallData() no longer requires you to write the inode back on success.
* Made most small data methods private.
* WriteAttribute() now tries to put the data into the small data section even if it
existed as a separate file before (the file is then removed).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20103 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 458ff7ff 16-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Inode::WriteAttribute() did not adopt a changed "type" when the attribute was a file,
causing subsequent reads with that type to fail.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19825 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b631d2f4 27-Sep-2006 Axel Dörfler <axeld@pinc-software.de>

* Fixed the bug Bruno observed (and worked around) in a safer way - the node data was
not written back before GetNextSmallData() was called (which let the region appear
empty even though it wasn't).
* I left the shortcut in case of the "name" attribute in there, because it should
be a bit faster.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18949 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 074ebdda 05-May-2006 Axel Dörfler <axeld@pinc-software.de>

* When mounting an image, BFS no longer tries to set the file into uncached mode - this
will waste some memory (as the data will be cached twice), but unlike BeOS, it cannot
deadlock the cache, so it's safe to be used. In other words, mounting images is now
working as expected.
* a BFS FATAL() condition no longer results in a KDL; this seemed to confuse anybody :)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17336 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b61fdf78 28-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

* The inode block wasn't written back when it was opened with O_TRUNC/B_ERASE_FILE
which could cause inconsistency of on-disk structures.
* Fixed copy&paste bug introduced by Ingo when he did the GCC 4 work-around: when
shrinking the direct range, the new size was written to the indirect range.
* Some cleanup, renamed private Inode methods to have a leading '_' symbol.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16557 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b3b202f4 28-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

The Inode's lock was named incorrectly when it was newly created.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16544 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6106f57e 26-Feb-2006 Stephan Aßmus <superstippi@gmx.de>

* Didn't allow to write back attributes outside the inode block (they don't
have a user accessable stream, but they do have a file cache).
* removed superfluous dump_inode() version; the "bfsinfo" debugger
command is now a bit more useful as well.
* Inode::fAttributes was not initialized when it wasn't used.

(coded by axeld)



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16508 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 866d738a 22-Feb-2006 Jérôme Duval <korli@users.berlios.de>

added error tracing to help on bug #106


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16498 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e5e7fa9 30-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

It's allowed to write attributes with type 0 - for some reason, our Backgrounds
preferences app writes its info with this type (instead of B_MESSAGE_TYPE as
Be's does).
It's now possible to set the background image for Tracker under Haiku.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15742 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7df07b24 23-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

Nice if an experienced problem matches a bug in the implementation that
closely: Inode::WriteAt() didn't call Inode::WriteBack() in case the
file size was enlarged - it was only written in case the file was closed
which a) could have not happened because of a crash, and b) would move
the change into the wrong transaction, and could therefore result in
an incorrect update, as seen.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15094 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 758b1d0e 12-Nov-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixes that make Haiku build with gcc 4. Mainly out of the following
categories:
* Missing includes (like <stdlib.h> and <string.h>).
* Linking against $(TARGET_LIBSTDC++) instead of libstdc++.r4.so.
* Local variables shadowing parameters.
* Default parameters in function definitions (as opposed to function
declarations).
* All C++ stuff (nothrow, map, set, vector, min, max,...) must be imported
explicitly from the std:: namespace now.
* "new (sometype)[...]" must read "new sometype[...]", even if sometype is
something like "const char *".
* __FUNCTION__ is no longer a string literal (but a string expression), i.e.
'printf(__FUNCTION__ ": ...\n")' is invalid code.
* A type cast results in a non-lvalue. E.g. "(char *)buffer += bytes"
is an invalid expression.
* "friend class SomeClass" only works when SomeClass is known before.
Otherwise the an inner class with that name is considered as friend.
gcc 4 is much pickier about scopes.
* gcc 4 is generally stricter with respect to type conversions in C.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14878 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7121425e 20-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Turns out we could remove a mount point...
Under BeOS remove_vnode() is failing in this case, which looks like a good idea to imitate.
Also, pipefs/rootfs didn't handle that case - they even removed the entry before calling
remove_vnode() - they now behave correctly. And also BFS now returns the actual error code
received from remove_vnode() instead of B_ERROR.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14456 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ece4feca 06-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Use snprintf() instead of sprintf().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14333 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1c12a6a3 08-Jun-2005 Axel Dörfler <axeld@pinc-software.de>

Inode::ShrinkStream() now evaluates the return values from some functions - dunno
if that's a good idea (it may still be a good idea to succeed for shrinking the
stream, even if not everything worked), but it looks better :-)
Improved debug output in case TrimPreallocation() fails.
Journal::FlushLogAndBlocks() no longer ends the current transaction if called
from within an ongoing transaction.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13019 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 69aaf3f3 26-May-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed some stupid problems with the stat::st_mode field; the type of
a node was not always correctly determined (or set) - the recent change
of the attribute (directory) modes made these bugs a bit more obtrusive.
This also fixes a drop to the kernel debugger when doing a
"zip -r config.zip config/" in the home directory, as reported by Korli.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12826 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bae7c12d 25-May-2005 Axel Dörfler <axeld@pinc-software.de>

bfs_read_link() did not report the correct link size (it did not take the
terminating null byte into account) - thanks to Korli for reporting this.
Inode::Create() will no longer publish symlink vnodes; instead, bfs_create_symlink()
will publish the link when it is complete (ie. the actual link data had been
written).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12822 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 36cb9bac 24-May-2005 Axel Dörfler <axeld@pinc-software.de>

Attribute directories must have the S_IFDIR flag set, attribute files
the S_IFREG flag. The missing flags caused the original BFS to crash
on our files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12796 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7fa5018c 13-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

We always want to hold the parent's lock in Inode::Create(), even if we
just create an attribute directory.
Removed the now unnecessary UNSAFE_GET_VNODE lines.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11724 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b7366070 13-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

InodeAllocator now takes care of calling new_vnode() and the new publish_vnode().
bfs_inode::InitCheck() tested INODE_NOT_READY before making sure the block is
an inode at all, resulting in spurious "inode is not becoming unbusy" errors.
Since there is now publish_vnode() we don't even have to return B_BUSY at all
anymore, though - INODE_NOT_READY is no longer used at all.
bfs_inode::etc is no longer used either (and for the same reason).
Inode::Create() no longer locks the whole volume, but only the write lock
of the parent directory (if any).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11723 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 62f7d84a 19-Jan-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a bug reported by Ingo: attribute inodes didn't get a file cache attached,
but tried to use it anyway.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10880 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a4480535 19-Jan-2005 Axel Dörfler <axeld@pinc-software.de>

No longer tries to update indices from deleted files. Added new method
Inode::IsDeleted().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10879 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 299e5215 12-Dec-2004 Axel Dörfler <axeld@pinc-software.de>

Added buffer size parameter to Inode::GetName().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10409 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 069694a2 06-Dec-2004 Axel Dörfler <axeld@pinc-software.de>

Rounding up a value can be soooo hard...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10361 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e15a7ad3 03-Dec-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed a big allocation leak: preallocation was done for all streams, but
only regular files were stripped back when bfs_close() was called.
Now, we don't preallocate any blocks for attributes, attribute directories,
and symbolic links (which do have a stream when longer than 144 bytes).
Also, bfs_release_vnode() now trims back all streams that need to be
trimmed - this catches standard directories, which could also slip through
before.
Removed the remaining blocks of INODE_NO_CACHE support as this is not
needed for Haiku.
Added method Inode::NeedsTrimming() that determines if its data stream
can be trimmed (indices are never trimmed to reduce fragmentation).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10356 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ef948c3c 27-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Yeah, sure, don't compile stuff before checking it in.
bfs_open_dir() now checks for read access.
bfs_lookup() now checks for execute access and not read access anymore
(as reported by Ingo as well).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10273 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 41cf3876 27-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

bfs_create() now only checks for write access in the parent directory if a
file really has to be created, thanks to Ingo for reporting this.
Inode::Create() now checks for write access to the inode when O_TRUNC is set.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10272 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 48f8c4e4 22-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

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


# 1d20e060 22-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Inode::Create() allowed to create a symlink "above" a file.
Also, it did not check the access permissions if the file already existed.
Removed check for INODE_NO_CACHE, as this no longer applies.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10184 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb02804a 19-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Big update while moving over completely to the Haiku kernel:
- Ported over BFS to the new cache API
- Inode no longer inherits from CachedBlock, and therefore, no longer
keeps the whole inode block in memory. It now has a copy of the bfs_inode
structure in memory instead. This has a number of advantages but also some
disadvantages, so it might be reverted later, even if it's unlikely.
- Added a NodeGetter class that can be used whenever the real block needs
to be accessed (ie. for attributes)
- Changed *transaction to &transaction where possible
- Removed support for KEEP_WRONG_DIRENT_RECLEN
- Removed support for uncached file access since that's no longer needed
- Fixed some endian issues in bfs_write_stat()
- Removed the install BFS rules, since they don't make any sense anymore
(unless you are running Haiku ;-))

Note, logged streams are not supported anymore right now. Also, the
transaction code is pretty simple and slow - it will be improved later
on. Attribute code is pretty much untested in the new environment.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10053 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3296ebb9 26-Oct-2004 Axel Dörfler <axeld@pinc-software.de>

When attributes get overwritten, the size may only change with string types,
ie. it makes sense to optimize the case when we don't have to move any other
item in the small_data region around.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9514 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a4e05e61 06-Sep-2004 Axel Dörfler <axeld@pinc-software.de>

Added a "cookie" parameter to the fs_read|write|has_page[s]().
Implemented bfs_get_file_map().
Now uses the brand new file cache for the file data streams.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8877 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5325a3e5 29-May-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed a major bug in the inode code: Inode::GetTree() was called completely
without any locking, but was not safe to be used this way.
Now, B+tree creation is done when the inode is created, and thus no further
locking is needed.
Although this reduces the speed when doing directory listings with many sub-
directories, any errors are reported upfront, and not only when you access
the tree directly.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7682 a95241bf-73f2-0310-859d-f6bbb57e9c96


# feec20d6 07-May-2004 Axel Dörfler <axeld@pinc-software.de>

It's now <util/kernel_cpp.h> rather than <kernel_cpp.h>.
Forgot to commit that...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7442 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 36660c5e 29-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Switched from direct get_vnode() usage to the Vnode class.
Now acquires the volume lock always before get_vnode() is called as long
as UNSAFE_GET_VNODE is defined (which now is by default).
May cause some unwanted side-effects; it still has to be thorougly tested.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6424 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b39a7a0e 29-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed the "inode is not becoming unbusy" problem.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6423 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 73e3e50c 29-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed the bug that caused the "vnode already exists with different cookie"
crash: bfs_inode::InitCheck() didn't check INODE_DELETED, and Inode::Remove()
didn't clear the INODE_IN_USE flag (as the original BFS, IIRC).
Some more debug output and checks.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6416 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d401c623 27-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed typo.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6354 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3eacb520 27-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

The InodeAllocator will now remove the INODE_NOT_READY flag to unblock
any pending bfs_read_vnode() calls when it is destructed and the inode
goes away.
Fixed some endian related issues.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6350 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9e72b773 25-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Inode::Create() now prints out a reason if new_vnode() failed.
If the parent is NULL, Inode::Create() will now set node::parent to
the node itself, like BFS is doing it (for root and indices nodes only).
Added a temporary hack in Volume::Initialize() to get the inodes freed.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6320 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d7db2108 25-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed a bug that could happen when calling Inode::Create() with unusual
arguments (such for creating a root directory, for example).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6312 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b53b9c0c 25-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Cleaned the debug mess mmu_man created (thanks anyway).
Switched to kernel_cpp.h/cpp.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6288 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 32e3f999 25-Jan-2004 François Revol <revol@free.fr>

Debug Inode ctor/dctor; fix printf args warnigns


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6285 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 91e6897c 24-Jan-2004 François Revol <revol@free.fr>

Added obfsinode kernel debugger command.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6262 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f929e152 08-Nov-2003 Nathan Whitehorn <nwhitehorn@nowhere.fake>

Eliminated the huge bugs caused by replacing thingy[0] with thingy[1]. Replaced small_data_start with an inline function SmallDataStart() that knows how to pacify mwcc. Should have negligible to no impact on x86 performance.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5286 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb94280c 16-Sep-2003 Axel Dörfler <axeld@pinc-software.de>

The file system is now almost endian-aware.
Used lazy unreadable conversion: ==, !=, == 0, != 0 are endian-safe
and don't need byte swapping.
If the platform endian differs from the one selected at compile time,
it will mount all volumes read-only for now.
Uncomment BFS_BIG_ENDIAN_ONLY in the Jamfile to build the big endian
version under x86.
No matter on what platform, the compilation defaults to build BFS as
little endian file system (see bfs_endian.h for details).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f14bae95 19-Jun-2003 Axel Dörfler <axeld@pinc-software.de>

Renamed "blocks" to "blocksRequested" in Inode::GrowStream() to make its
usage clearer. Also added a comment that explains why it's okay that
blocksNeeded and blocksRequested can be different.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3579 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4a9d9dfa 18-Jun-2003 Axel Dörfler <axeld@pinc-software.de>

Added new RecursiveLock and RecursiveLocker classes.
Added file system global locking around creating, deleting, and renaming
inodes - that's not nice, but since we have only sequential journal access,
it won't hurt concurrency much. The locks are needed to prevent certain
things from happening like two threads could theoretically create the same
file twice (one of them would have failed, but relatively late in the process).
Anyway, a better locking scheme will be implemented at a later date, but maybe
not for R1.
Small cleanup.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3562 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ea8d0c2 31-May-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed queries a bit more (maybe even completely...). In several situations,
the old attribute value wasn't evaluated at all.
Also, Index::Update() got a type code of zero, instead of the real value
in situations where this didn't make any sense.
Minor cleanup in kernel_interface.cpp.
New method Volume::CheckForLiveQuery() that checks if there is a live query
depending on the specified attribute - not yet implemented, but already used;
always returns "true" right now, which doesn't cause any harm but reducing
the speed lightly.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3394 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ae587160 27-May-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed another bad bug caused by calling get_vnode() on a node currently
being constructed: bfs_read_node() created an Inode object independent from
the one set in new_vnode().
As a work-around (the new VFS layer will introduce some better methods here)
we are now using the bfs_inode.etc field as a pointer to our object - just
like BFS has thought to use this field. If bfs_read_vnode() has to wait for
the inode (because it is being constructed), it will use the "etc" pointer
and don't create it's own Inode object.
Almost all changes made change the API to take this case into account:
- new Inode constructor to be able to be created from a CachedBlock
- CachedBlock now has a Keep() method which suppresses the release_block()
call when the object is destructed.
- a CachedBlock can now be constructed from the contents of another one (by
calling the source's Keep() method).
- Inode::InitCheck() no longer checks the integrity of the bfs_inode - this
is now done by bfs_inode::InitCheck() which is optionally called by the
former (default).
- moved the inline CachedBlock methods out of the class definition (was
too crowded to be readable).
- new Inode::Initialize() which is called by all Inode constructors
- an Inode object now sets a better name for its read/write lock.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3364 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e1d37632 25-May-2003 Axel Dörfler <axeld@pinc-software.de>

Now takes changed function of Index::Update() into account - queries on
non-indexed attributes now finally work as they should.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3330 a95241bf-73f2-0310-859d-f6bbb57e9c96


# adf71bf6 24-Feb-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed many warnings because of -Wall (thanks to David for pointing this out).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2839 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1d5f9787 05-Dec-2002 Axel Dörfler <axeld@pinc-software.de>

Added a few comments and ToDo items.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2167 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c78d0589 28-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Removed some debug output I accidently added to the repository.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2107 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 363999a1 27-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Thanks to Bruno, we fixed a bug in Inode::Create() that happened with newly
created files that already existed.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2098 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0606e6e1 25-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Added a new method Inode::GetName() which safely copies the inode's name
to the provided buffer.
Inode::Name() no longer locks the small_data region anymore.
Added ASSERTs that the small_data region is locked for the methods requiring
that.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2083 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fea5713c 21-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Added a comment about live-queries in Inode::Create().
Some style cleanups.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2060 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 11a8dbc6 21-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Completely worked over the inode creation mechanism. Now more work is delegated
to the InodeAllocator class (initialization of the inode, tree creation for
containers).
The InodeAllocator class now frees all the space the inode occupies, including
the B+tree if it's a container (by calling the new Inode::Free() method).
Inode::Free() implementation (logic removed from bfs_remove_vnode()).
Now secures the inode from being loaded by setting the INODE_NOT_READY flag
(completely handled by the InodeAllocator class).
The inode is now removed from its parent if something went wrong after it
had been added.
Utilizes the new BPlusTree::Remove() method where appropriate.
Inode::GetAttribute() now checks if the inode opened is really an attribute.
Inode::InitCheck() now fails with B_BUSY if the INODE_NOT_READY flag is set.
InodeAllocator::Keep() now writes back the inode.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2055 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52fafe62 19-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Changed the parameter logic from Inode::Create() - it now also keeps the
inode locked if the _inode parameter is passed.
Makes some more use of the new type identificators.
Symlinks are no longer added to the "size" index (compatibility with BFS, and it also
makes much more sense).
Now sets S_STR_INDEX for directories, if no index type was set (again, compatibility
issue with BFS).
Fixed a bug in the Inode::GrowStream() method in the double indirect region.
Some style updates.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2030 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7781a5df 17-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Now uses block_run::MergeableWith() in Inode::GrowStream() - that also fixes
the bug where a block_run could get a zero length after merging it...
Updated a comment in Inode::Remove().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1986 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 601f33e2 13-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

It's no longer possible to remove or recreate a file that is opened with
uncached access.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1928 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d801dfdd 16-Sep-2002 Axel Dörfler <axeld@pinc-software.de>

Added CachedBlock::BlockSize(), and CachedBlock::BlockShift() methods as
suggested by Mike Nordell.
Some code cleanups, added a comment in Inode::SetFileSize() to point out
that Stream<Cache>::WriteAt() denies growing the file size its own.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1060 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb34ad79 16-Sep-2002 Axel Dörfler <axeld@pinc-software.de>

Added a missing check of the return value of a cached write in
Inode::FillGapWithZeros(), pointed out by Mike Nordell.
Note, that function is currently not used.
Some smaller cleanups.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1058 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a130fd55 08-Sep-2002 Axel Dörfler <axeld@pinc-software.de>

Inode::SetFileSize() now doesn't allow changing the file size of uncached
files anymore (only Inode::WriteAt() denied it before).
Introduced a BFS_NAME define to be able to switch easier between "obfs",
and "bfs".
bfs_write_stat() didn't return the error code if Inode::SetFileSize() failed;
instead, it always reported success.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@995 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 35931182 02-Sep-2002 Axel Dörfler <axeld@pinc-software.de>

Finally implemented growing in the double indirect range.
Tested, and works - we are now feature complete (and now for the bugs... :-)).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@974 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2d38e3f6 21-Aug-2002 Axel Dörfler <axeld@pinc-software.de>

The beginning of letting a stream grow into the double indirect range.
Not yet finished, nor tested, but almost complete :)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@849 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ae38c6e9 12-Aug-2002 Axel Dörfler <axeld@pinc-software.de>

Fixed a bug that could lead to the wrong last_modified time in an inode;
bfs_close() updated the last_modified time & index, but it didn't write
the inode back to disk.
Furthermore, bfs_write() should have already updated the last_modified
time, not bfs_close.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@725 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ee77e6d6 12-Aug-2002 Axel Dörfler <axeld@pinc-software.de>

Implemented uncached access for files (untested though).
Uses a template class to provide generic access to the file.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c42ee134 07-Aug-2002 Axel Dörfler <axeld@pinc-software.de>

Initial revision


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@639 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5a95af70a2c45a103b96046b5dae5c2b5a303dfa 25-Oct-2014 Axel Dörfler <axeld@pinc-software.de>

vfs/{b|btr|package|b}fs/ext2/exfat: common access check.

* Added VFS helper function check_access_permissions() that combines
several partially correct versions to the one true version (tm).
* All but BFS (since recently) missed the S_IXOTH for root on directories,
and all but packagefs missed proper group handling.


# 49c31016cdf29502541eb8f4f39d557a91f65901 25-Oct-2014 Axel Dörfler <axeld@pinc-software.de>

bfs: root may always enter directories.

* If you're root, you can now always enter directories, even if they
don't have the X permission.


# de9c0613398645390b8d450089051b2888e2e15b 03-Jul-2014 Axel Dörfler <axeld@pinc-software.de>

bfs: Use the QueryParserUtils instead of its own copy.

* Ingo copied the methods into a shared location, and then obviously
"forgot" to let BFS use them. As a side note for Ingo: the complete
error GCC reported was "std::fssh_size_t" not defined with the macro
wrapper as code location. The actual problem was a "using std::size_t"
in some C++ header that accidentally got included after the wrapper.
* The shared Query code is not yet used. That'll be done another time.
* Renamed BFS_SHELL define to FS_SHELL, such that QueryParserUtils can be
used in any file system shell, not just the bfs_shell.


# aeee1f7ec7eaad6c0eba6d7892c11b8e2197fe4c 14-Oct-2013 Axel Dörfler <axeld@pinc-software.de>

bfs: Fixed removing a listener that was never added.

* When the tree constructor failed, the InodeAllocator would try to remove
the tree from the transaction. However, in that case, it was never added
to it.
* Inode::fTree is no longer set if the tree constructor failed.
* This fixes bug #10089.


# a1566b06b7b53d14fa53c169b0989925c54fd69d 06-May-2013 Axel Dörfler <axeld@pinc-software.de>

bfs: removed kernel_cpp.h's new operator.

* This fixes bug #9715 from the POV of BFS, ie. the new operator seems
to call the constructor on a NULL object on failure.


# 27aafb14d7831bba93b3cf865af537d5fd465fd4 22-Mar-2013 Alex Smith <alex@alex-smith.me.uk>

CID 712421: Missed some other occurrences, fixed them as well.


# ee8f0ab0dc5a4c9478151c3566c9fd776e14aedd 22-Mar-2013 Alex Smith <alex@alex-smith.me.uk>

CID 712421: Fix unintended sign extension.


# 46cf7a5a73679c6e4fde91710e4a4885242e49d1 14-Nov-2012 Przemysław Buczkowski <przemub@yahoo.pl>

Fix typos: super block -> superblock (#8974)

Signed-off-by: Przemysław Buczkowski <przemub@yahoo.pl>
Signed-off-by: Matt Madia <mattmadia@gmail.com>


# caa1e8b74245bd1602bd9d6ae642e34beb583a00 31-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fix CID 712419, 712420, 712421, 712422: Unintentional sign extension to 64 bits.


# 3cd66dda5e623130a5ef7560da6851d421fd591e 31-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fix CID 712419, 712420, 712421, 712422: Unintentional sign extension to 64 bits.


# 8f7ec006cbe74442fc0a6ef2cc0fbf733717b4a0 01-Apr-2012 Axel Dörfler <axeld@pinc-software.de>

We need to remove the tree from the transaction. Fixes #3159.

* The tree does keep a reference to the inode as well as long as it is part
of a transaction.
* Even if it wouldn't have done it (and would not have triggered the panic),
Haiku would likely have crashed, as the inode (and therefore its tree) was
already deleted at the time when the transaction discarded its listeners.


# 439495d8d418b0f1106d3a933b05eb4702502af8 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Inode was leaking its small data lock.

* This should not have harmed normal operation (as an Inode is only destroyed
when it is no longer being used), but the fs_shell could run out of
semaphores easily.


# 48ec4fbb40a9ac5327e0351486946403d0b533b8 09-Nov-2010 Axel Dörfler <axeld@pinc-software.de>

* Applied patch by Rohit Yadav that fixes #6750, thanks a lot!
* This changes Inode::CheckPermissions(), and bfs_write_stat() based on Ingo's
solution in his file corruption test file system.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39378 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 386be45abcfda37fcb4f30a664150430dac19aac 24-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed 64 bit warnings.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36928 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 709b35256ac13d4111a75dbdf412d60ed0d0c040 07-May-2010 Axel Dörfler <axeld@pinc-software.de>

* No longer keep the write lock when accessing the attribute data; instead, we
now make sure no one else touched it in the mean time (in order to retrieve
consistent data for the index update). This should fix bug #5878.
* Squashed a TODO by locking the inode in the transaction as well.
* Fixed a quasi bug that would not have read the attribute data if there was no
live query for it; "fortunately", Volume::CheckForLiveQuery() is not
implemented yet, and always returns true.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36707 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f3cf9af6bf5a033a9822d72db6482c6d9738b84a 14-Apr-2010 Axel Dörfler <axeld@pinc-software.de>

* Fill the gap between a write and the former file size with zeros, too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36263 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fd91cf4d189f91ecca91e6704796beeeee692cb5 16-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* Replaced the specialized inode in transaction mechanism with a generic one.
That costs 12 more bytes per inode on 32 bit platforms, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35491 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3c50a646979739e9151d14bf5d60df1be013fd02 24-Jan-2010 Axel Dörfler <axeld@pinc-software.de>

* Inode::Create() should also better check if creating the file cache succeeded.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35273 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c709a396cfd5dd02902f6968c648681f3f4ec0da 24-Jan-2010 Axel Dörfler <axeld@pinc-software.de>

* 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


# 27bb89cae1363273bfcf3495edf8e84017b59ea9 18-Jan-2010 Rene Gollent <anevilyak@gmail.com>

BFS needs to also allocate a file cache when dealing with a long symlink inode. Fixes ticket #5282.

Axel and/or Ingo, please review.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35147 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f2505b15830415f341ae4d6d18815d481f41b921 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Implemented O_DIRECTORY in BFS.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34280 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8859eeab5349da39ee9972ee0943919740754b77 24-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced "%Ld" and "%lld" in printf()s by the new B_PRI* macros to avoid
warnings when building with a 64 bit compiler.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34216 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b6670723e10c2065fd7c156a93b3046d4c1994fd 11-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Only remove the inode from the Volume::RemovedNodes() list when it has gone
through the VFS.
* This fixes bug #4942.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34007 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c07fb64478f13f9d543d9728a58c1ef9e4bc465e 04-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Since we know the address of the lock in question, there is no need to waste
memory by naming it individually.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33881 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1b944eec20dd1b26dd3b7878acc90b3acda1151d 29-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Improved the status_change time check to actually filter out invalid times,
before, st_ctim was never updated; since you cannot change st_ctim via an API,
'0' cannot ever be set, either.
* Inode::WriteAttribute(), and Attribute::Write() now return whether they
created an attribute or not, and thus B_ATTR_CREATED is now correctly set.
* Moved status_change update from bfs_write_attr() into Inode::WriteAttribute()
where it can be handled more efficiently.
* Likewise, Inode::RemoveAttribute() now updates the status_change time as well,
I simply forgot this before.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33832 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3637e0e0576cd8a4e918b6ab0e367dc4ebc3c42c 19-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed double indirect ranges again: I've messed them up when I tried to make
them more BeOS compatible while still keeping them somewhat flexible.
* _GrowStream() did actually not check if the double indirect region was already
filled up - this caused it to overwrite innocent memory. This fixes the bug
Rudolf showed me on this laptop that happened while copying a large file.
* Loosened file size restriction on a heavy fragmented disk: the indirect block
does not require a minimum array size anymore; before, you just couldn't let
a stream grow into the indirect range if it couldn't allocate NUM_ARRAY_BLOCKS
(4) blocks in a row. This considerably reduced the maximum file size in this
case.
* Removed no longer valid TODO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33675 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 361f5cdfaf9ab08c6a4fff6da7bc964846850984 12-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Build fix for the boot loader (it's now using the new utility functions as
well). Sorry!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33560 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 16a821d9685a8f25b8eb1f628474987ee6848fa6 12-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Inode::FindBlockRun() now checks the block run size of double indirect runs,
and stops processing if it finds something wrong.
* The default indirect/double array size differs from BeOS' BFS. I've changed
the size for double indirect arrays only, since the other size should work
either way (not tested yet, this change has a negative effect on the maximum
file size, but improves BeOS compatibility).
* The read/write path of BFS is now double indirect block size agnostic, and
should work with what it finds.
* Merged all double indirect size computation into some utility inline
functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33551 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1a60fd72cf588ed0d25028da354261b4d8409c08 06-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Replaced the Inode::GetTree() method with a simple getter - the tree is
always created for directories since quite some time now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32158 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 134e1b04d4256ec2958a6e2454318c46aea0acd3 06-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Somehow I forgot to update the parent directory's time stamps on file
creation, removal, and name changes...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32157 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 121805b41002901c6b8084cc814fd647c334baed 28-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* We need to update the status change time as well with each write, as required
by POSIX semantics.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31872 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0bad8397020c9c2e5b7b4be04497a7b8b34d87f9 28-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* When aborting a transaction, we also need to revert any changes made to the
cached bfs_inode of all changes inodes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31859 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e66295e5e578267d488a98387f2f29f38d7242e9 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* The inode may actually not be known when calling _RemoveInvalidNode(), this
could cause a KDL.
* Added a "force" argument to Inode::Remove() which should make it remove inodes
more reliably for checkfs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31773 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a4f9af2a402eb45463462d687f6226c9a0d21446 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

Fixed a number of issues with double indirect blocks:
* The "index" was not correctly updated when the next indirect block was about
to be used, which lead the code to write the runs to a wrong block, causing
slight corruption, as well as the known invalid block_run(0,0,0) problem.
* blocksRequested is now always a multiple of "minimum" as well.
* When the file size grew beyond the max_double_indirect_range, the minimum was
not adjusted, leading to too many extra allocations that had to be reverted
afterwards again.
* If an allocation was not a multiple of NUM_ARRAY_BLOCKS, but also smaller than
this limit (could happen due to the bug above), an endless loop could be
entered. This was actually a regression introduced in r974.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31767 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b49a46a7ffa912d6ea2bc75065a2b5aec6c59895 29-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Inode::_AddSmallData() now supports writing at an arbitrary position.
However, Inode::WriteAttribute() still has a number of problems when this is
actually used; contents could get lost when an attribute is moved from the
small data section to an attribute file, and the index might not be updated
correctly when you write within the first 256 bytes, but not at position 0.
Since these problems aren't exposed with how we're using BFS right now, it's
not that bad, though (Inode::WriteAttribute() supports everything correctly
that it had to under BeOS).
* Added test application for certain fs_attr functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31313 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5e088159859c4a53553aeae49a06721cdf70b6f8 26-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Allow more waste on index directories.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31254 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c1b4d0ecc58fd3eb3c0b3c5d35491c5936860cac 26-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Directories now only preallocate 4 KB.
* Reworked how preallocations are chosen, and also take the grow rate into
account.
* Also, the preallocation is now rounded to the next multiple of the
preallocation size (previously, a 64K write would only allocate 64K).
* This should also close bug #2573.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31253 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e49449412249a5175d2e69da8a3830121379b46c 15-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup of how the time is converted between bfs_inode and the outside world:
there is now a couple of conversion functions, and I changed the type from
bigtime_t to int64, as it's not what a bigtime_t would usually contain, but
some shift magic in order to make duplicate index entries less likely.
* We now correctly fill in the timespec in struct stat as good as possible; the
12 of the 16 possible bits are used for the nano second value. The lower 8
bits are used to avoid the duplicate index entries. Only if the nano second
time is 0, the lower 12 bits are used to achieve that.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31057 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 33203f677e24af9885c58e4407faa4cd44f130df 25-May-2009 Oliver Tappe <zooey@hirschkaefer.de>

* added support for ctime to BFS by grabbing two of the pad-fields
* added TODO about a sanity check that should perhaps be dropped
I checked this change with both a haiku-BFS partition and one from R5

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30852 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 24b822d843be9b891e7e9ebba99741b65e89647d 17-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* No longer hold the write lock when calling Inode::FillGapWithZeros(), as this
potentially deadlocks as described in bug #3768. The system is still
completely unresponsive, but gets back to a working state after some time now.
* Since the rw_lock is public, Transaction and InodeReadLocker no longer need to
be friends with Inode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30221 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 992fba36eef8b17808a06d483f2fdad90173b01d 16-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* There is now a list of removed vnodes in Volume - while asking the VFS for
this seemed to be a good idea, there is one race condition that cannot be
solved otherwise (the vnode must be added/removed to that list while holding
the transaction lock, and we cannot guarantee that in the VFS).
* We are using an unused area of the in-memory bfs_inode to store the list
links (bfs_inode::pad - this will also work on 64 bit platforms).
* Inode no longer adds a singly linked list link - the transaction list now
shares the doubly linked list with the removed vnodes list.
* Added an in-memory flag INODE_IN_TRANSACTION to avoid searching an inode
to be added in the list.
* Removing an attribute directory did not hold its write lock.
* If removing an attribute failed for some reason, the INODE_DELETED flag
was not removed (the transaction would not have failed because of that).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30203 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 41a6cf82b37f3225a11c11c8f74f3e9f8193e954 12-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* The InodeAllocator must remove the inode from the transaction before deleting
it, otherwise the transaction would access already freed memory when trying
to release its write lock of the inode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29481 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 31cb93ad43ca1e148bcfbccc48d2a32c81985852 12-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29479 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49004dc730f842ea3c162b56dee63696c51d17c7 19-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Remove the additional fs_vnode_ops arugment from get_vnode() again as it's not
needed at all when used as intended. Thanks Ingo for the explanation on how this
is intended to work. Adjusted the overlay fs accordingly and updated/reverted
the changes to the other filesystems.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29250 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 00405f2286fd370a0bd264d0bbac0cfa120e7646 09-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Add an additional argument to get_vnode() that gets the fs_vnode_ops of the
node. That is needed for a layered filesystem to be able to construct a full
fs_vnode out of a volume/inode pair.
* Adapt places where get_vnode is used. Sadly this is a C API and we can't just
use a default NULL for that argument.
* Introduce a flag B_VNODE_WANTS_OVERLAY_SUB_NODE that can be returned in the
flags field of a fs get_vnode call. A filesystem can use this flag to indicate
that it doesn't support the full set of fs features (attributes, write support)
and it'd like to have unsupported calls emulated by an overlay sub node.
* Add a perliminary overlay filesystem that emulates file attributes using files
on a filesystem where attributes aren't supported. It does currently only
support reading attributes/attribute directories though. All other calls are
just passed through to the super filesystem.
* Adjust places where a HAS_FS_CALL() is taken as a guarantee that the operation
is supported. For the overlay filesystem we may later return a B_UNSUPPORTED,
so make sure that in that case proper fallback options are taken.
* Make the iso9660 filesystem request overlay sub nodes. This can be fine tuned
later to only trigger where there are features on a CD that need emulation
at all.

If you happened to know the attribute file format and location you could build
an iso with read-only attribute support now. Note that this won't be enough to
get a bootable iso-only image as the query and index support is yet missing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29177 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 528b69d508b5e6670ecc932ecf36378bbd986fc3 24-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed bug #2727: symlinks usually "abuse" the data stream part of a
bfs_inode to store the link path (up to a certain length). If this was long
enough to clobber the data_stream::size field (which luckily was the last
field of struct data_stream), Inode::Free() would mistakenly assume this to
be a valid data stream to be freed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28311 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b2ec044cb8a930fe55b3a3d899f2e854d955f1d5 30-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Added stat::st_blocks field as required by POSIX. This also closes ticket
#2261.
* Made at least BFS report it more or less correctly (the attributes are
ignored, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27791 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 57b9debf766c370dff725412c27ab09701f1d05f 13-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Some index updating functions did not take into account that not all nodes
are put into all indices. For example, symlinks aren't part of the size
index. This fixes bug #2704.
* Also, Inode::NeedsTrimming() now ignores symlinks that have no data stream,
it's const now, too.
* Added helper methods Inode::In{Name|Size|LastModified}Index(), and use it
where appropriate.
* Clarified Inode::Create() description with regards to name vs. parent.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27471 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fa23653d48131dc800526f56f6f5b57271aad835 12-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Improved reported inode number to the be actual index.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27444 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c4b2fd5be3a452dcab9b45f0e47e5800a9b4a774 12-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Reverted r27196 and solved it differently (in a more robust way): instead of
guessing that the first attribute will be a name attribute, fCurrentSmallData
now takes hidden attributes into account.
* I haven't tested this change, though, so if it messes things up again, please
yell at me :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27441 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e1d9b813843e529b0a1ed8df5c3fdd3de4b6d1c3 24-Aug-2008 Bruno G. Albuquerque <bga@bug-br.org.br>

- AttributeIterator::Update() now take into account differences between its
view of the small data section and the outside view.

Long version:

AttributeIterator is a higher level class designed to make it easy to iterate
through attributes in the small data section. The first attribute in the small
data section is the special "name" attribute that is used to reconstruct the
node path when you only have a node handy. As this attribute is not user
visible nor user modifiable (except by changing a node name of course), it is
considered a special attribute so the AttributeIterator class ignores it and
starts iterating from the second attribute on.

As opposed to this, internally the Inode class accesses the small data section
directly without using the AttributeIterator class so whenever it indexes items
in the small data section, it takes into account the special "name" attribute.

This creates a off-by-one relationship between those 2 representations and this
was a problem because whenever the small data section changed, all iterators
had to be updated (through a call to AttributeIterator::Update() having an
index parameter that represented the outside view and not the AttributeIterator
view, so iterators would not be adjusted correctly and the end result is that
every other attribute was not removed from the index. This would cause all
types of havoc with indexes, the simplest one being that entries in indexes
would point to non-existing nodes.

Ingo, pleased now? ;)



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e07a4b3be0ae6c4e912415af093a97b30c1d01a8 23-Aug-2008 Bruno G. Albuquerque <bga@bug-br.org.br>

- Correct the index number when calling _RemoveSmallDat() with an index.
This may be masking out a different bug.
- This fixes part of bug #2614. It may even fix all of it but I have to
test.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27180 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34d496f8c38338a00542e96d9a327924c214523c 04-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* For regular files, BFS will now preallocate much more than the previous 64 KB,
which are now only used for directories and for files smaller than 1 MB.
* For files between 1 MB and 32 MB 512 KB are used as preallocation size,
everything beyond that will get a 1/16 of their file size, ie. 4 MB with a
file size of 64 MB, 64 MB with a file size of 1 GB.
* This should help a lot with fragmentation of large files when they are written
synchronously.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26794 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d172ee84c3cf3fdd8c10a3d672de1d28d1da7e9e 02-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed recently introduced write lock leak, when something failed
before file_cache_write() or nothing had to be written.
* Fixed race condition. While neither transaction nor read lock are
held, the file size can change.
* Add the inode to the transaction whenever possible, i.e. on error
before file_cache_write() and after it as well. This should prevent
readers from seeing inconsistent blocks when the transaction has to be
rolled back.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26736 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 02c8f6c89d13b94c5507012eaadddc79982c976f 02-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Coding style cleanups, no functional changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26728 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2accd07be4d2731332674ebf8d801260b5388130 01-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Replaced Chain with the new SinglyLinkedList.
* Renamed openModeToAccess() to open_mode_to_access().
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26718 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2e3477e3d851cc46fa682712c3f73dbb82d64fd9 31-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Changed the inode write locking to be held as long as the transaction is
running - this fixes several cases where someone could see outdated data
when a transaction had to be reverted (the time between unlocking the inode
and actually reverting the blocks). For that, Inodes can now be put into a
singly linked list.
* Added a TODO in Inode::WriteAt() which explains why it cannot use the above
method: seems that our VFS/VM locking model isn't really that good.
* Fixed a possible deadlock in Attribute::_Truncate() where the inode write
lock was held before starting the transaction.
* Added an InodeReadLocker convenience class, that should be used instead
of ReadLocker - Inode::Lock() only still exists because of the needs of
bfs_io().
* Moved the bfs_io() callback hooks out of the exported module API region,
and removed their bfs_ prefix.
* Added a Volume::IsInitializing() method that should be used rather than
checking if Volume::ID() is >= 0.
* Removed the MultiInodeLocker again, as it's pretty much superfluous now.
* Moved openModeToAccess() to the Utility.h header.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b99521f213e60f88b3d7700f395fb0c4bf99f63a 30-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

First round of locking fixes:
* Moved locking the data stream out of the BPlusTree methods; this fixes at
least two locations where another thread could have seen outdated/incorrect
data.
* Removed some superfluous code in bfs_rename(): we don't have to revert to the
previous situation, the transaction does this for us automatically.
* Added a simple MultiWriteLocker, even though it's not really necessary anymore
(since we always hold the transaction lock first when we lock more than one
inode at a time).
* Inode::Create() called InodeAllocator::Keep() a bit too early, the file cache
and map wasn't created and assigned yet.
* InodeAllocator now keeps the inode write locked.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26689 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 082bae1aa58dd0021d69aaa2dc05de7b33b75854 23-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* bfs_fsync() no longer grabs the Inode's read lock - instead, Inode::Sync()
will take care of the locking.
* Use new(std::nothrow) over new, and malloc (only in kernel_interface.cpp);
the kernel_cpp.h header isn't really necessary anymore, so there is no reason
BFS should continue to use it.
* Removed superfluous NULL checks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26574 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9083840f3462752eeba06158182a11a1e86c7aac 20-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

bonefish + mmlr + axeld:
* Fixed a bug that could easily corrupt your disks (yeah, one of those
again): bfs_get_file_map() truncated the last vec incorrectly and
would potentially return a too large file size -- which was later
happily overwritten with file data, but could have belonged to
anything but that file (like inodes, B+trees, etc.).
* Renamed previous round_up() function to key_align().
* Added round_up() template function, and used it where appropriate.
* The latter actually fixed two bugs where the and mask was computed in
32 bit where it should have been in 64 bit.
* Inode::FindBlockRun() should have checked the max indirect size
instead of the direct size - this didn't cause any problems, though.
* White space cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26531 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1bde8b03e7789d10cdc063a8a4b23ce3cba6f2e1 08-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Replaced BFS's ReadWriteLock implementation with the kernel's rw_lock.
* The BlockAllocator now uses the new mutex_transfer_lock() function instead
of clobbering the mutex directly.
* Removed Lock.h - it's no longer needed.
* Minor white space cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26317 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 03fa417b706f63305263982a61eb1002e6ff9d96 07-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Removed the home-brewn locking classes in BFS besides the read/write lock
(for now).
* Inode::fSmallDataLock is now a recursive_lock, Journal::fLock is now
a recursive_lock, too, Journal::fEntriesLock is now a mutex, as is
BPlusTree::fIteratorLock.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26298 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bcd307089b56ff8b0df050a4747a1405ff26ad80 28-Jun-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a deadlock found by Salvatore; the volume lock is now only used to
protect the bfs_read_fs_stat() and bfs_write_fs_stat() functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26154 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 536f5d515aeb33277b9d434e1d17a83a2919635a 09-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Don't create anything in a removed directory. Axel, please review. I
don't see how the locking in Remove()/Create() works.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25404 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e8edffce7fdf16a8ae17b2de36bffa05082114e 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed at least the "dd" part of bug #2148: the second double indirect array
block would be incorrectly addressed when allocating a stream - this could
cause random blocks to be overwritten, and therefore could cause many sorts
of problems.
* Moved BFS_TRACING macro to the tracing_config.h file, and let it follow the
new semantics of those other macros in there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25249 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d11e733fee81b682160c03a5d1cacb77b3a2faff 24-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Allow passing sub vnode ops and publish flags to Inode::Create().
* Implemented create_special_node() hook.
* Fixed Inode::IsContainer()/IsDirectory().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25140 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 701d1966683404307bccce6454e4db97ea52cf3d 24-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Inode::_GrowStream() did not make the double indirect block writable before
adding a block to its array. This could cause all kinds of trouble, and
fixes at least a part of #2148.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25125 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7ffafac8d76aa50ea68667e61038022220a90256 05-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reorganized the FS interface a little:
- Moved most file_system_module_info hooks into separate structures.
Those that operate on mounted volumes to fs_volume_ops, those
operating on a vnode to fs_vnode_ops.
- Got rid of the fs_volume, fs_cookie, fs_vnode typedefs. We use void*
again.
- Instead of a void* volume and node cookie hooks are passed a
fs_volume and fs_vnode structure pointer, which contain the cookie
and an ops pointer (fs_volume a few more things).
- The VFS {new,publish,get,...}_vnode() functions take a fs_volume*
instead of the volume ID. So does vfs_get_fs_node_from_path().
- Added type and flags arguments to publish_vnode() and the
get_vnode() hook and removed the type argument from lookup() hook.
Added vnode::type using formerly unused bits to store the node type.
Simplified a few things in the VFS due to the now always available
node type.
- Added fs_volume_ops::{create,delete}_sub_vnode() and
fs_vnode_ops::get_super_vnode() hooks. They are used to support file
system layers, e.g. allowing to extend an FS not supporting BeOS
attribute with attribute support. Needs some more work in the VFS.
- Added fs_vnode_ops::create_special_node() hook for creating special
nodes (e.g. FIFOs).
* Adjusted the built-in file systems and BFS according to the interface
changes. Removed all other FSs from the image for the time being.
We'll see whether further API changes are necessary before porting
them.
* Adjusted the bfs_shell accordingly.
* Implemented create_special_node() in rootfs to support special nodes.
* Added support for FIFOs:
- Added syscall _kern_create_fifo() (used by mkfifo()), which creates
a special node (type S_IFIFO) in the respective file system.
- When a special node is published the VFS creates a respective sub
node. Currently only FIFOs are supported.
- Added a little support for FIFO subnodes by using functionality from
the pipefs.
- Added mkfifo to the image. It can create FIFOs in the rootfs, but
the FIFOs aren't really usable ATM, since they still work like
pipes, i.e. readers and writers need to have them open at the same
time.
* Some smaller changes in the VFS:
- Made the *_CALL macros nicer to use (vargs).
- Refactored FS entry lookup into new function lookup_dir_entry().
- create_vnode() no longer just calls the FS create() hook. First it
looks up the entry and uses open_vnode(), if it already exists. This
is necessary for two reasons: 1) The FS might not support create()
while still allowing to open() entries. 2) When the FS has other
layers on to of it (or the respective node) it might not be
responsible for opening the node.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24816 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e63c1170110084f5a21f81eb5b26f008ea68d35e 03-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

Looks like some bloke forgot to commit *some* files that should have been part
of r24768 (block cache notification mechanism rewrite).
Thanks for the note, Vasilis!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24772 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8af46ac846eb6274f5334b76789a6aeb8c76be8a 25-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24576 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2f20bf154eedb98beafc55d646d58b8a98ea133d 25-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Added "bfs" prefix to tracing output.
* When an inode is trimmed, it now also traces the previous internal
size as well as the target size.
* Remove extraneous white space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24575 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a121b8c83ceba34954e7c187e84c206539207b3c 24-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Added a new flag for write stat: B_STAT_SIZE_INSECURE that allows a
file system to not fill newly created space with zeros.
BFile::SetSize() now uses this, while [f]truncate() does not. This
is only a temporary work-around until BFS supports sparse files.
* Apps that want to reserve space to fill up later should use
BFile::SetSize() for now, as this will be a lot faster than
[f]truncate().
* cache_io() and the functions below now use a special mode when you
pass in a NULL buffer: for read access, the cache is only populated
(useful for prefetching), for write access, the file is filled with
zeros.
* Implemented BFS's Inode::FillGapWithZeros() using this method now.
* Removed extraneous white space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24555 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 18a83f09cf080cbc3a40f6e4334becb318518d32 16-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Root is allowed to cd into any directory, regardless of the directory
permissions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c6f752c0c5f38752dedaee4f781bdf23de395bdb 06-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

Corrected patch to fix warnings when compiled with GCC 4, thanks Vasilis!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24279 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 351b7a2d2499a7c9929452009158a92ba9d66091 25-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Added B_WATCH_INTERIM_STAT, and B_STAT_INTERIM_UPDATE definitions to
NodeMonitor.h.
* The latter will be set in "statFields" for interim updates when you have
asked to get them via the former.
* BFS now uses the B_STAT_INTERIM_UPDATE flag for sending updates to actively
written files.
* This makes us more compatible with BeOS again; if you only asked for
B_WATCH_STAT, you will now only receive a notification if the file in
question has been closed.
* Tracker now uses B_WATCH_INTERIM_STAT to always get all updates (ie.
downloading a file will update its size and modification time in Tracker
periodically during the download).
* Wether "needsTrimming" was true or not has no influence on wether or not
the size index needs to be updated in BFS - only the actual file size is
stored there, not the on-disk size.
* Added a TODO comment in Inode::WriteAt() that it would actually need to
update the size index when changing the file size, not when the file has
been closed (but that's probably too slow).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24114 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7a5d9c5831397de59dc37ad27f5b4cd17a35db1 19-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed TraceEntry::Dump() to take a TraceOutput& and removed
AbstractTraceEntry::AddDump(char*, size_t).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23655 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d62f743549ffe8ef7d234116f5daa13fad15c201 19-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Inode::_FreeStreamArray() kept one block it should have freed when the
new size fell on a block boundary.
* Removed newline from Inode::Remove() tracing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23652 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5d8d6d9a0aaed67489430ba49a36adc72475e84a 19-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Improved tracing output a bit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23643 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4fc4f2c8aeefd8548dc95f51af64beabc07a4ec5 13-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Added a transaction listener mechanism to be notified when a
transaction ends or has been aborted.
* BFS now listens for transactions when it created an inode to see if
the transaction will be aborted without freeing the inode (in which
case it will panic for now).
* Started implementing tracing support, but it's not working yet.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23492 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e43ece8b85e5842fad76f130eae4dfd7e5eacd7 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Some more work on the tracing API:
* Added function to allocate space in the buffer.
* Dump() now fills a buffer instead of printing its data directly.
* This allows the new "#pattern" argument of the "traced" command to
work. When you're using that, the index of the trace entry is printed
out, too, so that you can then get a full dump around the hits.
* Added an AddDump() method to the AbstractTraceEntry class so that
there is no need to call the inherited function anymore.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23479 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d7477802b8a5451ce525646fd2d4b13ef449c455 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Made the additions of the KDL debugger commands independant from the
DEBUG macro; they are now added only if BFS_DEBUGGER_COMMANDS is
defined (which is now done by default in the Jamfile).
* Added "bfs" KDL command which dumps volume information and the super
block.
* Made use of the new tracing API to trace block and inode actions
(and the new AbstractTraceEntry class I forgot to mention in the last
commit). Is compiled in only when BFS_TRACING is enabled (defaults to
off in the standard builds).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23464 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4a31d30e84d78b7d06b9efa6c1dd96c292262e4a 13-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* The file map needs to know the actual file size to be able to know if it has
the complete extent info or not.
* file_map_translate() now cuts down the request to the file bounds.
* Adjusted BFS and FAT to the API changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22913 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f0d93820475083e456ce56c978bcb2b2cc80edd4 11-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* The previous locking order "inode write" -> "journal" was not only not
honoured (in the Inode attribute code), it also couldn't be honoured there.
Therefore, the locking order is now reversed, that is "journal" comes first,
then the Inode write lock. This should also help with the lock ups that
appeared after r22886.
* Got rid of INODE_NO_TRANSACTION; it doesn't make any sense to use.
* When Inode::WriteAttribute() changed the type, the type field was actually
never written back within the current transaction.
* If the attribute data fit into the inode again, the attribute's write lock
was never released.
* Since r22886, Inode::ReadAt() does its own locking, so we must no longer lock
the inode before calling it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22897 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3d268eda3d0ca504c865533347decf27b54025b6 10-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* Extracted file_map API out of the file cache - it's now an optional service
that can be used by file systems.
* Changed the way the file cache works: instead of reading/writing to the
underlying device directly, it can now be used for any data source, ie.
also network file systems.
* As a result, the former pages_io() moved to the VFS layer, and can now be
called by a file system via {read|write}_file_io_vec_pages() (naming
suggestions are always welcomed :-)). It now gets an FD, and uses that to
communicate with the device (via its fs_{read|write}_pages() hooks).
* The file_cache_{read|write}() functions must now be called without holding
an I/O relevant file system lock. That allows the file cache to prepare the
pages without colliding with the page writer, IOW the "mayBlock" flag can
go into the attic again (yay!).
* This also results in a much better performance when the system does I/O and
is low on memory, as the page writer can now finally write back some pages,
and that even without maxing out the CPU :)
* The API changes put slightly more burden on the fs_{read|write}_pages()
hooks, but in combination with the file_map it's still pretty straight
forward. It just will have to dispatch the call to the underlying device
directly, usually it will just call its fs_{read|write}_pages() hooks
via the above mentioned calls.
* Ported BFS and FAT to the new API, the latter has not been tested, though.
* Also ported the API changes to the fs_shell. I also completely removed its
file cache level page handling - the downside is that device access is no
longer cached (ie. depends on the host OS now), the upside is that the code
is greatly simplified.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22886 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 85b65f758524dae5cf6856f4ff4f907b0a5871fd 20-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

The AttributeIterator was returning the size of the attribute data rather than
the length of the attribute name in GetNext() for attributes that are actual
inodes. Found by Robert Szeleney, thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21674 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 245aecda8ac43fc2c0c0bac6a7e4016efa9b71e1 21-Jun-2007 Axel Dörfler <axeld@pinc-software.de>

Got rid of vnode_id and mount_id, replaced with ino_t and dev_t.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21485 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 065e31842971a008888c578c2c1f1a35c75de40e 22-May-2007 Axel Dörfler <axeld@pinc-software.de>

* Inode::Create() now has a "_created" parameter that will be set to true in case a
node has been created - this is now used in bfs_create() to suppress the new entry
notification in case the file already existed.
* Implemented parameter parsing in bfs_initialize() - does not work in the new bfs_shell
though, as it currently misses driver_settings functionality.
* Attribute::Create() and Attribute::Open() will now honour O_TRUNC correctly.
* Note: Inode::WriteAttribute() still follows R5 semantics for small_data attributes
in this regard and must be fixed (I've opened ticket #1242 for this).
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21204 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9d6c014f662e29cc6f21aafce95609fb996ef1b9 29-Apr-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added very basic volume initialization support.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20899 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c391f84b2c732398288276bc8354ac4060dc5a4d 26-Apr-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Prepared the BFS sources to be used with the new FS shell:
- Moved all inclusions of system headers into a new
system_dependencies.h header, which conditionally either includes
these or the FS shell headers.
- Fixed compiler warnings related to printf-like functions (int32 is
int, not long on non-BeOS platforms).
* Build a new bfs_shell. Compiles and links, but does nothing ATM.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20860 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c845a2964e1914430cdd931c4b857615cdf5647e 25-Apr-2007 Axel Dörfler <axeld@pinc-software.de>

Don't try to write back symlinks that don't have a data stream. This fixes bug #1179.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20813 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1d63cfdc5ba68e1a509cd9d160b1fb14fb8b7bfa 24-Apr-2007 Axel Dörfler <axeld@pinc-software.de>

Now makes use of the new block_cache_etc() function to sync data streams without a file cache attached.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20812 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb0572cac5f7cd3541cc1a95a02073a73487c6d5 25-Apr-2007 Axel Dörfler <axeld@pinc-software.de>

* Changed Inode::WriteAttribute() so that it no longer reads from the old
attribute when its size was 0 - this also fixes calling Index::Update()
with invalid values, and therefore bug #1178.
* Style cleanup: honour 80 column limit a bit more, use doxygen style comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20809 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ecd017140fa76d096f4856df9535312e5fd3411 07-Feb-2007 Axel Dörfler <axeld@pinc-software.de>

* Fixed a bug that would not remove an existing attribute from the small data section
when the new attribute data was too large to fit into the small data section at all.
This fixes the Trash icon update with a block size of 1024 bytes.
* This also fixes a bug where AddSmallData() required you to write back the inode even
if it failed with B_DEVICE_FULL, but no one did it.
* _RemoveSmallData() no longer requires you to write the inode back on success.
* Made most small data methods private.
* WriteAttribute() now tries to put the data into the small data section even if it
existed as a separate file before (the file is then removed).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20103 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 458ff7ff315d181f2ffc96e6c2f1204fb33b4c8a 16-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Inode::WriteAttribute() did not adopt a changed "type" when the attribute was a file,
causing subsequent reads with that type to fail.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19825 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b631d2f40d9e9b66e90533ad6e7595380a5dcda7 27-Sep-2006 Axel Dörfler <axeld@pinc-software.de>

* Fixed the bug Bruno observed (and worked around) in a safer way - the node data was
not written back before GetNextSmallData() was called (which let the region appear
empty even though it wasn't).
* I left the shortcut in case of the "name" attribute in there, because it should
be a bit faster.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18949 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 074ebdda4ae9932b3bd3af85261a63e4db689bb3 05-May-2006 Axel Dörfler <axeld@pinc-software.de>

* When mounting an image, BFS no longer tries to set the file into uncached mode - this
will waste some memory (as the data will be cached twice), but unlike BeOS, it cannot
deadlock the cache, so it's safe to be used. In other words, mounting images is now
working as expected.
* a BFS FATAL() condition no longer results in a KDL; this seemed to confuse anybody :)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17336 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b61fdf78c6e0da8638a91542ef457ee9ca8e6ca8 28-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

* The inode block wasn't written back when it was opened with O_TRUNC/B_ERASE_FILE
which could cause inconsistency of on-disk structures.
* Fixed copy&paste bug introduced by Ingo when he did the GCC 4 work-around: when
shrinking the direct range, the new size was written to the indirect range.
* Some cleanup, renamed private Inode methods to have a leading '_' symbol.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16557 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b3b202f451941bf59ba9875837a841d76f9c3c33 28-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

The Inode's lock was named incorrectly when it was newly created.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16544 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6106f57e218cbdc72d0de30b71ddd9973bbbc9d6 26-Feb-2006 Stephan Aßmus <superstippi@gmx.de>

* Didn't allow to write back attributes outside the inode block (they don't
have a user accessable stream, but they do have a file cache).
* removed superfluous dump_inode() version; the "bfsinfo" debugger
command is now a bit more useful as well.
* Inode::fAttributes was not initialized when it wasn't used.

(coded by axeld)



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16508 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 866d738a052dec5802a8992ad4d2bc6d44470544 22-Feb-2006 Jérôme Duval <korli@users.berlios.de>

added error tracing to help on bug #106


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16498 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e5e7fa996aebd72a1bfabf25e3f867842f52212 30-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

It's allowed to write attributes with type 0 - for some reason, our Backgrounds
preferences app writes its info with this type (instead of B_MESSAGE_TYPE as
Be's does).
It's now possible to set the background image for Tracker under Haiku.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15742 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7df07b24d3eb55209493a990af86055a58625a2f 23-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

Nice if an experienced problem matches a bug in the implementation that
closely: Inode::WriteAt() didn't call Inode::WriteBack() in case the
file size was enlarged - it was only written in case the file was closed
which a) could have not happened because of a crash, and b) would move
the change into the wrong transaction, and could therefore result in
an incorrect update, as seen.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15094 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 758b1d0e05fe1042cce6e00d194a147802d4f9be 12-Nov-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixes that make Haiku build with gcc 4. Mainly out of the following
categories:
* Missing includes (like <stdlib.h> and <string.h>).
* Linking against $(TARGET_LIBSTDC++) instead of libstdc++.r4.so.
* Local variables shadowing parameters.
* Default parameters in function definitions (as opposed to function
declarations).
* All C++ stuff (nothrow, map, set, vector, min, max,...) must be imported
explicitly from the std:: namespace now.
* "new (sometype)[...]" must read "new sometype[...]", even if sometype is
something like "const char *".
* __FUNCTION__ is no longer a string literal (but a string expression), i.e.
'printf(__FUNCTION__ ": ...\n")' is invalid code.
* A type cast results in a non-lvalue. E.g. "(char *)buffer += bytes"
is an invalid expression.
* "friend class SomeClass" only works when SomeClass is known before.
Otherwise the an inner class with that name is considered as friend.
gcc 4 is much pickier about scopes.
* gcc 4 is generally stricter with respect to type conversions in C.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14878 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7121425eb599ad42f6e070d4edd8b879ba75748d 20-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Turns out we could remove a mount point...
Under BeOS remove_vnode() is failing in this case, which looks like a good idea to imitate.
Also, pipefs/rootfs didn't handle that case - they even removed the entry before calling
remove_vnode() - they now behave correctly. And also BFS now returns the actual error code
received from remove_vnode() instead of B_ERROR.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14456 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ece4feca93b91d8adc2bc2d0b71328db54a7cb53 06-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Use snprintf() instead of sprintf().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14333 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1c12a6a33f1af79130b6b2da2ca7bf4d78610ab4 08-Jun-2005 Axel Dörfler <axeld@pinc-software.de>

Inode::ShrinkStream() now evaluates the return values from some functions - dunno
if that's a good idea (it may still be a good idea to succeed for shrinking the
stream, even if not everything worked), but it looks better :-)
Improved debug output in case TrimPreallocation() fails.
Journal::FlushLogAndBlocks() no longer ends the current transaction if called
from within an ongoing transaction.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13019 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 69aaf3f39bdf94b3135fcddcfe867e3f7219622a 26-May-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed some stupid problems with the stat::st_mode field; the type of
a node was not always correctly determined (or set) - the recent change
of the attribute (directory) modes made these bugs a bit more obtrusive.
This also fixes a drop to the kernel debugger when doing a
"zip -r config.zip config/" in the home directory, as reported by Korli.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12826 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bae7c12dba9651705d21c73470da51bdc16f016d 25-May-2005 Axel Dörfler <axeld@pinc-software.de>

bfs_read_link() did not report the correct link size (it did not take the
terminating null byte into account) - thanks to Korli for reporting this.
Inode::Create() will no longer publish symlink vnodes; instead, bfs_create_symlink()
will publish the link when it is complete (ie. the actual link data had been
written).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12822 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 36cb9bac61d74bec7808cf036b2bab298d971f07 24-May-2005 Axel Dörfler <axeld@pinc-software.de>

Attribute directories must have the S_IFDIR flag set, attribute files
the S_IFREG flag. The missing flags caused the original BFS to crash
on our files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12796 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7fa5018c9d0c527fa9c1b8124954991631a265e1 13-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

We always want to hold the parent's lock in Inode::Create(), even if we
just create an attribute directory.
Removed the now unnecessary UNSAFE_GET_VNODE lines.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11724 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b7366070fa28f4ac1f3ab016f404f27a306a7818 13-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

InodeAllocator now takes care of calling new_vnode() and the new publish_vnode().
bfs_inode::InitCheck() tested INODE_NOT_READY before making sure the block is
an inode at all, resulting in spurious "inode is not becoming unbusy" errors.
Since there is now publish_vnode() we don't even have to return B_BUSY at all
anymore, though - INODE_NOT_READY is no longer used at all.
bfs_inode::etc is no longer used either (and for the same reason).
Inode::Create() no longer locks the whole volume, but only the write lock
of the parent directory (if any).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11723 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 62f7d84a85b6a02bbd22ee74f5cd5b5f967efc17 19-Jan-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a bug reported by Ingo: attribute inodes didn't get a file cache attached,
but tried to use it anyway.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10880 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a4480535ade318237fb8382cb0545bb2c2d6323f 19-Jan-2005 Axel Dörfler <axeld@pinc-software.de>

No longer tries to update indices from deleted files. Added new method
Inode::IsDeleted().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10879 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 299e521546f70bc079b1e77a8e65a883544b7ed6 12-Dec-2004 Axel Dörfler <axeld@pinc-software.de>

Added buffer size parameter to Inode::GetName().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10409 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 069694a22ad27a8919d4ccbd47e147ca28114ccf 06-Dec-2004 Axel Dörfler <axeld@pinc-software.de>

Rounding up a value can be soooo hard...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10361 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e15a7ad3a398f37a44b9fa7207ed7e1922dc9840 03-Dec-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed a big allocation leak: preallocation was done for all streams, but
only regular files were stripped back when bfs_close() was called.
Now, we don't preallocate any blocks for attributes, attribute directories,
and symbolic links (which do have a stream when longer than 144 bytes).
Also, bfs_release_vnode() now trims back all streams that need to be
trimmed - this catches standard directories, which could also slip through
before.
Removed the remaining blocks of INODE_NO_CACHE support as this is not
needed for Haiku.
Added method Inode::NeedsTrimming() that determines if its data stream
can be trimmed (indices are never trimmed to reduce fragmentation).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10356 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ef948c3cc75acd6d61d2ef6de17cfe1262d84230 27-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Yeah, sure, don't compile stuff before checking it in.
bfs_open_dir() now checks for read access.
bfs_lookup() now checks for execute access and not read access anymore
(as reported by Ingo as well).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10273 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 41cf3876974fa4f855fed199a3839868c4fde86f 27-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

bfs_create() now only checks for write access in the parent directory if a
file really has to be created, thanks to Ingo for reporting this.
Inode::Create() now checks for write access to the inode when O_TRUNC is set.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10272 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 48f8c4e477c5ee6eecef1bbb15b5f8fe38abc5a2 22-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

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


# 1d20e0608e48e44344f76bcc23bd00e6fc87a913 22-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Inode::Create() allowed to create a symlink "above" a file.
Also, it did not check the access permissions if the file already existed.
Removed check for INODE_NO_CACHE, as this no longer applies.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10184 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb02804a89b1100c0f20c3e3c28be28215103c44 19-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Big update while moving over completely to the Haiku kernel:
- Ported over BFS to the new cache API
- Inode no longer inherits from CachedBlock, and therefore, no longer
keeps the whole inode block in memory. It now has a copy of the bfs_inode
structure in memory instead. This has a number of advantages but also some
disadvantages, so it might be reverted later, even if it's unlikely.
- Added a NodeGetter class that can be used whenever the real block needs
to be accessed (ie. for attributes)
- Changed *transaction to &transaction where possible
- Removed support for KEEP_WRONG_DIRENT_RECLEN
- Removed support for uncached file access since that's no longer needed
- Fixed some endian issues in bfs_write_stat()
- Removed the install BFS rules, since they don't make any sense anymore
(unless you are running Haiku ;-))

Note, logged streams are not supported anymore right now. Also, the
transaction code is pretty simple and slow - it will be improved later
on. Attribute code is pretty much untested in the new environment.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10053 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3296ebb98a8403aa50829063fb5c7bbd13790242 26-Oct-2004 Axel Dörfler <axeld@pinc-software.de>

When attributes get overwritten, the size may only change with string types,
ie. it makes sense to optimize the case when we don't have to move any other
item in the small_data region around.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9514 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a4e05e618a467d1af0433cde51683a33580ce6cc 06-Sep-2004 Axel Dörfler <axeld@pinc-software.de>

Added a "cookie" parameter to the fs_read|write|has_page[s]().
Implemented bfs_get_file_map().
Now uses the brand new file cache for the file data streams.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8877 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5325a3e53d9e56e40bccc2f4e488cea1e523e729 29-May-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed a major bug in the inode code: Inode::GetTree() was called completely
without any locking, but was not safe to be used this way.
Now, B+tree creation is done when the inode is created, and thus no further
locking is needed.
Although this reduces the speed when doing directory listings with many sub-
directories, any errors are reported upfront, and not only when you access
the tree directly.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7682 a95241bf-73f2-0310-859d-f6bbb57e9c96


# feec20d64b8c5be705c76f8ac957408c7c95df97 07-May-2004 Axel Dörfler <axeld@pinc-software.de>

It's now <util/kernel_cpp.h> rather than <kernel_cpp.h>.
Forgot to commit that...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7442 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 36660c5e9996909146d3872baa555115357f9267 29-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Switched from direct get_vnode() usage to the Vnode class.
Now acquires the volume lock always before get_vnode() is called as long
as UNSAFE_GET_VNODE is defined (which now is by default).
May cause some unwanted side-effects; it still has to be thorougly tested.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6424 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b39a7a0edd6417fe5b7e4e04f5e01afe623672e7 29-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed the "inode is not becoming unbusy" problem.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6423 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 73e3e50c41c5581ffe8b86ed4235bdf87f131423 29-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed the bug that caused the "vnode already exists with different cookie"
crash: bfs_inode::InitCheck() didn't check INODE_DELETED, and Inode::Remove()
didn't clear the INODE_IN_USE flag (as the original BFS, IIRC).
Some more debug output and checks.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6416 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d401c623833f6802ff455be5cb306a1e1c0cfe29 27-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed typo.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6354 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3eacb520e4990f6cd6c0f9dea5456efe59732305 27-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

The InodeAllocator will now remove the INODE_NOT_READY flag to unblock
any pending bfs_read_vnode() calls when it is destructed and the inode
goes away.
Fixed some endian related issues.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6350 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9e72b7739de05a0fde76a720fabcb639700aa1d2 25-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Inode::Create() now prints out a reason if new_vnode() failed.
If the parent is NULL, Inode::Create() will now set node::parent to
the node itself, like BFS is doing it (for root and indices nodes only).
Added a temporary hack in Volume::Initialize() to get the inodes freed.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6320 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d7db2108823e1433edff5e94fb856d172e7c9cd1 25-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed a bug that could happen when calling Inode::Create() with unusual
arguments (such for creating a root directory, for example).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6312 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b53b9c0cd91a8ebf7cbd5cbcc32e02449603a095 25-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Cleaned the debug mess mmu_man created (thanks anyway).
Switched to kernel_cpp.h/cpp.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6288 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 32e3f999727923b03369626590ad799718708619 25-Jan-2004 François Revol <revol@free.fr>

Debug Inode ctor/dctor; fix printf args warnigns


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6285 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 91e6897c6321262a91daed30b1b5be7420c53679 24-Jan-2004 François Revol <revol@free.fr>

Added obfsinode kernel debugger command.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6262 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f929e1521782fde08e27077f4da9d9fa1715ae70 08-Nov-2003 Nathan Whitehorn <nwhitehorn@nowhere.fake>

Eliminated the huge bugs caused by replacing thingy[0] with thingy[1]. Replaced small_data_start with an inline function SmallDataStart() that knows how to pacify mwcc. Should have negligible to no impact on x86 performance.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5286 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb94280c6b8450b48764df889cdf0a8fd19af64b 16-Sep-2003 Axel Dörfler <axeld@pinc-software.de>

The file system is now almost endian-aware.
Used lazy unreadable conversion: ==, !=, == 0, != 0 are endian-safe
and don't need byte swapping.
If the platform endian differs from the one selected at compile time,
it will mount all volumes read-only for now.
Uncomment BFS_BIG_ENDIAN_ONLY in the Jamfile to build the big endian
version under x86.
No matter on what platform, the compilation defaults to build BFS as
little endian file system (see bfs_endian.h for details).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f14bae95b6c1e2f56e44cecc2042e20ab45059ab 19-Jun-2003 Axel Dörfler <axeld@pinc-software.de>

Renamed "blocks" to "blocksRequested" in Inode::GrowStream() to make its
usage clearer. Also added a comment that explains why it's okay that
blocksNeeded and blocksRequested can be different.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3579 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4a9d9dfa146df5d8a5b0c118501e3662dcd02239 18-Jun-2003 Axel Dörfler <axeld@pinc-software.de>

Added new RecursiveLock and RecursiveLocker classes.
Added file system global locking around creating, deleting, and renaming
inodes - that's not nice, but since we have only sequential journal access,
it won't hurt concurrency much. The locks are needed to prevent certain
things from happening like two threads could theoretically create the same
file twice (one of them would have failed, but relatively late in the process).
Anyway, a better locking scheme will be implemented at a later date, but maybe
not for R1.
Small cleanup.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3562 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ea8d0c2bb1270149813f29b7cda0fba06f2210a 31-May-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed queries a bit more (maybe even completely...). In several situations,
the old attribute value wasn't evaluated at all.
Also, Index::Update() got a type code of zero, instead of the real value
in situations where this didn't make any sense.
Minor cleanup in kernel_interface.cpp.
New method Volume::CheckForLiveQuery() that checks if there is a live query
depending on the specified attribute - not yet implemented, but already used;
always returns "true" right now, which doesn't cause any harm but reducing
the speed lightly.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3394 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ae587160243f792a18663e03b0c77c93058fb24f 27-May-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed another bad bug caused by calling get_vnode() on a node currently
being constructed: bfs_read_node() created an Inode object independent from
the one set in new_vnode().
As a work-around (the new VFS layer will introduce some better methods here)
we are now using the bfs_inode.etc field as a pointer to our object - just
like BFS has thought to use this field. If bfs_read_vnode() has to wait for
the inode (because it is being constructed), it will use the "etc" pointer
and don't create it's own Inode object.
Almost all changes made change the API to take this case into account:
- new Inode constructor to be able to be created from a CachedBlock
- CachedBlock now has a Keep() method which suppresses the release_block()
call when the object is destructed.
- a CachedBlock can now be constructed from the contents of another one (by
calling the source's Keep() method).
- Inode::InitCheck() no longer checks the integrity of the bfs_inode - this
is now done by bfs_inode::InitCheck() which is optionally called by the
former (default).
- moved the inline CachedBlock methods out of the class definition (was
too crowded to be readable).
- new Inode::Initialize() which is called by all Inode constructors
- an Inode object now sets a better name for its read/write lock.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3364 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e1d37632bb534f950117fee49223ede624c968ac 25-May-2003 Axel Dörfler <axeld@pinc-software.de>

Now takes changed function of Index::Update() into account - queries on
non-indexed attributes now finally work as they should.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3330 a95241bf-73f2-0310-859d-f6bbb57e9c96


# adf71bf6088252bc575a3f61372905461fba29bf 24-Feb-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed many warnings because of -Wall (thanks to David for pointing this out).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2839 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1d5f9787e82c1d9b454caa0a4625620dc6e68ecd 05-Dec-2002 Axel Dörfler <axeld@pinc-software.de>

Added a few comments and ToDo items.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2167 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c78d05895cc3a8c2df78f6506b5c81e29fd4830d 28-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Removed some debug output I accidently added to the repository.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2107 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 363999a1ebe2ba20a3f41d6f76b45d6b2248a16a 27-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Thanks to Bruno, we fixed a bug in Inode::Create() that happened with newly
created files that already existed.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2098 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0606e6e197959adbbdedd297aa13db64c2e6b826 25-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Added a new method Inode::GetName() which safely copies the inode's name
to the provided buffer.
Inode::Name() no longer locks the small_data region anymore.
Added ASSERTs that the small_data region is locked for the methods requiring
that.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2083 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fea5713c6de2f3fc5fd4760ad1f07458e86802db 21-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Added a comment about live-queries in Inode::Create().
Some style cleanups.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2060 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 11a8dbc63a11de70b8bcfe11e6fc15402529d8f7 21-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Completely worked over the inode creation mechanism. Now more work is delegated
to the InodeAllocator class (initialization of the inode, tree creation for
containers).
The InodeAllocator class now frees all the space the inode occupies, including
the B+tree if it's a container (by calling the new Inode::Free() method).
Inode::Free() implementation (logic removed from bfs_remove_vnode()).
Now secures the inode from being loaded by setting the INODE_NOT_READY flag
(completely handled by the InodeAllocator class).
The inode is now removed from its parent if something went wrong after it
had been added.
Utilizes the new BPlusTree::Remove() method where appropriate.
Inode::GetAttribute() now checks if the inode opened is really an attribute.
Inode::InitCheck() now fails with B_BUSY if the INODE_NOT_READY flag is set.
InodeAllocator::Keep() now writes back the inode.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2055 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52fafe627e0439ce36f8715d9c00a9e3bab3adfa 19-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Changed the parameter logic from Inode::Create() - it now also keeps the
inode locked if the _inode parameter is passed.
Makes some more use of the new type identificators.
Symlinks are no longer added to the "size" index (compatibility with BFS, and it also
makes much more sense).
Now sets S_STR_INDEX for directories, if no index type was set (again, compatibility
issue with BFS).
Fixed a bug in the Inode::GrowStream() method in the double indirect region.
Some style updates.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2030 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7781a5df6b33e6ccc6a410a80a8236fc35a6e855 17-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Now uses block_run::MergeableWith() in Inode::GrowStream() - that also fixes
the bug where a block_run could get a zero length after merging it...
Updated a comment in Inode::Remove().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1986 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 601f33e2465bed4afe8f03fbcb58f8f358c4ff47 13-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

It's no longer possible to remove or recreate a file that is opened with
uncached access.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1928 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d801dfdd1c4390a342dc2900c19baee9e36f3283 16-Sep-2002 Axel Dörfler <axeld@pinc-software.de>

Added CachedBlock::BlockSize(), and CachedBlock::BlockShift() methods as
suggested by Mike Nordell.
Some code cleanups, added a comment in Inode::SetFileSize() to point out
that Stream<Cache>::WriteAt() denies growing the file size its own.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1060 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb34ad79d79c4fb22eb8eb14a1526ff12d332236 16-Sep-2002 Axel Dörfler <axeld@pinc-software.de>

Added a missing check of the return value of a cached write in
Inode::FillGapWithZeros(), pointed out by Mike Nordell.
Note, that function is currently not used.
Some smaller cleanups.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1058 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a130fd552092e739e6d5540795f5e3cbaa5c3cfa 08-Sep-2002 Axel Dörfler <axeld@pinc-software.de>

Inode::SetFileSize() now doesn't allow changing the file size of uncached
files anymore (only Inode::WriteAt() denied it before).
Introduced a BFS_NAME define to be able to switch easier between "obfs",
and "bfs".
bfs_write_stat() didn't return the error code if Inode::SetFileSize() failed;
instead, it always reported success.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@995 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 35931182a2edd14d3b9f9fb19f62997db2ab3b38 02-Sep-2002 Axel Dörfler <axeld@pinc-software.de>

Finally implemented growing in the double indirect range.
Tested, and works - we are now feature complete (and now for the bugs... :-)).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@974 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2d38e3f603b1db6061c6adc67a0ebd57686b3bbf 21-Aug-2002 Axel Dörfler <axeld@pinc-software.de>

The beginning of letting a stream grow into the double indirect range.
Not yet finished, nor tested, but almost complete :)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@849 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ae38c6e93d625dc75f719411c39ab57557ce81b7 12-Aug-2002 Axel Dörfler <axeld@pinc-software.de>

Fixed a bug that could lead to the wrong last_modified time in an inode;
bfs_close() updated the last_modified time & index, but it didn't write
the inode back to disk.
Furthermore, bfs_write() should have already updated the last_modified
time, not bfs_close.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@725 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ee77e6d68f1da4fbdbe2fbb098049c58472dac9a 12-Aug-2002 Axel Dörfler <axeld@pinc-software.de>

Implemented uncached access for files (untested though).
Uses a template class to provide generic access to the file.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c42ee13401be80c431846910959d587949a1ad10 07-Aug-2002 Axel Dörfler <axeld@pinc-software.de>

Initial revision


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@639 a95241bf-73f2-0310-859d-f6bbb57e9c96