History log of /haiku/src/add-ons/kernel/file_systems/bfs/Utility.h
Revision Date Author Comments
# 35b40030 27-Jan-2023 Augustin Cavalier <waddlesplash@gmail.com>

file_systems/fs_ops_support: Add open_mode_to_access.

This is duplicated across multiple filesystems, and could probably be
used in more still.

Adjusted only BFS, EXT2, and NTFS in this commit, as they are the ones
which make use of fs_ops_support.h already and thus need to be modified
to avoid duplicate-definition errors.

Also tweak next_dirent to support being built under fs_shell.
(Possibly we should define ASSERT there, though?)


# 87d5beae 09-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Made the duplicate_array endian safe. Cleanup.

* Renamed the sorted_array to duplicate_array (which was only a typedef
before), and moved it into the BPlusTree.cpp file, as its specific to
that one.
* Utilities.cpp is no longer needed.
* Introduced endian safe getters/setters so that little endian BFS volumes
should now work fine on a big endian architecture.


# 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


# 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


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

* AllocateBlocks() now guarantees that the returned allocation size is a
multiple of "minimum".


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


# 35a16d8f 18-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Moved the inode_types into Utilities.h.
* Added a S_EXTENDED_TYPES constant to simplify some checks.
* Simplified the fAllowDuplicates computation in BPlusTree::SetTo().


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


# 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


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

* When I ported over BFS to the new FS API, I pretty much toasted the logging
code:
- The vec array to contain the block list and the index block was one entry
to small.
- But that didn't really matter, as RunArrays/run_array was broken and never
put anything into the log; we only ever wrote index headers. BFS would
totally screw up the disk when trying to replay the log (even though the
replay code itself was and is working fine).
- If a log entry ended at the end of the log area, BFS could overwrite the
first block after the log with the next entry.
* run_array now adopt the sorting stuff from the sorted_array. Blocks in the
log are now always sorted.
* Added TODO item to sorted_array as it's not endian safe (will only work
correctly when BFS is used in the native endian).
* Minor cleanup.


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


# 0bf62ebe 18-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

The BlockArray class is now longer used, and strlcpy() is part of the Haiku kernel anyway.


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


# c0614f32 30-Jun-2005 Axel Dörfler <axeld@pinc-software.de>

Ported r13366 back from the R5 BFS to the Haiku BFS: fixed bad bug in the journaling
code, the super block log data could have been wrong. Moved the doubly linked list
code to the kernel's util/DoublyLinkedList.h.
Also removed Journal::fCurrent, as it's not really used.


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


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

We now have atomic_test_and_set() and atomic_set() in the kernel directly.
Removed Metrowerks support.


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


# 161915fd 01-Sep-2003 Axel Dörfler <axeld@pinc-software.de>

Resolved the name clashing caused by the introduction of atomic_set() and
atomic_test_and_set() to the OpenBeOS headers (prefixed BFS versions with '_').


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


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

Added a strlcpy() call for usage in BeOS (OpenBeOS has it built-in already).


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


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

Added a simple (and completely non-reliable) C implementation for atomic_set(),
and atomic_test_and_set() for userland testing purposes.


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


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

Fixed a dead-lock that could happen if an attribute was changed and you
had some running live queries.
SimpleLock now allows nesting; added some missing atomic operations to
make its implementation as easy as possible.


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


# 87d5beae86a208ed47523046cf7f28ac717af969 09-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Made the duplicate_array endian safe. Cleanup.

* Renamed the sorted_array to duplicate_array (which was only a typedef
before), and moved it into the BPlusTree.cpp file, as its specific to
that one.
* Utilities.cpp is no longer needed.
* Introduced endian safe getters/setters so that little endian BFS volumes
should now work fine on a big endian architecture.


# 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


# 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


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

* AllocateBlocks() now guarantees that the returned allocation size is a
multiple of "minimum".


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


# 35a16d8f5e035b37cf8dc6a242cadf54b23eb142 18-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Moved the inode_types into Utilities.h.
* Added a S_EXTENDED_TYPES constant to simplify some checks.
* Simplified the fAllowDuplicates computation in BPlusTree::SetTo().


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


# 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


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

* When I ported over BFS to the new FS API, I pretty much toasted the logging
code:
- The vec array to contain the block list and the index block was one entry
to small.
- But that didn't really matter, as RunArrays/run_array was broken and never
put anything into the log; we only ever wrote index headers. BFS would
totally screw up the disk when trying to replay the log (even though the
replay code itself was and is working fine).
- If a log entry ended at the end of the log area, BFS could overwrite the
first block after the log with the next entry.
* run_array now adopt the sorting stuff from the sorted_array. Blocks in the
log are now always sorted.
* Added TODO item to sorted_array as it's not endian safe (will only work
correctly when BFS is used in the native endian).
* Minor cleanup.


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


# 0bf62ebeceb89b1d5c611ff91ba06c2756cc8ca7 18-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

The BlockArray class is now longer used, and strlcpy() is part of the Haiku kernel anyway.


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


# c0614f3291ad73663b85a1837fecbf24915bfa06 30-Jun-2005 Axel Dörfler <axeld@pinc-software.de>

Ported r13366 back from the R5 BFS to the Haiku BFS: fixed bad bug in the journaling
code, the super block log data could have been wrong. Moved the doubly linked list
code to the kernel's util/DoublyLinkedList.h.
Also removed Journal::fCurrent, as it's not really used.


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


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

We now have atomic_test_and_set() and atomic_set() in the kernel directly.
Removed Metrowerks support.


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


# 161915fd91d9196887be2a32095f3c60515728a2 01-Sep-2003 Axel Dörfler <axeld@pinc-software.de>

Resolved the name clashing caused by the introduction of atomic_set() and
atomic_test_and_set() to the OpenBeOS headers (prefixed BFS versions with '_').


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


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

Added a strlcpy() call for usage in BeOS (OpenBeOS has it built-in already).


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


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

Added a simple (and completely non-reliable) C implementation for atomic_set(),
and atomic_test_and_set() for userland testing purposes.


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


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

Fixed a dead-lock that could happen if an attribute was changed and you
had some running live queries.
SimpleLock now allows nesting; added some missing atomic operations to
make its implementation as easy as possible.


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