Commit Graph
35 Commits
Author SHA1 Message Date
Trung Nguyen 4331338685 headers/os: Add name to spacing enum.
The `enum` containing `B_USE_DEFAULT_SPACING` and other members are
regularly used in default arguments.

Adding the name to this `enum` makes the header more generator-friendly
(see #6716).

Change-Id: I6676d2329bdb2152ccb37615345b97ba35f70563
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7377
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
2024-02-04 08:13:53 +00:00
Trung Nguyen ba9a9ce167 headers/os: Add missing Interface Kit includes
Adds headers that have not been directly or indirectly included by
the "InterfaceKit.h" master include.

Change-Id: Id163e0e8db54bc553593819801e0e854cde78fa3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7376
Reviewed-by: Niels Sascha Reedijk <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2024-01-28 20:36:07 +00:00
Trung Nguyen ea2870c839 headers: Define static_assert for C11
Defines the `static_assert` macro in `assert.h` as required by
the C11 standard.

Change-Id: Ic25dc99537f995404b7b4280b72c6000a293a1df
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6916
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Niels Sascha Reedijk <[email protected]>
2023-09-04 05:58:31 +00:00
Trung Nguyen 303ff56a5f unix: Implement SO_RCVBUF
Implemented `UnixBufferQueue::SetCapacity` so that `setsockopt`
with `SO_RCVBUF` will not always return an error.

Change-Id: I2d9be84633f84474fac64b379e9f89ef2751a094
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6816
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2023-08-13 21:14:51 +00:00
Trung Nguyen abf8d2e209 unix: Report connected status to socket module
Report connected status to the socket module. Otherwise, operations
like `getpeername` would not work correctly.

Fixes #18534.

Change-Id: I99d047f0d7b4d442cc2b3ea9222b0d89d216c1ae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6719
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2023-08-03 06:47:44 +00:00
Trung Nguyen b7b57869e8 unix: Implement datagram sockets
Implement `SOCK_DGRAM` sockets for `AF_UNIX` family.

Change-Id: If3d6f408a7d881635ccf04b080391905fdc94b13
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6617
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2023-07-19 17:16:16 +00:00
Trung Nguyen 8e8250e9dd headers: Explicitly hide BAlert functions
Explicitly hide some BAlert functions that ought to have been
deleted. This prevents binding generators from thinking that these
functions are available, causing undefined symbol errors during
link time.

Change-Id: I56f53808851b82a10f31015d2351d4e2c29b6f33
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6718
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2023-07-18 16:43:33 +00:00
Trung Nguyen 3cb845283e headers/os: Make headers generator-friendly
Make Haiku headers a bit more friendly to binding generators by:
- Giving some `enum`s names (especially those that appear in
default arguments).
- Converting an internal `inline` function into a macro so that
the result could be evaluated in compile time.

Change-Id: I770674ad8fa7b24ac30b6b447d52a4b4c2530b8a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6716
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2023-07-11 14:40:02 +00:00
Trung Nguyen 4313795d2e network/stack: socketpair for non-stream sockets
`socketpair` should skip the `listen` and `accept` step for
non-stream sockets. This allows the implementation to work for
UNIX domain datagram sockets.

Change-Id: I81ba826d605b77be5a4ec9046ea4c6bd556a35a0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6618
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2023-07-04 15:09:20 +00:00
Trung Nguyen 79572316c4 kernel/vm: check if page is in area
Checks if a `vm_page` is part of a `VMArea` before doing work with
it, as pages in a `VMCache` that an area is a part of might not
belong to that area.

This fixes a bug for copy-on-write areas when an application is
`fork`ing.

Change-Id: Ic5683c67865b41bf3708bb7ea4104502ddf31a19
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6496
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: Axel Dörfler <[email protected]>
2023-06-19 15:59:11 +00:00
Trung Nguyen bdcc293fa8 kernel/vm: handle page protections in cut_area
- Resize the `page_protections` array in `cut_area` and also shift
the bits if necessary.
- Set the correct protection array as well as the real page
protections for the second area produced by `cut_area`.

Change-Id: I62293480487e869420ebe5a3bc729cec2a14c687
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6395
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2023-06-19 15:59:11 +00:00
Trung Nguyen 29f8da76d7 strace: Add mutex type
Added a dedicated mutex type handler that can print mutex status
flags while still showing the mutex address.

Change-Id: Ie028e5c0a336063a4c03a4f9adf955ffa6911837
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6557
Reviewed-by: waddlesplash <[email protected]>
2023-06-10 00:34:37 +00:00
Trung Nguyen c80a875a74 libroot: fix pthread_[g/s]etschedparam
Make `pthread_getschedparam` and `pthread_setschedparam` handle
scheduling policies more consistently with `sched_get_priority_min`
and `sched_get_priority_max`.

Threads running in real-time priority will appear to be under the
`SCHED_RR` policy, while normal threads will appaer to be
`SCHED_OTHER`.

This prevents POSIX code using `sched_get_priority_min` with the
calling thread's current policy returned by `pthread_getschedparam`
to adjust its priority from unwantedly promote into real-time code
and affect overall system performance.

Change-Id: I9664257dc1b98db579e55218ce352cb762524b0c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6556
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2023-06-09 17:07:44 +00:00
Trung Nguyen a2cb4665de strace: Improvements
- Added some utility functions to the `Context` class.
- Updated the `sockaddr` handler to retrieve the next sibling
rather than the sibling at index 2. This allows the handler to
work for syscalls where the `socklen_t` argument is not the third
one, for example, `_kern_recvfrom`.
- Added the ability to print the `flatArgs` for `_kern_exec` and
`_kern_load_image`.

Change-Id: Ia4cf0a30a5cf972274820bbf068101450db52189
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6498
Reviewed-by: waddlesplash <[email protected]>
2023-06-06 15:10:35 +00:00
Trung Nguyen 17d9a20c62 strace: Add support for struct sockaddr
- Updated old `sockaddr *` formatting code to work with current
`strace` structure.
- Add support for `AF_UNIX` family address.

Change-Id: I13f7b0a3eb913ab188bea68f8ea84e928b753154
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6497
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2023-06-05 12:40:24 +00:00
Trung Nguyen 7be371792f kernel/vm: unlock cache before unmapping addresses
Unlock the current cache in `map_backing_store` before
`unmap_address_range` is called, since `unmap_address_range` may
call `delete_area` which would then also attempt to lock the same
cache if that cache has already been mapped to an area in the
conflicting address range.

Fixes #18422.

Change-Id: I6fc5301c43d11bb6df489a2e6d6bdcd6cd80d2b7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6392
Reviewed-by: Jérôme Duval <[email protected]>
2023-06-01 08:23:53 +00:00
Trung Nguyen de07bc3fa5 kernel/vm: handle page protections in cut_area
- Resize the `page_protections` array in `cut_area` and also shift
the bits if necessary.
- Set the correct protection array as well as the real page
protections for the second area produced by `cut_area`.

Change-Id: I62293480487e828970ebe5a3bc729cec2a14c687
2023-05-31 14:47:40 -04:00
Trung Nguyen bfd3d33765 strace: Print detailed signal information
- Add support for retrieving the `siginfo_t` structure of a signal
event from the Debugger API.
- Add code to `strace` to display this information every time a
signal event occurs, similar to the Linux `strace` tool.

Change-Id: If4e92bbae049ee0b52efaf9fc911d66511da62f4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6393
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2023-05-31 16:34:12 +00:00
Trung Nguyen 74d2e61ee2 kernel/vm: Make cut_area respect overcommitting flag
`cut_area` now checks the protection of the target area for
the `B_OVERCOMMITTING_AREA` flag and sets it on any cache it
creates. This allows operations that split large overcommitting
areas to succeed.

Change-Id: I8dee27d22df29741cc61af2575c9e6626da25949
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6391
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2023-05-20 16:45:58 +00:00
Trung Nguyen b809279cd8 kernel/team: Allow retrieving more attributes
- Stored the additional start time of each team, expressed by
milliseconds since boot.
- Added more fields to the `team_info` structure. These field
include those provided by the `get_extended_team_info` syscall as
well as the newly introduced `start_time`.
- Extended the `_kern_get_team_info` system call to receive an
additional `size_t` argument. If this size is smaller than or
equal to the size of the old `team_info` structure, the newly
added attributes will not be retrieved.

Change-Id: I22ee6b91ad2ee3b66a7f770036c79a718c5f115c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6390
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jessica Hamilton <[email protected]>
2023-05-17 11:07:14 +00:00
Trung Nguyen b197dcbafa tty: Implement exclusive mode
Implemented exclusive mode on Haiku and added the related `ioctl`
operations (`TIOCEXCL` and `TIOCNXCL`).

Change-Id: Iaa201ea20eec0e45d02dd5db9ba6aa35fd27dfb2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6387
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jessica Hamilton <[email protected]>
2023-05-13 00:41:16 +00:00
Trung Nguyen bbd6beb7ee kernel/vm: Allow more maximum protection for mmap'ed areas
Always allow a memory region mapped by `map_file` to change its
protection to any user protection flags other than `B_WRITE_AREA`.
This flag should only be settable when the file is opened with
write access.

Change-Id: Icc00c08fc033b3bd6b6ceb2833bf566c72914007
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6389
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: John Scipione <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2023-05-12 16:43:48 +00:00
Trung Nguyen 412bcb11fd kernel/vm: Fix area_for with PROT_NONE address
Do not assume "no user protection" means "kernel area".

This allows calls to `area_for` for addresses with protection 0
to work properly.

Change-Id: I54cbcc154d10b63359a2e1233f0c0f45d0d8e21e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6388
Reviewed-by: waddlesplash <[email protected]>
2023-05-11 15:08:35 +00:00
Trung Nguyen d97ad7c4dc termios: New ioctl: TIOCOUTQ
Change-Id: I86f2a7b007137e22cf7d6fc8ad6675ff5de267d4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6386
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jessica Hamilton <[email protected]>
2023-05-11 02:57:36 +00:00
Trung Nguyen 568b8f9395 headers/posix: Add TIOCM_RNG as a synonym for TIOCM_RI
dotnet uses it.

Change-Id: Ie5658263a0fd9c0aa833cc468ddcafe08116a30d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6385
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jessica Hamilton <[email protected]>
2023-05-11 02:55:38 +00:00
Trung Nguyen f967e2c0c7 headers/bsd: Export pthread_attr_get_np
Exported `pthread_attr_get_np` under `_DEFAULT_SOURCE`. Otherwise,
the presence of this function in `libroot.so` without a definition
would confuse some configuration scripts.

Change-Id: I623ebefc98800e9528dc48859c2aefc828821f27
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6383
Reviewed-by: Jessica Hamilton <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2023-05-08 01:38:41 +00:00
Trung Nguyen 7bfc9c6fc7 libroot: Fix bad pointer access in __init_stack_protector
The address of the variable should be taken instead of the
variable itself being casted to `void*`.

This fixes a rare segfault bug when any Haiku binary runs in
a `chroot`ed environment without a `/dev` mount.

Change-Id: I2fdacac62fadbcce8006bbf0a5350f6ec95133ae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6377
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2023-04-16 15:57:12 +00:00
Trung Nguyen 50a5eed083 app_server: Fix potential infinite loop
Return `B_ENTRY_NOT_FOUND` instead of -1 when `/dev/graphics`
is not found.

Otherwise, `app_server` would run into an infinite loop
while waiting `fCardFD` to equal `B_ENTRY_NOT_FOUND` in some
specific environments such as a `chroot` where `/dev` is missing.

Change-Id: Ice23a82f58811f1258c58826c2488ae5c5c29cee
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6376
Reviewed-by: X512 <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2023-04-16 13:09:36 +00:00
Trung Nguyen 55f3abb4c9 userlandfs: Support mapping FUSE files to memory
- Create a file cache for FUSE mounted files on open to allow
memory mapping these files unless direct_io is specified.
- Implement DoIO for FUSE mounted files.

This patch enables files mounted through FUSE filesystems such as
sshfs or vmhgfs to be `mmap`ed, allowing remotely cross-compiled
executables to be directly run on Haiku.

Change-Id: I364b8225eae5b1d586280c2b3301fb661581caed
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6277
Tested-by: Automation <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2023-03-31 13:42:17 +00:00
Trung Nguyen 35212f7bef userlandfs: Fix GetVNodeName
- VNode names are now allowed to have a length of 1. This is
common for Windows drives mounted through a shared filesystem.
- Empty VNode names are now checked from the userland side,
preventing the kernel driver to reject and not ACK a false
B_OK from the userland server.

Change-Id: If0a6fcea1387367d1492c9b94c62c03e381ce1c1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6276
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Automation <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2023-03-27 17:57:27 +00:00
Trung Nguyen d02c0bade7 libs/posix: Fix NULL pointer in uselocale
uselocale now attempts to create a backend and a databrige.

If the attempt fails due to a missing libroot-addon-icu, uselocale
does nothing (to support applications calling uselocale during
startup to enforce the C locale).

Else, uselocale will fail with ENOMEM.

LocaleBackend::CreateBackend() has been modified to return a status_t
that indicates whether NULL is returned due to out of memory (B_NO_MEMORY)
or due to being unable to load the ICU addon (B_MISSING_LIBRARY).

Change-Id: I0f62ebde5890364c64e6694ec58d38de43ec6841
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5505
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2022-08-03 00:16:08 +00:00
Trung Nguyen d338200e2b libs/posix: Implemented new locale functions
Implemented the missing POSIX functions in <locale.h>:
newlocale, duplocale, uselocale, and freelocale, and also
provided missing type definitions for <locale.h>.

Implemented missing POSIX locale-based function variants.

Modified LocaleBackend so that it could support thread-local
locales.

Some glibc-like locale-related variables supporting
ctype and printf family of functions have also been updated
to reflect the thread-local variables present in the latest
glibc sources.

As there have been some modifications to global symbols
in libroot, libroot_stubs.c has been regenerated.

Bug: #17168
Change-Id: Ibf296c58c47d42d1d1dfb2ce64042442f2679431
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5351
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-07-11 16:30:16 +00:00
Trung Nguyen ae7395c833 libs/posix: Fix printf handling for %F format.
Before this patch, calling functions in the `printf` family and
passing %F in the format string, such as

    printf("%6.2F\n", 580.0f);

would incorrectly output numbers in the exponential format:

    5.8D+02

This patch fixes the output for this situation:

    580.00

and fixes the behavior for programs that use %F, such as
several tests for the `fish` shell.

Change-Id: I124a5a7b93b5f551fa190501a5778726812d347c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5424
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
2022-07-11 09:52:59 +00:00
Trung Nguyen 908107a15f libs/bsd: implemented dl_iterate_phdr
dl_iterate_phdr now fills the first four fields of
struct dl_phdr_info. The last four fields remain
unimplemented, as it requires help from the
runtime_loader.

Change-Id: Id96a7c7ac05633a71b9fb62c98b3a40f7d4f255b
Signed-off-by: Augustin Cavalier <[email protected]>
2022-06-28 13:07:54 -04:00
Trung Nguyen 956f45070d kernel/vm: Remove default kernel read/write flags
`fix_protection` will not apply `B_KERNEL_READ_AREA` and
`B_KERNEL_WRITE_AREA` by default.

Kernel drivers that directly call `create_area` or `create_area_etc`
and do not pass any protection flags have been updated to
apply `B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA` instead.

Bug: #17751
Change-Id: I43e7ee6b5396e0309cdcff750e28262942c6d01c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5330
Reviewed-by: waddlesplash <[email protected]>
2022-05-24 16:37:29 +00:00