History log of /haiku/src/add-ons/kernel/file_systems/ext2/DirectoryIterator.cpp
Revision Date Author Comments
# 7b97f05b 29-Oct-2023 Jérôme Duval <jerome.duval@gmail.com>

ext2: DirectoryIterator: the dotdot entry size is the entry block minus what comes before.

* the problem appears after the directory has been splitted.
* this fixes fsck complaining about an invalid directory entry.

Change-Id: I1566a279fc6438cb735439be002c634882e5a83b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7077
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 82bdd310 31-Dec-2021 Jérôme Duval <jerome.duval@gmail.com>

ext2: the offset still can be equal to the block size with metacsum

fix assert check for _CheckBlock()

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


# 1fb138bf 12-Sep-2021 Franck LeCodeur <cassisian@gmail.com>

ext2: Fix build warnings, enable Werror

This fix is for ticket #9460 to enable -Werror for ext2.

- Unused functions are removed.

- The ASSERT macro was redefining a different ASSERT macro from the included files. Now it gets undefined first.

- One comparison side was cast to ptrdiff_t because X86_gcc2 complained about signed/unsigned comparison

Change-Id: Ib0caade2f83de34c04acc0fc6aa5ed50712daec4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4453
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# ce4e12ca 10-Oct-2018 Jérôme Duval <jerome.duval@gmail.com>

ext2: implements metadata_csum and 64bit features.

* Some PVS-Studio warnings are removed.
* fixes hardlink count in source and destination folders on rename.
* tested with fstorture and fsx (one job).
* add new definitions.
* import crc32c code from BSD.
* add some consistency checks at mount.
* DirectoryIterator::_AllocateBestEntryInBlock(), the direntry is checked for
consistency before using it, which should avoid crashing on bad data.
* DirectoryIterator::_SplitIndexedBlock(): the dotdot entry length should
include the dot and dotdot entries length.

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


# a130bab3 08-May-2013 Jérôme Duval <jerome.duval@gmail.com>

ext2: fixes 64 bit warnings


# c33b645d 02-May-2013 Jerome Duval <jerome.duval@gmail.com>

ext2: Return more than a single dirent at a time in ext2_read_dir().

* similar to what mmlr did in hrev45575 for bfs.


# 45af882d 18-Dec-2010 Jérôme Duval <korli@users.berlios.de>

* added fsblock_t and fileblock_t definitions, used them when needed.
* validate fBlockShift in superblock.
* Volume::AllocateBlocks() now uses an absolute fsblock instead of a blockgroup related fsblock.
* AllocationBlockGroup now provides absolute fsblock values.
* added support for extents feature: ExtentStream class is the equivalent for DataStream class for extent operations.
The extent tree implementation is very basic, should work for normal growing/shrinking
operations, but not for sparse files. When enlarging a file and extent tree is full,
the root is moved in a new block and a new level is added on top. Extents can usually
be extended when adjacent blocks are allocated. Shrinking happens by removing leafs
one after another.
* removed empty IndexedDirectoryIterator.*


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


# b6e7a070 16-Dec-2010 Jérôme Duval <korli@users.berlios.de>

* checks file name length in FindEntry()


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


# f7218c21 10-Dec-2010 Jérôme Duval <korli@users.berlios.de>

* HTree::Lookup() was trying to find the entry .. through indexed search instead of linear search. Should fix #6305
* DirectoryIterator::FindEntry() now takes name length in account for name comparison.
* cleanup


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


# a1cdecff 07-Nov-2010 Jérôme Duval <korli@users.berlios.de>

DirectoryIterator changes:
* RemoveEntry(): set inode id to zero when reaching the end of block
* FindEntry(): keep on searching if Get() returns B_BAD_DATA
* added _Offset() based on fLogicalBlock and fDisplacement
* Next(): keep on searching when inode id is zero; also when entry length is zero, keep on with next block
* added GetNext() to get the next valid entry.
* Get(): now returns B_BAD_DATA on a zero length or inode id.


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


# 8d5a0a8f 01-Nov-2010 Jérôme Duval <korli@users.berlios.de>

fixed warnings, added a better label for >1TB sized volumes


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


# 583f39e9 31-Oct-2010 Jérôme Duval <korli@users.berlios.de>

* switched more uint32 to off_t for 64bit support
* added error messages in InodeAllocator, Inode
* if BlockAllocator can't initialize, don't fail completely but switch to readonly
* fixed a bug in FindNextMarked() for bitmaps with a length non multiple of 32
* Inode::FindBlock() now returns an optional block_run length, useful for get_file_map()
* added flag for Inode for extents


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


# a1b0ec30 07-Sep-2010 Jérôme Duval <korli@users.berlios.de>

Patch from Janito Ferreira Filho (aka jjvf): this is the result of his GSoC assignment "Implement ext2/3 Read and Write Support for Haiku".
* Tested and checked most features and fs operations, while passing successfully the Linux fsck. Though the implementation still needs more testing and is to be used with
caution, it's better in my mind to have the code committed now given the size of the patch.
* Code style isn't extensively checked but is mostly OK. Code review is welcome.
Some notes from Janito:
* Sparse files aren't supported and hard links aren't supported. Write attributes methods aren't activated nor tested.
* Journaling needs more testing to make sure it behaves in a compatible way to Ext3, and support for the different modes hasn't been implemented (due to the block
and file cache incompatibility). Correct revoke management is also lacking, as is proper management of the superblock state and copies and block group copies.
* The code is partly based and inspired by the BFS implementation. Author information might need to be fixed.

I'd like to congratulate and thank Janito for his hard work to bring the implementation to the current state. I hope he'll keep on maintaining it and become a regular
contributor/committer.



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


# 919f9c41 28-Jun-2010 Jérôme Duval <korli@users.berlios.de>

Patch from Janito Ferreira Filho with fixes by myself: Ext3 Indexed Directory Lookup (as part of GSOC).


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


# 13de3d07 02-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed wrong group block offset computation: the
ext2_super_block::first_data_block must be used; the superblock offset
doesn't matter if the block size is greater than 2KB.
* Fixed block access beyond the 4GB limit - we need to cast the block to
a 64 bit type in ext2_get_file_map() before shifting it.
* Tested with various larger ext3 disks, and everything seems to work fine.
* Added some optional debug output.
* Minor cleanup.


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


# 63db34c8 01-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Implemented a read-only ext2 file system.
* It's not yet complete, doesn't support some ext2 stuff (like files over 4 GB),
and might have some other bugs (I only tested it with a single 20 MB ext2
image).
* To have a read/write ext2 file system, it would probably make more sense to
port GNU sources (like ext2fs lib), and use that. But a small read-only ext2
file sytem doesn't hurt, I think, and I don't know if ext2fs lib would be
feasible for kernel use (porting the file system from Linux directly would
also be an alternative, but probably more work).


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


# a130bab351822fb76ee1750cd4af6ba11ad70bbe 08-May-2013 Jérôme Duval <jerome.duval@gmail.com>

ext2: fixes 64 bit warnings


# c33b645d33c3c568b0371e13ee527676bf4931db 02-May-2013 Jerome Duval <jerome.duval@gmail.com>

ext2: Return more than a single dirent at a time in ext2_read_dir().

* similar to what mmlr did in hrev45575 for bfs.


# 45af882d0698d575ec1b4883a8ebff276c9519d8 18-Dec-2010 Jérôme Duval <korli@users.berlios.de>

* added fsblock_t and fileblock_t definitions, used them when needed.
* validate fBlockShift in superblock.
* Volume::AllocateBlocks() now uses an absolute fsblock instead of a blockgroup related fsblock.
* AllocationBlockGroup now provides absolute fsblock values.
* added support for extents feature: ExtentStream class is the equivalent for DataStream class for extent operations.
The extent tree implementation is very basic, should work for normal growing/shrinking
operations, but not for sparse files. When enlarging a file and extent tree is full,
the root is moved in a new block and a new level is added on top. Extents can usually
be extended when adjacent blocks are allocated. Shrinking happens by removing leafs
one after another.
* removed empty IndexedDirectoryIterator.*


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


# b6e7a070e71efcdc2e5997861313e7b963c5a3ba 16-Dec-2010 Jérôme Duval <korli@users.berlios.de>

* checks file name length in FindEntry()


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


# f7218c2187ea34f01be1bed46a233afa1a641dcf 10-Dec-2010 Jérôme Duval <korli@users.berlios.de>

* HTree::Lookup() was trying to find the entry .. through indexed search instead of linear search. Should fix #6305
* DirectoryIterator::FindEntry() now takes name length in account for name comparison.
* cleanup


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


# a1cdecff94d6e914ca2370dc6b02c284a9843e62 07-Nov-2010 Jérôme Duval <korli@users.berlios.de>

DirectoryIterator changes:
* RemoveEntry(): set inode id to zero when reaching the end of block
* FindEntry(): keep on searching if Get() returns B_BAD_DATA
* added _Offset() based on fLogicalBlock and fDisplacement
* Next(): keep on searching when inode id is zero; also when entry length is zero, keep on with next block
* added GetNext() to get the next valid entry.
* Get(): now returns B_BAD_DATA on a zero length or inode id.


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


# 8d5a0a8ff133f2d334f0ad021d4a67a2d60e0d7c 01-Nov-2010 Jérôme Duval <korli@users.berlios.de>

fixed warnings, added a better label for >1TB sized volumes


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


# 583f39e94d4065be3e621924661b98d231f29b10 31-Oct-2010 Jérôme Duval <korli@users.berlios.de>

* switched more uint32 to off_t for 64bit support
* added error messages in InodeAllocator, Inode
* if BlockAllocator can't initialize, don't fail completely but switch to readonly
* fixed a bug in FindNextMarked() for bitmaps with a length non multiple of 32
* Inode::FindBlock() now returns an optional block_run length, useful for get_file_map()
* added flag for Inode for extents


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


# a1b0ec30977df3c4f608eaac97ddc03bf9d3b255 07-Sep-2010 Jérôme Duval <korli@users.berlios.de>

Patch from Janito Ferreira Filho (aka jjvf): this is the result of his GSoC assignment "Implement ext2/3 Read and Write Support for Haiku".
* Tested and checked most features and fs operations, while passing successfully the Linux fsck. Though the implementation still needs more testing and is to be used with
caution, it's better in my mind to have the code committed now given the size of the patch.
* Code style isn't extensively checked but is mostly OK. Code review is welcome.
Some notes from Janito:
* Sparse files aren't supported and hard links aren't supported. Write attributes methods aren't activated nor tested.
* Journaling needs more testing to make sure it behaves in a compatible way to Ext3, and support for the different modes hasn't been implemented (due to the block
and file cache incompatibility). Correct revoke management is also lacking, as is proper management of the superblock state and copies and block group copies.
* The code is partly based and inspired by the BFS implementation. Author information might need to be fixed.

I'd like to congratulate and thank Janito for his hard work to bring the implementation to the current state. I hope he'll keep on maintaining it and become a regular
contributor/committer.



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


# 919f9c41da4d06c2ac637035adcfb62501d5dc88 28-Jun-2010 Jérôme Duval <korli@users.berlios.de>

Patch from Janito Ferreira Filho with fixes by myself: Ext3 Indexed Directory Lookup (as part of GSOC).


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


# 13de3d07679ac012dcb2f247d615073dd8f56c2f 02-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed wrong group block offset computation: the
ext2_super_block::first_data_block must be used; the superblock offset
doesn't matter if the block size is greater than 2KB.
* Fixed block access beyond the 4GB limit - we need to cast the block to
a 64 bit type in ext2_get_file_map() before shifting it.
* Tested with various larger ext3 disks, and everything seems to work fine.
* Added some optional debug output.
* Minor cleanup.


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


# 63db34c816c7067b251f03c50286d594ceac3cc2 01-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Implemented a read-only ext2 file system.
* It's not yet complete, doesn't support some ext2 stuff (like files over 4 GB),
and might have some other bugs (I only tested it with a single 20 MB ext2
image).
* To have a read/write ext2 file system, it would probably make more sense to
port GNU sources (like ext2fs lib), and use that. But a small read-only ext2
file sytem doesn't hurt, I think, and I don't know if ext2fs lib would be
feasible for kernel use (porting the file system from Linux directly would
also be an alternative, but probably more work).


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