History log of /haiku/src/tests/kits/storage/SymLinkTest.cpp
Revision Date Author Comments
# 2ca13760 20-Aug-2021 Coldfirex <sakison@gmail.com>

Mass updating of OpenBeOS text to Haiku

No functional code altered.

https://dev.haiku-os.org/ticket/17197

Change-Id: I75cc74f6be0ad968fd77c31fbe5b0f650a6fe9e0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4364
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# e1b7c1c7 19-Apr-2020 Kyle Ambroff-Kao <kyle@ambroffkao.com>

storage/SymLink: Fix Be API regression in ReadLink

After this patch, "UnitTester BSymLink" passes.

BSymLink::ReadLink() in BeOS would always return the length of the
link unless an error occurred. Before this patch, Haiku instead seemed
to emulate posix readlink() behavior, returning the number of bytes
copied into the output buffer.

BeOS also did not guarantee that the string written into the output
buffer is NULL terminated if the output buffer cannot contain the
entire link contents, but the Haiku implementation does since it is is
a basic safety issue.

This patch fixes this and updates the Haiku API docs to describe the
behavior explicitly.

Fixing this required changing behavior in bfs_read_link, which
required changes in many more places.

docs/user/storage/SymLink.dox:
src/kits/storage/SymLink.cpp:
* Don't return B_BUFFER_OVERFLOW if the provided buffer is not large
enough to hold the link contents.
* Update documentation to clearly describe behavior.

src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp:
* Change bfs_read_link() to always return the link length. This is
called by common_read_link in the VFS, which is called by
_kern_read_link().

src/add-ons/kernel/file_systems/btrfs/kernel_interface.cpp:
src/add-ons/kernel/file_systems/exfat/kernel_interface.cpp:
src/add-ons/kernel/file_systems/ext2/kernel_interface.cpp:
src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp:
src/add-ons/kernel/file_systems/netfs/client/netfs.cpp:
src/add-ons/kernel/file_systems/nfs/nfs_add_on.c:
src/add-ons/kernel/file_systems/ramfs/kernel_interface.cpp:
src/add-ons/kernel/file_systems/reiserfs/Iterators.cpp:
src/add-ons/kernel/file_systems/reiserfs/Iterators.h:
src/add-ons/kernel/file_systems/reiserfs/Volume.cpp:
src/add-ons/kernel/file_systems/reiserfs/Volume.h:
* Update the implementation of read_link for these filesystems. Some
of them were incorrect, and some had just copied the posix behavior of
bfs from before this patch.
* Use user_memcpy in ext2_read_link()
* Use user_memcpy in nfs fs_read_link()
* Use user_memcpy in reiserfs StreamReader::_ReadIndirectItem and
StreamReader::_ReadDirectItem
* Remove unused method Volume::ReadObject in reiserfs.

src/add-ons/kernel/file_systems/packagefs/nodes/UnpackingLeafNode.cpp:
src/add-ons/kernel/file_systems/packagefs/package_links/PackageLinkSymlink.cpp:
* Update UnpackingLeafNode::ReadSymlink and
PackageSymLink::ReadSymLink() to set the bufferSize out parameter to
the symlink length. Both of these are called by
packagefs_read_symlink.
* Use user_memcpy

src/add-ons/kernel/file_systems/netfs/client/netfs.cpp:
* netfs seems mostly unimplemented. Added a FIXME note for future
implementers so that they know to implement the correct behavior.

src/system/libroot/posix/unistd/link.c:
* readlinkat() was just wrapping _kern_read_link() because before this
patch it had expected posix behavior. But now it does not, so we
need to return the number of bytes written to the output
buffer.

src/build/libroot/fs.cpp:
* Update _kern_read_link() in the compatibility code to emulate the
Haiku behavior on the host system. This is done by using an
intermediate buffer that is guaranteed to fit the link contents and
returning its length. The intermediate buffer is copied into the
output buffer until there is no more room.

src/tests/kits/storage/SymLinkTest.cpp:
* This patch also resolves some test failures similar to those
resolved in ee8cf35f0 which fixed tests for BNode. The tests were
failing because Haiku's error checking is just better.

BeOS allowed constructing a BSymLink with BSymLink(BDirectory*,
const char*) with the entry name of "". The same is true of the
equivilant SetTo() method. The BSymLink object will appear valid
until you attempt to use it by, for example, calling the ReadLink
method, which will return B_BAD_VALUE.

Haiku does a more appropriate thing and returns B_ENTRY_NOT_FOUND,
for this constructor and the equivilant SetTo(BDirectory*, const
char*) method. This patch fixes these test assertions to match Haiku
behavior.

docs/develop/file_systems/overview.txt:
* Add notes for future filesystem driver implementers to call this
mistake when implementing fs_vnode_ops::read_symlink.

docs/user/drivers/fs_interface.dox:
* Fix documentation for fs_vnode_ops::read_symlink

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


# 77aa0e2a 11-Jun-2014 Oliver Tappe <zooey@hirschkaefer.de>

Fix build of unit-tests with gcc4.


# f788b935 15-Nov-2002 Ingo Weinhold <ingo_weinhold@gmx.de>

Reverted to previous version. The tests do compile and link again.


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


# 8e07bd3f 26-Oct-2002 Tyler Dauwalder <tylerdauwalder@nowhere.fake>

#ifdef'd out R5 versions of tests that tried to use functions not found
in R5 version of the Storage Kit.

This appears to fix the BSymLink linking errors, at least as a temporary
fix.


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


# aad997bd 17-Jul-2002 Tyler Dauwalder <tylerdauwalder@nowhere.fake>

Finished migrating Storage Kit tests to new framework.


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


# 28fd2c3c 09-Jul-2002 Ingo Weinhold <ingo_weinhold@gmx.de>

The included Test.StorageKit.h has been renamed to StorageKitTester.h.


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


# 77aa0e2a5ef8e6d00570dbeb7a12aeb23e9e5cf0 11-Jun-2014 Oliver Tappe <zooey@hirschkaefer.de>

Fix build of unit-tests with gcc4.


# f788b9354bbe548e7faba939313851bacb65a5c0 15-Nov-2002 Ingo Weinhold <ingo_weinhold@gmx.de>

Reverted to previous version. The tests do compile and link again.


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


# 8e07bd3faf25c0eee5766041327d50b03e97684c 26-Oct-2002 Tyler Dauwalder <tylerdauwalder@nowhere.fake>

#ifdef'd out R5 versions of tests that tried to use functions not found
in R5 version of the Storage Kit.

This appears to fix the BSymLink linking errors, at least as a temporary
fix.


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


# aad997bd6c9035ac0185bda5c52bd1ba2dd8a47d 17-Jul-2002 Tyler Dauwalder <tylerdauwalder@nowhere.fake>

Finished migrating Storage Kit tests to new framework.


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


# 28fd2c3c85827fa730f6564a835e03f87d36aeb5 09-Jul-2002 Ingo Weinhold <ingo_weinhold@gmx.de>

The included Test.StorageKit.h has been renamed to StorageKitTester.h.


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