Commit Graph
67921 Commits
Author SHA1 Message Date
Jim906 d0b07ec244 nfs4: Disable file cache to invalidate it
* When resetting the file cache, use file_cache_disable() to remove
  all pages, instead of calling file_cache_delete().
* Possible fix for #19656.

file_cache_delete doesn't actually delete the VMCache object, so when
file_cache_create() is called the returned file_cache_ref just points
to the same VMCache as before.

Change-Id: Ifba42b51c52f11980fd97212d0c3bdfdc1e55085
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9448
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2025-07-09 17:57:29 +00:00
Augustin Cavalier ceec330bbb kernel/vm: Numerous fixes to area cutting and commitment logic.
* Split the "is only cache user" logic from cut_area into
   a helper routine.

 * If we can't modify a cache in cut_area, then we can't modify
   its commitment either, so add that to the check.

 * If we didn't split the areas, then modifying the commitments
   doesn't make sense and will cause problems, so move that logic
   into the "modify cache" branch.

 * Use the new helper routine in set_memory_protection rather than
   checking only cache->temporary.

Combined with the previous commit, seems to fix #19624.
2025-07-07 17:20:34 -04:00
Augustin Cavalier 92f73a4e2c RAMFS: Use cache types of 0 (invalid) rather than "RAM".
Otherwise, various parts of the VM think it's safe to modify
such caches and/or their commitments in ways that it's not.
2025-07-07 17:08:37 -04:00
Augustin Cavalier 687e76e3f9 kernel/vm: Make the first CACHE_TYPE be 1 instead of 0.
We store this value in a bitfield, so we can't use -1 to mean
invalid/unknown. Move the first value up so that 0 can be used
for that instead.
2025-07-07 17:05:11 -04:00
Augustin Cavalier 34e38174eb RAMFS: Use the new check_write_stat_permissions. 2025-07-07 15:19:11 -04:00
Augustin Cavalier 15b255904d BFS & EXTFS: Use the new check_write_stat_permissions in write_stat hooks. 2025-07-07 15:11:21 -04:00
Augustin Cavalier 9ea1065b16 kernel/fs: Introduce check_write_stat_permissions utility method.
Like check_access_permissions() but for write_stat() hook instead
of access().

Basic logic copied from BFS, but with the UID/GID logic rewritten
to better conform to behavior on other OSes: notably, we allow
chown() requests that keep the UID the same to go through, same
as Linux seems to, which should fix #19666. We now also validate
that the GID is one of the current team's groups.
2025-07-07 15:10:01 -04:00
Augustin Cavalier 7ed202f9ed kernel: Add is_in_group(Team*) private utility method and use it in the VFS.
Slightly more efficient than using getegid() and getgroups().

While at it, make the user-group utility methods C++-only.
2025-07-07 15:02:17 -04:00
Pascal Abresch 8e086795b2 implement fdatasync
Change-Id: I2aefc1acebce93a2c53a6d3be5eef3b9e69480ec
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8507
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: nephele nephele <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2025-07-07 15:20:18 +00:00
Jim906 258fce50e0 nfs4: Check for stale nodes when reload dir cache
* When the DirectoryCache is updated, compare the new contents with
  the old.  If any of the old entries are obsolete, treat the
  respective node as stale.
* Create FileSystem::TrashStaleNode() to avoid duplicating code.
* Possible fix for #19656.

This helps the client keep current with changes made to server files
by other users.

While the comparison will be slow for a large directory, it won't be
executed unless another user has changed the contents of a directory
since the last time the Haiku client read the directory.

Change-Id: I03e65aaaad5027c66b10265f2b4a21ed9d2b6744
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9445
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2025-07-07 15:16:10 +00:00
Augustin Cavalier d9048aa4fc libroot/malloc: Increase address space reservation to 1GB.
Similar to the debug malloc and the old hoard2.

May help with #19592 a bit more.
2025-07-02 17:41:23 -04:00
Augustin Cavalier e6de99eb01 multiuser: Change all groups in setup_environment.
We need to change all groups, not just the primary group.
Otherwise, other groups will be left intact, which may
include groups the new user doesn't have permissions for.
2025-07-02 17:20:01 -04:00
Augustin Cavalier 27e99e3a64 su: Don't ask root for passwords.
root can su to any user without needing any password.
Same behavior as passwd for changing passwords.
2025-07-02 17:20:01 -04:00
John Scipione b58c23c7c6 Menu docs: fix typo
Change-Id: Icc789b5d2652dca3a64c3bbc5572821747efa75d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9438
Reviewed-by: waddlesplash <[email protected]>
2025-07-02 19:12:03 +00:00
Augustin Cavalier 987a07492e BMenu: Automatically invoke _Install and _Uninstall in Attached/Detached.
This way, we can't inadvertently end up in a state where the
window is deleted but some things are still attached to it.

Fixes #19662.

Change-Id: I3ce7b5ccffc8cf12670209f3023613b32e31c41c

Reviewed-on: https://review.haiku-os.org/c/haiku/+/9437
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: John Scipione <[email protected]>
2025-07-02 18:39:25 +00:00
Máximo Castañeda 45f3d65457 Storage Kit: do what the method says in InstalledTypes::_AddSupertype
That is, just add the supertype if it does not exist. Leave getting it
to the callers that need it.

Fixes: #19653
Change-Id: I79d804161d28684e16a0d84ec3a2fb6788c0b506
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9436
Reviewed-by: waddlesplash <[email protected]>
2025-07-01 18:07:08 +00:00
Augustin Cavalier 8f149016fb kernel/arch: Put KERNEL_USER_DATA_BASE at USER_STACK_REGION.
x86_64 already does this and it seems to work fine. Since stack areas
grow downwards and should always have a guard page, overruns shouldn't
be too much of a concern (for that matter, randomization still makes
a difference here also, it seems.)

This allows us to regain another ~256 MB or so of contiguous address
space (areas smaller than that could still be inserted in the 0x6.. to
0x7.. block, but if you had 10MB of free address space below 0x6..,
and 246MB above it, you couldn't allocate a 256MB block.)

Part of #19592.
2025-07-01 00:26:29 -04:00
Augustin Cavalier e16d28419f kernel/vm: Ignore insertion hints when the address space is over half full.
We ideally want to avoid further fragmentation and just insert in the
smallest possible slot in that case.

Part of #19592. With DISABLE_ASLR=1, seems to save about 120 MB or so
of address space, which is a lot on 32-bit.
2025-07-01 00:22:32 -04:00
Augustin Cavalier da5a0edd02 kernel/vm: Adjust next-insert hint on area removal.
This doesn't matter so much because the hint's used for
an AVL tree lookup both for next and previous, but it
probably does at least a bit because the new area's size
is used in the tree lookups.
2025-07-01 00:19:50 -04:00
Augustin Cavalier be1a714a52 libroot/malloc: Increase address space reservation size to 512 MB.
The kernel will ignore the reservations if there's not enough space
left in the address space anyway.

It seems using larger reservations prevents address space fragmentation,
and so this by itself may be enough to fix #19592.
2025-07-01 00:18:32 -04:00
Augustin Cavalier df18fd7ab6 libroot/malloc: Add a free maximum to PagesAllocator.
128 MB should be more than enough memory in the global cache
for most applications (this limit's hit once the application
has 512 MB of live allocations, based on the current free
percentage of 25%.)
2025-07-01 00:17:35 -04:00
Augustin Cavalier c582c91f05 iprowifi3945: Add missing if_free_inplace.
Fixes the new KDL in #14265.
2025-06-30 21:30:12 -04:00
Augustin Cavalier 944c5ed17d NFS4: Handle B_MOUNT_READ_ONLY.
Should fix #19658.
2025-06-30 15:43:27 -04:00
Augustin Cavalier 9b0788bdc8 kernel/file_cache: Invoke VMCache::ReleaseStoreRef without a lock held.
Otherwise we might get lock-order inversion in the VFS (see comment in
VMCache::RemoveArea) and deadlock the system, which indeed I observed
while testing some things today.
2025-06-30 15:06:45 -04:00
Augustin Cavalier 7415ce0639 kernel/slab: Fix potential memory leak in HashedObjectCache.
If the resize-needed amount changed while we were allocating memory,
then we'd leak the new buffer.

In testing, I added an ASSERT() to check if this case actually happened,
and it didn't seem to fire when using the system (with a debug kernel
though, admittedly.)

Inspired by a change suggested on GitHub, but implemented in a
completely different way (that cleans up the code at the same time.)
2025-06-30 15:02:05 -04:00
John Scipione e362f604f4 Revert Interface Kit: BWindow owns (and deletes) menu sem and friends
This reverts commits:
39083dd0f7
0f430ba35c
ac55439364

Fixes #19553

Change-Id: I40f9a694079d4376221099e1d1b99208aeb207b7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9416
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-06-30 17:43:51 +00:00
John Scipione b515400884 BButton: Document AdoptSystemColors() and HasSystemColors() in the Haiku Book.
Change-Id: Ibe72cc796738e90beee9388eaba95342ab48640d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8898
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-06-30 14:57:07 +00:00
John Scipione 15c87be3ea ColorListView: Handle color dropped on unselected
Remove shared message handling from ColorListView,
you are expected to implement this yourself and these
message constants were not actually being used by
the message target.

Do color drop handling in Appearance and Terminal.
Handle all color drops in WasDropped().

Allow current selection to remain, only update color.
TODO Changing selection on external drops should be
fixed in BListView. Work-around in BColorListView.

Fixes #19562

Change-Id: Ic99bbb1288fd736778eac831d38e453122815abc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9296
Reviewed-by: John Scipione <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2025-06-30 14:56:42 +00:00
John Scipione 0d91cd6464 Tracker: Add Paste item to volume window context menu
Change-Id: Iaa8b992011510364cf1eb9a3f0e6a6e749eefe5f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8955
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: John Scipione <[email protected]>
2025-06-30 14:55:52 +00:00
John Scipione 76f3ceaadc Deskbar: Reduce window height by 1 in mini-mode
Adjust tray icons and clock to fit accordingly. Leaf menu height is
reduced by 1 in vertical mode to match.

This makes the overlap of maximized windows and Deskbar less noticeable,
especially in horizontal mini-mode.

Fixes #16231

Change-Id: I622d008ee093e018ebcb46e3c45647577f46184f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8833
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: John Scipione <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
2025-06-30 14:54:49 +00:00
Augustin Cavalier 83aa27ada6 netinet/in.h: Add IP_DONTFRAG socket option, and implement for IPv4.
To allow consumers to cause the "don't fragment" bit to be set in
all IPv4 packet headers.

There is no standard way of doing this, and different OSes expose
this option in different ways. Linux has "IP_MTU_DISCOVER", but it
takes an enum, not a boolean. NetBSD and OpenBSD appear to have
no socket option, instead they have "IP_MTUDISC", an option for
the "ip_output()" kernel-level network stack method.

"IP_DONTFRAG" sockopt originates on FreeBSD, and it seems macOS now
also supports it in version 11+. Windows has "IP_DONTFRAGMENT",
which, at a glance, appears to do the same thing. So this looks
like the one that makes the most sense to adopt.

This doesn't add any code to process MTU changes yet, though.

Change-Id: I492d22dbd0ee5f4ab35c600396ad3d3ec9f4f200
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9401
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2025-06-28 17:22:47 +00:00
Augustin Cavalier d31febdefa ICMP: Pass FRAGMENTATION_NEEDED and REDIRECT info up the stack.
Using the new net_error_data parameter to error_received.
Move the "update routing table" TODO into the IPv4 module,
since the ICMP module doesn't deal with the routing table
at all, while the IPv4 module already does.

Also add a missing endian swap in ICMP error_reply.

Change-Id: I1135eaa442f515d656143c76ab130be19cdcbaf2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9400
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-06-28 17:22:47 +00:00
Augustin Cavalier f9a86ebeab network: Add net_error_data parameter to error_received.
Same structure as used for error_reply, to contain information
(like path MTU or redirect gateway) from the original error packet,
so that upper layers don't have to re-parse it.

Nothing uses or passes it around at present, but it will be used
in the next commits.

Change-Id: I38a3dec5506bdcb77a7850294082db7be74dd80f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9399
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2025-06-28 17:22:47 +00:00
Augustin Cavalier 4cf1bb8619 netinet/in.h: Cleanup.
* POSIX also specifies in6 availability in in.h, not just RFCs.

 * Drop IPPORT_USERRESERVED. It's in RFC 1700, but FreeBSD and musl
   do not define it, and OpenBSD and NetBSD disagree on its value
   (the RFC says 5000, while OpenBSD used this "49151" starting
   in 1998.)

 * Organize the remainder with clear indications of what RFC defined them
   (if indeed they were specified in an RFC.)

 * Drop "helpful macros"; they're guarded by _KERNEL on OpenBSD.

Change-Id: Ia20be56398130ee22d70b38ee25a3f609b567c3b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9398
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2025-06-28 17:22:47 +00:00
Augustin Cavalier eb8651d492 IPv4: IP_HDRINCL may need a checksum.
IP_HDRINCL isn't POSIX. The FreeBSD manual page for it doesn't specify,
but the Linux manual page indicates it will compute the checksum.
traceroute seems to depend on it doing so.

Significantly improves the situation in #3210.
2025-06-26 11:46:43 -04:00
Jérôme Duval 334de37d58 udp: empty address is different from uninitialized address
* instead teach getpeername that family is to be checked.
* fix #19652

Change-Id: I0e2150820687ca08e339adaf111918adc83b9e6b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9397
Reviewed-by: waddlesplash <[email protected]>
2025-06-26 15:09:13 +00:00
Jim906 3738985e2c fat: Fix error handling in buffer IO functions
* Have bread() output a NULL *bpp when returning an error (consistent
  with FreeBSD).

* Enable brelse() to handle a NULL argument (consistent with FreeBSD).

* Ensure that when getblkx() returns an error, no clean-up remains to
  be done by bread() or getblk().

* Let allocate_data() set buf::b_owned, and set it only if successful
  in allocating, so the flag won't be misleading to put_buf() after a
  failure.

* Revise vput() to avoid situations when, after an error, it might
  call put_vnode() before the node is published to the VFS.

Change-Id: I42cc1684fe5b68333284b149e72a794c93ac71ff
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9393
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-06-26 14:44:39 +00:00
Jérôme Duval 2b9fdf7847 ipv4: empty address should be a zero sa_len
UdpDomainSupport::ConnectEndpoint() uses SetToEmpty() to unconnect when used
with AF_UNSPEC.
checked against the output of the test sortix/os-test/udp/connect-unconnect-getpeername
Change-Id: Iccfa46399a0e14057459966a2f406469566bcbac
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9396
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2025-06-26 05:43:59 +00:00
Jérôme Duval 48e3aa8081 kernel/socket: allow sendto to an empty address
should return EDESTADDRREQ for UDP
checked against the output of the test sortix/os-test/udp/sendto-null

Change-Id: I3bc61e0cc9d75319d61f0395f1ae45d28171bfef
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9395
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-06-26 05:43:59 +00:00
Jérôme Duval 74be257edf udp: send should return the error on the last send packet
checked against the output of the test sortix/os-test/udp/connect-send-error-send
* icmp: add more error codes

Change-Id: I7b1695d37cf5eae8cd09132047404b990f8791dd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9394
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-06-26 05:43:59 +00:00
scphandAugustin Cavalier f8e01ad15c app_server: Render cursors from vector icons based on the font size.
* Cursor bitmaps are now generated at runtime from vectors
   embedded in CursorData.cpp (replacing the old bitmaps).
   There is still a fallback bitmap pointer in case generation fails.
   All cursors should scale correctly, and hotspots are accounted for.

 * The Pointer vector in data/artwork/cursors was very slightly tweaked
   to look better at larger sizes - the white edge at the bottom was made
   rounder.

 * The new dynamically-generated cursor looks close to the old one,
   unless you're zoomed in and comparing them pixel-by-pixel.

 * The cursor shadow is generated with a gaussian blur to create a
   similar look to the old shadow, which was created in an image editor.

Fixes #13171.

Co-authored-by: Augustin Cavalier <[email protected]>
Change-Id: Ifa881619354a42bc60d2b5c1d0443e8addf6e0f5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5200
Reviewed-by: nephele nephele <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-06-26 01:19:41 +00:00
Jérôme Duval f2a0f2a3e0 udp: implement shutdown()
instead of returning B_NOT_SUPPORTED.
* this fixes a few tests of sortix/os-test/udp.

Change-Id: I961e71cc419ce7ab38419749a42df8737e272c83
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9392
Reviewed-by: waddlesplash <[email protected]>
2025-06-25 13:24:25 +00:00
Augustin Cavalier 8e86be8509 libbe_build: Synchronize BBitmap implementation with the main one.
BView-related code removed or disabled, of course, but this now uses
the ColorConversions class, and adds some more ImportBits APIs from that.

Change-Id: I805cef159bac52173ef16030eae69e83db6f061b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9391
Reviewed-by: waddlesplash <[email protected]>
2025-06-24 22:47:45 +00:00
Augustin Cavalier 1ad882a7ec BToolBar: Use MENU_BACKGROUND color, and leave buttons with default.
Toolbars go with menu bars, and so to blend in better with them,
should use the same colors. (Under the default color schemes,
the menu bar and panel colors are the same, so this makes no
visible difference there.)

Added a TODO for button colors as we may want to do something different
for that, it also makes no difference with the default scheme, but
for non-default schemes may matter.

Improves #19629.
2025-06-24 14:48:30 -04:00
Niklas Poslovski 92261f367f Printers: Make icons scale for HiDPI
Fixes #17985

Change-Id: I867bb9c95f6421bf056845a2686789341c8aa7d5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9376
Reviewed-by: waddlesplash <[email protected]>
2025-06-24 18:41:40 +00:00
Jérôme Duval 3aaa4c9d96 udp: a second bind on broadcast address should error with EADDRNOTAVAIL
Testcase: https://gitlab.com/sortix/os-test/-/blob/master/udp/bind-conflict-loopback-broadcast.c

Change-Id: I37c6d05910c3d9573610207b650f1957bccd1e47
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9390
Reviewed-by: waddlesplash <[email protected]>
2025-06-24 17:33:06 +00:00
Jérôme Duval 090519cfe5 network/stack: socket_accept: return B_NOT_SUPPORTED for non-stream sockets
Testcase: https://gitlab.com/sortix/os-test/-/blob/master/udp/accept.c

Change-Id: I9020292facb47339ede31a8d1c49d197e40d6ca9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9389
Reviewed-by: waddlesplash <[email protected]>
2025-06-24 17:33:06 +00:00
PawanYr 1e4ba4883f App Server: Don't set workspace in Desktop::MoveWindowBy
This fixes a bug that's been annoying me - when I use Workspaces to
move a terminal that's scrolling/moving on another workspace, the
terminal begins drawing into the current workspace; this also happens with
some other apps, like Qemu. I tracked this down to Desktop::MoveWindowBy,
where we update an invisible window's current workspace to the one it's
being moved on. Trouble is, the current workspace is set to -1 for windows
on another workspace, and IsVisible just returns whether the current
workspace is >=0, so doing this causes IsVisible to return true when it
shouldn't.

This patch replaces that call with one that sets a separate
invisible workspace member variable, which preserves all window moving
functionality without improperly setting a window as visible. It also fixes a
minor graphical glitch when moving off-workspace tiled windows.

Fixes #6722

Change-Id: I2c4f04602caed85bf08391d0ea99e4dc74c1e1d8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9256
Reviewed-by: waddlesplash <[email protected]>
2025-06-23 19:58:39 +00:00
nipos 349b6d2d2a Expander: Improve HiDPI scaling and avoid cutting off the window
Fixes #17905

Change-Id: Ia6790a2ebe5e6cdfdc88365f39c46ad9412541ee
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9388
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2025-06-23 19:52:23 +00:00
Augustin Cavalier 5cfaa09f1f iprowifi3945: Replace with the OpenBSD driver.
According to the comments on #19588, this seems to be more reliable than
the driver variants from FreeBSD or elsewhere.

Change-Id: Icdc24683de3f588f51c4c08529aa6cab3a09c7fd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9311
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-06-23 19:50:07 +00:00