History log of /haiku/src/kits/storage/Directory.cpp
Revision Date Author Comments
# 2532a287 23-Nov-2021 Augustin Cavalier <waddlesplash@gmail.com>

Avoid using unions for LongDirEntry.

GCC still assumes that the dirent has no data past the end for some
scenarios here and still mis-optimizes things. Therefore, drop the
usages of unions altogether, and instead use a casted character array.

Additionally, use B_FILE_NAME_LENGTH for the array, not B_PATH_NAME_LENGTH,
and make sure to add 1 for the NULL terminator.


# 8f03af00 18-Nov-2021 Augustin Cavalier <waddlesplash@gmail.com>

Storage: Rework LongDirEntry to be a union.

Our dirent structure is "slim": it has a flexible-length array at the
end which must be allocated to whatever size the consumer wants. However,
we use [1] there and not [0] or [], which meant GCC thought it was not
a flexible-length array, and so it optimized various string accesses
that it assumed must be always false. Among these was BDirectory's
check for "." and "..", and so that resulted in infinite loops.

When changing our dirent structure to a proper FLA instead of [1],
GCC then throws errors on LongDirEntry as it has data "after" the
FLA; which is what we want, but there is no way to tell GCC that.
So now we use a union instead, which is the proper way to statically
allocate a FLA.

This is part of #17389, but the real fix requires changing our dirent
structure, which is coming in a separate commit.


# 901de869 14-Dec-2018 Augustin Cavalier <waddlesplash@gmail.com>

BDirectory: Rewrite some functions for clarity.

No functional change intended. Whoever wrote these functions before
seems to have been allergic to more than one "return" statement
in a function...


# 26d14a31 14-Dec-2018 Augustin Cavalier <waddlesplash@gmail.com>

BDirectory: GetNextEntry() should unset entry when one is not found.

Fixes #1692.


# 2ac1eb67 18-Dec-2011 John Scipione <jscipione@gmail.com>

Move the doxygen documentation comments from src/kits/storage/Directory.cpp to docs/user/storage/Directory.dox and update it both the language, fix a few errors, and bring the syntax up to snuff. The documentation for the BDirectory class is now added to the Haiku Book.


# 23f83f8c 23-Sep-2009 Stephan Aßmus <superstippi@gmx.de>

BEntry and BDirectory also needed stat related symbols defined when compiling
the test environment for GCC4.


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


# 2c69b5b6 19-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Made the libbe_test environment basically working under Haiku - to actually
make it work, one would need to use versioning for all libbe symbols. This is
worth an 8k price per file that links against libbe.so, so I didn't want to
commit this as is. An alternative to this solution would be to write a
separate application that is responsible for the app_server's window. Comments
welcome.
* Removed BeOS compatbility of the libbe_test stuff.
* Renamed the libbe_test targets from *haiku* to *test*, ie. libbe_haiku.so is
now called libbe_test.so, haiku_registrar is now test_registrar, etc.
* This also removes BeOS compatibility from tracker/FSUtils.cpp (all BeOS
compatibility should be removed, but I don't want to make Alexandre more work
in his branch, and it's not urgent at all).
* Replaced the former "run" scripts for the test environment with a single
run script (see updated NOTES file).
* Removed the libbe_test target from some applications - this was only to help
developing them under BeOS, and is thus no longer necessary.


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


# 160f2d10 17-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Added private header defining __gUmask which is now used everywhere where
needed.
* Some cleanup in Directory.cpp, and File.cpp.


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


# 0bb8521b 17-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* create_directory() did not take the umask into account.


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


# bcfe344c 22-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Made our struct stat POSIX compliant again -- the time_t fields have been
replaced by timespec fields. Via macros the structure is still source
compatible with the old one.
* Introduced header <compat/sys/stat.h> that defines the old stat structure
(as stat_beos) and conversion functions
* Introduced versions for [l,f]stat().
* Added symbol versions for BDirectory::GetStatFor() for sake of binary
compatibility.
* BStatable::GetStat(): Renamed the old method, changed its parameter to
stat_beos*, and and made it private. Added a new version (using up a
reserved vtable slot). It remains source and binary compatible.
* BRefFilter::Filter(): Changed the struct stat* parameter to struct stat_beos*
for sake of binary compatibility. This breaks source compatibility, though,
which we can't help, since the class doesn't have reserved vtable slots.
* Fixed several issues with the stat structure change, mostly adjusted uses of
BRefFilter.


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


# 91da3218 01-Dec-2008 Rene Gollent <anevilyak@gmail.com>

Remove unnecessary length check, and add a clarifying comment.



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


# 4ebaf16f 01-Dec-2008 Rene Gollent <anevilyak@gmail.com>

We need to check if we have an exact match in order to match BeOS's behavior (a directory is considered to contain itself on R5). Nice catch Axel!


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


# 6020e8a4 01-Dec-2008 Rene Gollent <anevilyak@gmail.com>

When comparing paths, we need to ensure that the entry's path does in fact have a path separator at the same position as the original, otherwise we incorrectly indicate containment in some cases. Fixes ticket #3186.


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


# e84abff2 12-Oct-2008 Michael Lotz <mmlr@mlotz.ch>

Fix strange validity check in BDirectory::Contains(). If either path ends up as
invalid it must not be used.


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


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

* BDirectory::CreateDirectory() and CreateSymlink() now both use __gUmask to
correct the permission mask. This fixes bug #2670.
* Minor cleanup.


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


# 872c3d3f 11-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed the broken nodeFlags semantics in BDirectory::Contains() (they are
flags, after all).
* This fixes the "Command-Tab" ie. switch to source/header command in Pe.


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


# 2586d10e 09-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

CreateFile() didn't specify the B_ERASE_FILE, hence the file wouldn't be
truncated, if already existing. This problem could be experienced when
saving in Pe.


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


# d87dc169 02-May-2007 Jérôme Duval <korli@users.berlios.de>

fixed a typo was U instead of O


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


# d8de23cd 23-Feb-2007 Axel Dörfler <axeld@pinc-software.de>

BDirectory::Contains() would return "true" if the entry being tested for existed,
but the BDirectory was not initialized correctly. Thanks to Jonas who also provided
a patch for this (which I didn't use directly, though, for some minor reasons).
This fixes bug #1034.


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


# 6a8e3dec 03-May-2006 Stephan Aßmus <superstippi@gmx.de>

* compile fix for the test environment


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


# 3e54c13a 01-May-2006 Axel Dörfler <axeld@pinc-software.de>

* Fixed BDirectory::SetTo(BDirectory*, path) constructor in case the target
directory was "this".
* Fixed storage_support.h header - didn't include all needed headers.


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


# b06942c6 13-Jan-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

All internally used FDs are now set to O_CLOEXEC.


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


# db10640d 28-Aug-2004 Ingo Weinhold <ingo_weinhold@gmx.de>

Got rid of the Storage Kit's kernel abstraction layer, which was
unfortunately quite slow and made some things more complicated than they
needed to be.
Implemented a few missing things (e.g. BSymLink and node locking).


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


# 5abde301 03-Jan-2004 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed the behavior of Contains(const char*, int32): It does not longer
return true, if the directory is not initialized, or if the directory
does not contain the entry, but the given path is absolute. This change
makes it less compatible with R5, but more consistent with the BEntry*
version and undoubtfully more compatible with common sense.


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


# 7c44680a 11-Feb-2003 Ingo Weinhold <ingo_weinhold@gmx.de>

Renamed the private virtual slots back to their original (R5) names. We would break binary compatibility otherwise, or at least had to do some additional work to maintain nevertheless.


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


# 2af60585 09-Feb-2003 Ingo Weinhold <ingo_weinhold@gmx.de>

Added two open() versions to our kernel_interface, that re-try opening read-only, if desired. They are now used in BDirectory and BNode, which formerly failed on read-only devices.


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


# 9a17c3cf 23-Sep-2002 Ingo Weinhold <ingo_weinhold@gmx.de>

Dealt with the *_LENGTH+1 issue: Removed all "+1"s in buffer allocations and adjusted checks etc.


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


# 09d84e61 12-Aug-2002 Tyler Dauwalder <tylerdauwalder@nowhere.fake>

+ Changed StorageKit namespace to BPrivate::Storage
+ Changed Sniffer namespace to BPrivate::Storage::Sniffer


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


# 52a38012 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


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


# 2ac1eb67b34123bb6d6d843d58efd14ab3437566 18-Dec-2011 John Scipione <jscipione@gmail.com>

Move the doxygen documentation comments from src/kits/storage/Directory.cpp to docs/user/storage/Directory.dox and update it both the language, fix a few errors, and bring the syntax up to snuff. The documentation for the BDirectory class is now added to the Haiku Book.


# 23f83f8ccbe7b68f0e9e7398ab7e1782629c98d7 23-Sep-2009 Stephan Aßmus <superstippi@gmx.de>

BEntry and BDirectory also needed stat related symbols defined when compiling
the test environment for GCC4.


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


# 2c69b5b6c0e7b481a0c43366a1942a6055cbb864 19-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Made the libbe_test environment basically working under Haiku - to actually
make it work, one would need to use versioning for all libbe symbols. This is
worth an 8k price per file that links against libbe.so, so I didn't want to
commit this as is. An alternative to this solution would be to write a
separate application that is responsible for the app_server's window. Comments
welcome.
* Removed BeOS compatbility of the libbe_test stuff.
* Renamed the libbe_test targets from *haiku* to *test*, ie. libbe_haiku.so is
now called libbe_test.so, haiku_registrar is now test_registrar, etc.
* This also removes BeOS compatibility from tracker/FSUtils.cpp (all BeOS
compatibility should be removed, but I don't want to make Alexandre more work
in his branch, and it's not urgent at all).
* Replaced the former "run" scripts for the test environment with a single
run script (see updated NOTES file).
* Removed the libbe_test target from some applications - this was only to help
developing them under BeOS, and is thus no longer necessary.


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


# 160f2d1081839e78eb60c26147f1a04163cbde69 17-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Added private header defining __gUmask which is now used everywhere where
needed.
* Some cleanup in Directory.cpp, and File.cpp.


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


# 0bb8521b687a586a897fdf96fffb4da24399eb20 17-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* create_directory() did not take the umask into account.


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


# bcfe344c537cb0dcee183c5a9afb4c362f5abe86 22-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Made our struct stat POSIX compliant again -- the time_t fields have been
replaced by timespec fields. Via macros the structure is still source
compatible with the old one.
* Introduced header <compat/sys/stat.h> that defines the old stat structure
(as stat_beos) and conversion functions
* Introduced versions for [l,f]stat().
* Added symbol versions for BDirectory::GetStatFor() for sake of binary
compatibility.
* BStatable::GetStat(): Renamed the old method, changed its parameter to
stat_beos*, and and made it private. Added a new version (using up a
reserved vtable slot). It remains source and binary compatible.
* BRefFilter::Filter(): Changed the struct stat* parameter to struct stat_beos*
for sake of binary compatibility. This breaks source compatibility, though,
which we can't help, since the class doesn't have reserved vtable slots.
* Fixed several issues with the stat structure change, mostly adjusted uses of
BRefFilter.


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


# 91da321846140e32285bad8701b080b0e3e30535 01-Dec-2008 Rene Gollent <anevilyak@gmail.com>

Remove unnecessary length check, and add a clarifying comment.



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


# 4ebaf16fab2cacfae2e5bd03c9ed8f34927403f8 01-Dec-2008 Rene Gollent <anevilyak@gmail.com>

We need to check if we have an exact match in order to match BeOS's behavior (a directory is considered to contain itself on R5). Nice catch Axel!


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


# 6020e8a4c3e91d9725e015c4de6bfa05bf982594 01-Dec-2008 Rene Gollent <anevilyak@gmail.com>

When comparing paths, we need to ensure that the entry's path does in fact have a path separator at the same position as the original, otherwise we incorrectly indicate containment in some cases. Fixes ticket #3186.


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


# e84abff2bd741614f8cb40828f46618d4eb100e4 12-Oct-2008 Michael Lotz <mmlr@mlotz.ch>

Fix strange validity check in BDirectory::Contains(). If either path ends up as
invalid it must not be used.


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


# 43209917de09f23bb36f0f09164a0b2f170b3af9 10-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* BDirectory::CreateDirectory() and CreateSymlink() now both use __gUmask to
correct the permission mask. This fixes bug #2670.
* Minor cleanup.


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


# 872c3d3f6a398fc6688210ec1dd5b4e03e966ec1 11-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed the broken nodeFlags semantics in BDirectory::Contains() (they are
flags, after all).
* This fixes the "Command-Tab" ie. switch to source/header command in Pe.


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


# 2586d10ea9c2569b53b7df72625ee3bb1b595c02 09-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

CreateFile() didn't specify the B_ERASE_FILE, hence the file wouldn't be
truncated, if already existing. This problem could be experienced when
saving in Pe.


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


# d87dc169fb1f600286ae130f2fb9faf188e3cdf4 02-May-2007 Jérôme Duval <korli@users.berlios.de>

fixed a typo was U instead of O


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


# d8de23cd1e8b532fe0739524ae49f9c81aff8345 23-Feb-2007 Axel Dörfler <axeld@pinc-software.de>

BDirectory::Contains() would return "true" if the entry being tested for existed,
but the BDirectory was not initialized correctly. Thanks to Jonas who also provided
a patch for this (which I didn't use directly, though, for some minor reasons).
This fixes bug #1034.


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


# 6a8e3decde03622506e7df689cdbb78921e15125 03-May-2006 Stephan Aßmus <superstippi@gmx.de>

* compile fix for the test environment


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


# 3e54c13abcc14beb1f4ebf724d65fc956b644303 01-May-2006 Axel Dörfler <axeld@pinc-software.de>

* Fixed BDirectory::SetTo(BDirectory*, path) constructor in case the target
directory was "this".
* Fixed storage_support.h header - didn't include all needed headers.


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


# b06942c6049d167350529b36a6f7f559383a764f 13-Jan-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

All internally used FDs are now set to O_CLOEXEC.


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


# db10640de90f7f9519ba2da9577b7c1af3c64f6b 28-Aug-2004 Ingo Weinhold <ingo_weinhold@gmx.de>

Got rid of the Storage Kit's kernel abstraction layer, which was
unfortunately quite slow and made some things more complicated than they
needed to be.
Implemented a few missing things (e.g. BSymLink and node locking).


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


# 5abde301c146181da26bbe8746ebb85624ce8e34 03-Jan-2004 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed the behavior of Contains(const char*, int32): It does not longer
return true, if the directory is not initialized, or if the directory
does not contain the entry, but the given path is absolute. This change
makes it less compatible with R5, but more consistent with the BEntry*
version and undoubtfully more compatible with common sense.


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


# 7c44680a3623191910d7fb6617ff897583f2ef60 11-Feb-2003 Ingo Weinhold <ingo_weinhold@gmx.de>

Renamed the private virtual slots back to their original (R5) names. We would break binary compatibility otherwise, or at least had to do some additional work to maintain nevertheless.


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


# 2af6058585a93f47f4c2bfa98929fc9893174f41 09-Feb-2003 Ingo Weinhold <ingo_weinhold@gmx.de>

Added two open() versions to our kernel_interface, that re-try opening read-only, if desired. They are now used in BDirectory and BNode, which formerly failed on read-only devices.


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


# 9a17c3cfac5f2463b41b3f233975a2904ef10135 23-Sep-2002 Ingo Weinhold <ingo_weinhold@gmx.de>

Dealt with the *_LENGTH+1 issue: Removed all "+1"s in buffer allocations and adjusted checks etc.


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


# 09d84e61b6c2629d253dce1e7d7e944943d3e40e 12-Aug-2002 Tyler Dauwalder <tylerdauwalder@nowhere.fake>

+ Changed StorageKit namespace to BPrivate::Storage
+ Changed Sniffer namespace to BPrivate::Storage::Sniffer


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


# 52a380120846174213ccce9c4aab0dda17c72083 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


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