History log of /haiku/src/add-ons/kernel/file_systems/bfs/bfs.h
Revision Date Author Comments
# 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.


# 29a73026 03-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Added Volume::IsValidInodeBlock().

* The method checks whether a block may be occupied by an inode, ie. is neither
part of the bitmap nor of the log, and would also fit on the disk.
* Also made disk_super_block::IsValid() const.


# 950f37b2 13-Oct-2010 Jérôme Duval <korli@users.berlios.de>

* renamed bfs_inode::ToUsecs() to bfs_inode::ToNsecs, as it really converts to nanoseconds.
* added a comment explaining the nanoseconds conversion


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38965 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


# 3818aa7d 25-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

On 64 bit machines the bfs_inode::pad field is too small for a
DoublyLinkedListLink. That actually seems to get the bfs_shell working
properly.


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


# 1fee9fcf 24-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced some off_t's in on-disk structure definitions by fixed-size int64. I
couldn't bring myself to replace the types everywhere they are used, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34215 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


# 214f3706 31-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Do not show the time randomization to the user; filter it out again.
* Also, round the nano second times, and don't only cut them off.

+alphabranch


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


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

* Moved most utility functions from bfs.h to Utility.h.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31770 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


# 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


# e677f5aa 10-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed two possible crashing bugs in the file system check code: the checker
was attached to the inode instead of the file descriptor, causing it to call
BlockAllocator::StopChecking() whenever anyone closed the device's root node
during the check. The other bug was that it tried to fix errors even if the
device was read-only.
* Added TODO that ioctl() accesses userland buffers unsafely.
* Removed no longer valid or superfluous comments.


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


# 64e0d084 02-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* Inodes are no longer trimmed from the checking thread. This should fix bug
#3190.


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


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

* Removed no longer needed IOCTL_FILE_UNCACHED_IO definition.
* Some cleanup, no functional change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26706 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


# 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


# 21885de2 08-Dec-2007 Axel Dörfler <axeld@pinc-software.de>

* BFS now always writes back the whole block when it writes the super block.
* Therefore, I've added an I/O control that let's it update the boot block
part of this block, so that makebootable can use it on a mounted volume
(this will probably be moved into a disk system API later).
* Added user_memcpy() to the fs_shell.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23082 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


# 5acd132f 16-Jun-2007 Jérôme Duval <korli@users.berlios.de>

replaced uint32 by addr_t where it applies to please gcc on x86_64


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


# 87ac9f1d 27-Apr-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed boot loader BFS build which I broke with my recent changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20861 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


# 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


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

Removed support for the Metrowerks compiler; it's not needed under Haiku (the
R5 compatible version still has this support).
Added a missing const to block_run::IsZero().


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


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

Some changes due to the fsproto.h/fs_interface.h tandem.


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


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

Moved the functionality of Volume::IsSuperBlockValid() into the new
disk_super_block::IsValid() method.
There is now a disk_super_block::Initialize() method that sets up
a super block for creating a new file system on it - it's currently
hard coded to produce correct results for 10 MB images, though;
the allocation group stuff has to be done a bit more flexible :)

Added a DeviceOpener class that simplifies Volume::Mount() a bit and
fixes some problems of it (forgot to call close() once or twice).
Implemented the new Volume::Initialize() method that completely
covers the mkbfs functionality.

Fixed the broken Volume::ToBlockRun() method - AFAICT it has only
be used by Volume::CreateIndicesRoot() and in dump_bplustree_node
so far (should not have been critical, as the former was probably
never called yet [only if you had tried to create an index on a
BFS volume that didn't have indices yet]).


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


# 40997e14 21-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Added the _PACKED attribute to the BFS on-disk structures to be sure
the compiler doesn't break anything by aligning them differently.


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


# 70a5b6f8 13-Nov-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed compilation on x86. Also moved the SmallDataStart() inline out of
the structure definition.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5351 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


# 55e3d987 08-Nov-2003 Axel Dörfler <axeld@pinc-software.de>

Fixes Nathan's changes at least for gcc.


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


# 1a49a098 07-Nov-2003 Nathan Whitehorn <nwhitehorn@nowhere.fake>

Bunches of changes to make mwcc like the code. I also coded an _atomic_set() and _atomic_test_and_set() for PowerPC. Of course, there's already one in the kernel tree, but mine's better. :P Now builds (and works, after a fashion) on R5 PowerPC.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5280 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


# 0774a741 12-Sep-2003 Axel Dörfler <axeld@pinc-software.de>

The small_data section now makes use of the const keyword :-)


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


# 7df7a4cc 11-Sep-2003 Axel Dörfler <axeld@pinc-software.de>

Added endian-aware getter methods for all internal BFS structures.
Also made all methods implemented in this file endian-aware (lazy as I am,
I left things like "name_size == 0" unchanged, because 0 is a endian-safe
value... [hey, it's even faster that way]).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4638 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


# 3cfd8472 26-May-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed the ominous "new_vnode() already exists with different cookie" bug,
thanks to Bruno for pointing me in the right direction (that has probably cost
him several hours of his life ;-))!
Yes, it was that complicated to fix it...


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


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

Added a new inode flag INODE_CHKBFS_RUNNING to detect aborted chkbfs processes.
bfs_read_vnode() will now wait for half a second at maximum until it returns
the B_BUSY error (so that live queries will like it better).


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


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

Removed the unused INODE_EMPTY flag, and introduced a new INODE_NOT_READY
flag which is used during construction of an inode.


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


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

Added new method block_run::MergeableWith() which checks if two different
block_runs can be merged together.
Added a constant for the maximum length of a block_run.
Added a flag constant to the inode that prevents freeing up its space
after it has been removed - this is only useful for the "chkbfs" stuff.


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


# e891a05e 22-Oct-2002 Axel Dörfler <axeld@pinc-software.de>

Add a new DEBUGGER() macro (doesn't do anything for the release build).
Some style changes.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1601 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


# 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


# 29a73026aa2a0dd097a5b89954722fd1fbf89fb8 03-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Added Volume::IsValidInodeBlock().

* The method checks whether a block may be occupied by an inode, ie. is neither
part of the bitmap nor of the log, and would also fit on the disk.
* Also made disk_super_block::IsValid() const.


# 950f37b2069f10d297d7192726f70be915a49e80 13-Oct-2010 Jérôme Duval <korli@users.berlios.de>

* renamed bfs_inode::ToUsecs() to bfs_inode::ToNsecs, as it really converts to nanoseconds.
* added a comment explaining the nanoseconds conversion


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38965 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


# 3818aa7dac4af166b107553c90bca6acf650739f 25-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

On 64 bit machines the bfs_inode::pad field is too small for a
DoublyLinkedListLink. That actually seems to get the bfs_shell working
properly.


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


# 1fee9fcf2106c8aca117d973f8e0b650820756d0 24-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced some off_t's in on-disk structure definitions by fixed-size int64. I
couldn't bring myself to replace the types everywhere they are used, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34215 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


# 214f3706536568d38b68c7c417fa88373a27d6e8 31-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Do not show the time randomization to the user; filter it out again.
* Also, round the nano second times, and don't only cut them off.

+alphabranch


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


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

* Moved most utility functions from bfs.h to Utility.h.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31770 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


# 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


# e677f5aa675fce95e7558cf58fee40afd6df554d 10-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed two possible crashing bugs in the file system check code: the checker
was attached to the inode instead of the file descriptor, causing it to call
BlockAllocator::StopChecking() whenever anyone closed the device's root node
during the check. The other bug was that it tried to fix errors even if the
device was read-only.
* Added TODO that ioctl() accesses userland buffers unsafely.
* Removed no longer valid or superfluous comments.


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


# 64e0d0841b2276f67a953dd09e900743b7cb5a2b 02-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* Inodes are no longer trimmed from the checking thread. This should fix bug
#3190.


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


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

* Removed no longer needed IOCTL_FILE_UNCACHED_IO definition.
* Some cleanup, no functional change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26706 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


# 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


# 21885de266a154a66d4027ba78b8c9ed8f12ac3b 08-Dec-2007 Axel Dörfler <axeld@pinc-software.de>

* BFS now always writes back the whole block when it writes the super block.
* Therefore, I've added an I/O control that let's it update the boot block
part of this block, so that makebootable can use it on a mounted volume
(this will probably be moved into a disk system API later).
* Added user_memcpy() to the fs_shell.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23082 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


# 5acd132fa47d06377bf58bac6b8d57f4eeec27a7 16-Jun-2007 Jérôme Duval <korli@users.berlios.de>

replaced uint32 by addr_t where it applies to please gcc on x86_64


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


# 87ac9f1d4642e54fd2c474ed531996f4545cca25 27-Apr-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed boot loader BFS build which I broke with my recent changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20861 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


# 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


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

Removed support for the Metrowerks compiler; it's not needed under Haiku (the
R5 compatible version still has this support).
Added a missing const to block_run::IsZero().


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


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

Some changes due to the fsproto.h/fs_interface.h tandem.


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


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

Moved the functionality of Volume::IsSuperBlockValid() into the new
disk_super_block::IsValid() method.
There is now a disk_super_block::Initialize() method that sets up
a super block for creating a new file system on it - it's currently
hard coded to produce correct results for 10 MB images, though;
the allocation group stuff has to be done a bit more flexible :)

Added a DeviceOpener class that simplifies Volume::Mount() a bit and
fixes some problems of it (forgot to call close() once or twice).
Implemented the new Volume::Initialize() method that completely
covers the mkbfs functionality.

Fixed the broken Volume::ToBlockRun() method - AFAICT it has only
be used by Volume::CreateIndicesRoot() and in dump_bplustree_node
so far (should not have been critical, as the former was probably
never called yet [only if you had tried to create an index on a
BFS volume that didn't have indices yet]).


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


# 40997e144446d1bab3f6ce35d4a4b1756758bf24 21-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Added the _PACKED attribute to the BFS on-disk structures to be sure
the compiler doesn't break anything by aligning them differently.


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


# 70a5b6f8942803cc670632377485c75ebbbe6354 13-Nov-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed compilation on x86. Also moved the SmallDataStart() inline out of
the structure definition.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5351 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


# 55e3d98707efe97f65a2f1159a4c3ae27950e6f9 08-Nov-2003 Axel Dörfler <axeld@pinc-software.de>

Fixes Nathan's changes at least for gcc.


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


# 1a49a0986bd50ef30d406b4f5001a0784d344015 07-Nov-2003 Nathan Whitehorn <nwhitehorn@nowhere.fake>

Bunches of changes to make mwcc like the code. I also coded an _atomic_set() and _atomic_test_and_set() for PowerPC. Of course, there's already one in the kernel tree, but mine's better. :P Now builds (and works, after a fashion) on R5 PowerPC.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5280 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


# 0774a741c21bfe3a168e3b447b58cfc6a8745843 12-Sep-2003 Axel Dörfler <axeld@pinc-software.de>

The small_data section now makes use of the const keyword :-)


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


# 7df7a4cc014ec3738bccf6840913e3adebddb163 11-Sep-2003 Axel Dörfler <axeld@pinc-software.de>

Added endian-aware getter methods for all internal BFS structures.
Also made all methods implemented in this file endian-aware (lazy as I am,
I left things like "name_size == 0" unchanged, because 0 is a endian-safe
value... [hey, it's even faster that way]).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4638 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


# 3cfd8472f9097dd9475436a8dd71e9a2517655d9 26-May-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed the ominous "new_vnode() already exists with different cookie" bug,
thanks to Bruno for pointing me in the right direction (that has probably cost
him several hours of his life ;-))!
Yes, it was that complicated to fix it...


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


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

Added a new inode flag INODE_CHKBFS_RUNNING to detect aborted chkbfs processes.
bfs_read_vnode() will now wait for half a second at maximum until it returns
the B_BUSY error (so that live queries will like it better).


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


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

Removed the unused INODE_EMPTY flag, and introduced a new INODE_NOT_READY
flag which is used during construction of an inode.


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


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

Added new method block_run::MergeableWith() which checks if two different
block_runs can be merged together.
Added a constant for the maximum length of a block_run.
Added a flag constant to the inode that prevents freeing up its space
after it has been removed - this is only useful for the "chkbfs" stuff.


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


# e891a05e6e1aa3962eb8474e7967f277a295827c 22-Oct-2002 Axel Dörfler <axeld@pinc-software.de>

Add a new DEBUGGER() macro (doesn't do anything for the release build).
Some style changes.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1601 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


# 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