Commit Graph

394 Commits

Author SHA1 Message Date
Augustin Cavalier 9d242fb955 file_systems & Tracker: Do not assume sizeof(dirent) contains 1 byte for the name.
At present, it does, but that is an oddity we have preserved from BeOS
that the next commit is going to remove. (This commit thus wastes 1 byte
without the following one.)

Most changes are pretty straightforward: only a +1 is needed,
and a few removed from sizing calculations. Some filesystems like UDF
originally passed back the length with the \0 included, so they have
been adjusted further. UFS2 had some other sizing problems which are also
corrected in this commit.
2021-11-18 16:24:04 -05:00
Coldfirex 2ca1376080 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>
2021-11-07 10:00:35 +00:00
Jérôme Duval f89943d822 build/x86: also test the stack protector on x86 secondary arch
on x86, gcc emits a local reference to __stack_chk_fail_local
which can only be provided by a static library. as we don't have
a libroot_nonshared, we use libgcc from gcc, in which libssp_nonshared
was merged, from version 8.3.0_2019_05_24-11.

Change-Id: I22bf26dec5c1fe69a3915a923bd716a494f846ce
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4564
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2021-10-14 19:42:07 +00:00
Augustin Cavalier c4eec9f1e8 Distinguish KERNEL_ARCH_DIR from KERNEL_ARCH.
On x86_64, the KERNEL_ARCH should really be "x86_64", but it was "x86"
as the architecture sources/headers directory is shared between 32 and 64 bit.

Should not be a functional change on any platform outside x86_64.
2021-10-01 16:26:45 -04:00
Alexander von Gluck IV 34fe8ba793 system/boot: Finish cleaning up remaining platform_get_boot_partition
* Fixes the riscv64 build
* Should fix next_m68k loader (untested)

Change-Id: Ic9b2d4305302d28a9ca0c71f8e1e502c763162d9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4199
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
2021-07-10 01:22:12 +00:00
X512 af435dd1c9 libroot: remove delete_driver_settings
It is not present in BeOS R5 and it just call unload_driver_settings.

Replace delete_driver_settings usages with unload_driver_settings.
Keep the symbol on x86 for binary compatibility.

Change-Id: I1382710e3a4cb5c65d1249ea0e5880891e6800e4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3485
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2021-05-31 06:51:45 +00:00
Jérôme Duval 04be20a75a Implement stack protection support
this adds kernel & libroot stack protector hooks. it uses /dev/random in userspace.
A configure option --enable-stack-protector is added to activate -fstack-protector
on selected system components (ATM apps, kits, servers).

Change-Id: If3a2920ba9aa0a85eaff4ba6778947f8c76ade31
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3895
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-05-03 17:52:31 +00:00
Jérôme Duval a44af2ec16 libroot: call thread exit hooks before destroying tls
Change-Id: Ide2799ccf8620e42650a8f45177fb5fac4f09696
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3762
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
2021-03-06 10:31:51 +00:00
Adrien Destugues a959262cd0 implement mlock(), munlock()
Change-Id: I2f04b8986d2ed32bb4d30d238d668e21a1505778
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1991
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-12-03 07:58:05 +00:00
Leorize a3f0ca5023 tests/system/kernel/vm/Jamfile: remove non-existent
This non-existent file causes unittests builds to fail.

Change-Id: I0ea2164487279fefcbc9e5c930440db3f2e6ccb9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2969
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-07-05 21:16:20 +00:00
Jérôme Duval a9f415f06a add simple avx test
Change-Id: Ia17524929672b420e20d9b491fdafd21cc5a928f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2850
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-06-03 13:57:35 +00:00
Kyle Ambroff-Kao 44a4bc5fd6 tcp: Remove sanity checks from BufferQueue in release builds
Each TCPEndpoint has two BufferQueue members, one for the send queue
and one for the receive queue.

If DEBUG_BUFFER_QUEUE is enabled, then most methods of BufferQueue
call BufferQueue::Verify(), sometimes twice. This member function
performs some sanity checking which requires iterating through every
net_buffer in the queue.

Disabling this in a debug build improved throughput by a factor of 5x
over the loopback interface on my laptop. Using iperf the measured
throughput went from 900Mbps to around 4.8Gbps.

This patch turns this sanity checking off for release builds.

* Rename DEBUG_BUFFER_QUEUE to DEBUG_TCP_BUFFER_QUEUE
* Change the default in BufferQueue.h to disabled
* Set DEBUG_TCP_BUFFER_QUEUE to KDEBUG_LEVEL_2 in
  kernel_debug_config.h

Change-Id: I262dac5d7e2889d2942bbdcf6b667cc0cbafa4c8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2780
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-05-23 02:32:58 +00:00
Jérôme Duval 073e295aa6 kernel/x86: stores cpu number in TSC_AUX if rdtscp is available
On modern x86, one can use __rdtscp to get the current cpu in userland.

Change-Id: I1767e379606230a75e4622637c7a5aed9cdf9ab0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2248
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-02-17 17:26:39 +00:00
Kyle Ambroff-Kao 2112748284 tcp: Fix KDL when sockets are reused
This fixes a KDL that is triggered by the following scenario.

1. A socket is created, attempting to establish a session
   between (loopback, ephemeral port) => (remote address, remote
   port).
2. That socket ends up in the closed state because the remote is not
   accepting connections.
3. The socket is re-used to connect to a different (remote address,
   remote port).

The problem is that fConnectionHash is a BOpenHashTable<TCPEndpoint>,
and inserting endpoint multiple times can create a linked list
cycle (TCPEndpoint is an intrusive linked list node). That means that,
even though TCPEndpoint's destructor removes itself from
fConnectionHash, there will still be a pointer to it left behind,
which means that future accesses within that hash table bucket will
result in a segfault.

The added fConnectionHash.Remove(endpoint) here prevents the KDL, as
it ensures that socket reuse doesn't result in a cycle.

Fixes #13927, see that ticket for a detailed explanation of the
problem.

Also added some regression tests:
* Added SocketTests::ClientSocketReuseTest to PosixNetTest, which
  reproduces this KDL.
* BOpenHashTable: Added tests to cover RemoveUnchecked and removal
  of an object that isn't in the table.

Change-Id: If4bcc1e0d94350a5ad9ba8e7ae6f1b783b3f6d34
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2173
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
2020-02-01 11:52:34 +00:00
Kyle Ambroff-Kao e8a484b0f6 tests/kernel: Fix KPath tests
42e3c6f97 changed the default buffer size for KPath, but the tests
still assume the original default.

Change-Id: I2712d81bbdc678bbaae11e975b0a9a05f5a9151f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2175
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2020-01-31 15:22:55 +00:00
Kyle Ambroff-Kao aa7ac127f8 tests/kernel: Add tests for BOpenHashTable
Linking libkernelutilstest.so with libbe to for use of BObjectList in
the tests.

Change-Id: I1abb991e240dd522821a71ef54d22a1ca7957283
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2165
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-01-30 00:30:00 +00:00
Adrien Destugues 5cd8219db6 Remove annoying message at start of build. 2020-01-27 13:49:47 +01:00
Kyle Ambroff-Kao 4df8f0223b tests: Fix build on x86_gcc2
This patch fixes the build of unittests on x86_gcc2.

src/tests/kits/shared/KeymapTest.cpp:
* Don't use auto
* Don't use braced-initialization for std::map.

src/tests/system/kernel/vm/Jamfile:
* Link lock.o from kernel source to include _mutex_lock and
  _mutex_unlock when linking libkernelvmtest.so

Change-Id: I60e02bfb23334064ec25d767f659a188e393ed1c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2074
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-01-04 08:29:41 +00:00
Alexander von Gluck IV ed7204fad2 gpt: Correct naming. efi_* also conflicts with some efi headers
Change-Id: I19b5b2c4609da8474b26588ae8d7d4caf72a826b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2018
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
2019-12-13 23:53:07 +00:00
Augustin Cavalier 852cf6de56 tests: Correct includes ordering.
Spotted by korli.
2019-08-30 16:16:10 -04:00
Jaroslaw Pelczar 979676fb4e wcs_test.cpp: Fix invalid unicode strings
Signed-off-by: Jaroslaw Pelczar <jarek@jpelczar.com>
Change-Id: Ic09c229a1ee857e466ededbaa05fdd948c009fcd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1795
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-08-30 14:25:20 +00:00
Jaroslaw Pelczar 2cf1b6d6aa specific_video_driver.cpp: Add missing include
Signed-off-by: Jaroslaw Pelczar <jarek@jpelczar.com>
Change-Id: I155e1a89561b43c3a83675c9a61c5e35496e217e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1792
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-08-30 14:24:49 +00:00
Jérôme Duval df0ba1eca1 vfs: _user_ioctl: any buffer value is allowed for some ops.
some ops want an integer value instead of a pointer as arg parameter ( #15058 ).

http://pubs.opengroup.org/onlinepubs/9699919799/functions/ioctl.html clearly specifies that:
"The type of arg depends upon the particular control request, but it shall be either an
integer or a pointer to a device-specific data structure."

add a test for functions which should return ENOTTY as errno.

Change-Id: I4a98af73b17c79c3460123d3794ee866f8719898
Reviewed-on: https://review.haiku-os.org/c/1447
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-05-14 16:12:31 +00:00
Jérôme Duval 858e5775ab vfs: fail only truncate on file descriptors opened read-only.
chmod is allowed.

Change-Id: Idcac38bdd7f0d614538421a41dfd30066a0c316f
Reviewed-on: https://review.haiku-os.org/c/1444
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2019-05-12 07:23:16 +00:00
Jérôme Duval 888652929c runtime_loader: treat weak symbols as strong symbols definitions.
http://www.sourceware.org/ml/libc-hacker/2000-06/msg00029.html
Change-Id: I15bf1f48dda32942e2a93610d62dabe0cabdc9a1
Reviewed-on: https://review.haiku-os.org/c/1191
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2019-04-27 08:58:11 +00:00
Jérôme Duval 3a75ef9ad1 runtime_loader: call preinit_array before initializing dependencies.
Change-Id: Ieed1af8ede83692d583d8e84bae92b1be29ddd1e
Reviewed-on: https://review.haiku-os.org/c/1187
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-04-18 04:54:01 +00:00
Augustin Cavalier 1e60bdeab6 Remove all invocations of SetSubDirSupportedPlatformsBeOSCompatible. 2019-03-30 15:19:38 -04:00
Augustin Cavalier b357daa5c5 build: Deprecate SetSubDirSupportedPlatformsBeOSCompatible.
By default, all targets support the "haiku" platform, and we no longer
support building for BeOS, Dan0, Zeta, or other BeOS-compatible targets,
so this is no longer needed.

Also remove all references to the non-Haiku compatible platforms, and
change all BEOS_COMPATIBLE checks to HAIKU_COMPATIBLE. Removal of
all SetSubDirSupportedPlatformsBeOSCompatible invocations
will be in the next commit.
2019-03-30 14:54:14 -04:00
Jérôme Duval 901c3d44b0 pthread: implement pthread_attr_[get|set]stack.
remove pthread_attr_[get|set]stackaddr from unimplemented functions.

Change-Id: I58807e86c75a189a576639ae1b2e4505a63700a5
Reviewed-on: https://review.haiku-os.org/c/1152
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-03-07 16:55:14 +00:00
Jérôme Duval 2e1e3f0d75 runtime_loader: fix failures in the test suite.
* use --no-as-needed on Linux as the default changed some time ago.
* adjust LD_LIBRARY_PATH/LIBRARY_PATH to load in the current directory.
* fix some builds of program with compile_lib.

Only dlopen_lookup_next1 fails on Ubuntu 18.04.02 x86_64.

Change-Id: I6ecf70f742f67ab24d7d00fa615baa209634d02c
Reviewed-on: https://review.haiku-os.org/c/1140
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-03-03 17:39:45 +00:00
Leorize b6ec8338f9 libnetwork: getifaddrs() now returns ipv6 and physical addresses
If available, getifaddrs() will now return additional entries for
different addresses of an interface. This is similiar to how NetBSD does
it.

This allows software such as libuv to construct detailed information
about network interfaces within the system.

Adrien have some concerns about getaddrinfo() wouldn't correctly exclude
IPv6 addresses after this change so a test was added to cover that.

Change-Id: I8c5d3a02b9294d746ca928a285f40344dfd6e3cb
Reviewed-on: https://review.haiku-os.org/c/874
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-01-14 16:00:36 +00:00
Augustin Cavalier 5e54f6d4f9 tests/kits/net: Move libnetwork-related tests to tests/system/network. 2018-12-21 12:26:38 -05:00
Augustin Cavalier 5e621d3edd tests/posix: Add tls_concurrency_test.
From #14342. Crashed before the last commit, now works. Disabled because
it won't build under GCC2.
2018-12-17 20:09:27 -05:00
Jérôme Duval 8c053e955e vfs: fail write_stat() on file descriptors opened read-only.
Change-Id: I20d586c606c47df6625cc9272f153250a5a621d6
Reviewed-on: https://review.haiku-os.org/706
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-11-18 00:04:26 +00:00
Murai Takashi 93930f335d Replace B_MAX_CPU_COUNT with SMP_MAX_CPUS
Change-Id: I55c53ab35e9645e20466b09407a251571c589958
Reviewed-on: https://review.haiku-os.org/447
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-10-27 17:50:11 +00:00
Jessica Hamilton 1f96a3cbde system/boot: Add support for multiple bootloaders 2018-10-17 14:47:46 -05:00
Augustin Cavalier 66c7a2ac9c KPath: Add to kernelland_emu.
This replaces the one in the "playground." It's identical to the current
kernel implementation, except with the few VFS functions replaced with
Storage Kit calls.

Userland packagefs will need this.
2018-10-16 18:50:00 -04:00
Augustin Cavalier 6d7838a16b src/tests: Fix some incorrect filemodes.
Change-Id: I779cec1905c52eae6955bae979e32ba587e23560
Reviewed-on: https://review.haiku-os.org/565
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-09-16 00:09:14 +00:00
Kacper Kasper fe8b46fb0d kernel: vm: add unit tests for get_mount_point
Change-Id: I1eb7540ffadb26acf05b695af2e7508c71ac7274
Reviewed-on: https://review.haiku-os.org/460
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-08-15 16:14:18 +00:00
Augustin Cavalier 38c59f2971 tests/device_manager: Remove dependence on fs_shell.
Doesn't build currently due to KPath API changes, but this seems unneeded
at least.
2018-08-12 23:37:18 -04:00
Jérôme Duval c90a0ee947 posix_spawn(): dup2() again this time on file_action_dup2.
* fixes #14322.
2018-08-06 19:13:32 +02:00
Jérôme Duval 20694a0458 posix_spawn(): dup2() returns a fd on success, -1 on error.
* duplicate the just opened file descriptor, instead of the target file descriptor.
* fixes #14308.
2018-08-02 11:21:04 +02:00
Xiang Fan fb6387f2b4 kernel: add /dev/null polling test
Bug: 13965
2018-02-26 10:44:22 +00:00
Augustin Cavalier 8a9e1e0d4a Removal of non-Haiku target platform logic from build system (part 1.)
Following recent changes to use libroot_build on Haiku also, it is now
actually impossible to build Haiku components on non-Haiku platforms
(BeOS R5, Dan0, BONE, Zeta), so we can remove any logic related to this.

This is only the first part; still to be removed are:
 * SetSubDirSupportedPlatformsBeOSCompatible
 * HOST_PLATFORM_BEOS_COMPATIBLE
 * TARGET_PLATFORM_BEOS_COMPATIBLE
2017-12-31 16:14:22 -05:00
Augustin Cavalier a128e43004 calloc_test: Apply correct version.
Sorry for the noise...
2017-12-17 17:51:12 -05:00
ohnx 3934b3e6cc Add tests for calloc()
Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2017-12-17 17:02:47 -05:00
Adrien Destugues d87218f79e Add test for stack alignment. 2017-12-10 09:28:49 +01:00
Augustin Cavalier 6aff37d1c7 Move SHA256 class to libroot instead of linking libshared into libroot.
Discussed with PulkoMandy and on the haiku-commits mailing list.

Thanks to @jessicah for compile-testing and fixing 2 small issues I missed.
2017-10-03 20:18:26 -04:00
Jérôme Duval ccd42320c4 libroot: add posix_spawn(). 2017-09-12 19:42:57 +02:00
Philippe Houdoin 12b5c184b2 kernel: add fifo polling test from #7859 2017-08-01 18:50:36 +00:00