Commit Graph

67273 Commits

Author SHA1 Message Date
Augustin Cavalier
c4a59a7a5f file_systems/QueryParser: Don't try to read the key size of invalid indexes.
Fixes a rare corner case.
2024-12-10 16:28:28 -05:00
Augustin Cavalier
f63a4a17ea kernel/fs: Unlock the unused-vnodes lock before continue'ing.
Otherwise we'll unlock in the wrong order and trigger an "interrupts
disabled" assertion in this case.
2024-12-10 13:53:06 -05:00
Augustin Cavalier
81f187cbd9 stdlib.h: Remove *rand48_r methods.
These were declared in this header on BeOS, so we need to keep
them around for ABI compatibility, but they are nonstandard
and no other C library besides glibc appears to provide them
at all (not even musl, and none of the BSDs.)
2024-12-10 13:15:06 -05:00
Augustin Cavalier
7f7ff2884f freebsd_wlan: Enable -fvisibility=hidden.
Reduces the size of WiFi drivers by a bit (and reduces the number
of symbols the kernel has to resolve within the binaries.)

Tested with realtekwifi, still works.
2024-12-10 13:00:49 -05:00
Andrew Lindesay
cb3ddd18bb HaikuDepot: Faster Open State Change
This will signal the package state change to
"pending" more quickly when the package is
being installed.

Change-Id: Ic0bbb0dbbe938f73348cb184aa1c3b83db90acd5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8588
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Andrew Lindesay <apl@lindesay.co.nz>
2024-12-09 09:56:06 +00:00
Augustin Cavalier
4a87c95e0a kernel/fs: Handle O_RDONLY | O_TRUNC in the VFS rather than filesystems.
The POSIX specification says that the behavior of specifying O_TRUNC
with O_RDONLY is "undefined", but the Linux manpages ominously state
"On many systems the file is actually truncated." I tested this,
and indeed on Linux the file is actually truncated.

This doesn't seem like a very sensible behavior, so in this commit
it's changed to return B_NOT_ALLOWED (EPERM) if those flags are
specified together. The FAT driver already did this, but most other
filesystem drivers just checked write access permissions and
truncated the file anyway; so this is indeed a behavioral change.

Change-Id: If2e76782743ee91d934dc7e0c2f306f37b159a0f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8625
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2024-12-09 01:00:33 +00:00
PulkoMandy
5941862c92 Cortex LoggingConsumer: log more details about media buffers
Change-Id: I24d175ae8a414d10fa6c4f49aa2f86ee9b939c4f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8585
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-12-08 09:36:40 +00:00
Autocomitter
8ada0c0e7c Update translations from Pootle 2024-12-07 08:08:39 +00:00
Augustin Cavalier
6690c6cc72 kernel/vm: Don't allow mapping areas larger than the source cache's size.
And also return an error if the offset of an mmap() request isn't
page-aligned, rather than silently aligning it. libroot already
did this for mmap() itself, so this only affects things that invoke
the operation or syscall directly.

Fixes #19155.

Change-Id: I081dd1492d06f56536c1dbb5d4028345f95c4460
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8622
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-06 22:15:03 +00:00
Augustin Cavalier
ae6629023f tests/kernel/vm: Add mmap_invalid_tests.
Move one test from map_cut_tests, otherwise the other tests are new.
Includes a test for the cause of #19155.

Change-Id: I15abbf11f2c6db7385754825abbcc159414f6fd8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8631
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-06 22:15:03 +00:00
Augustin Cavalier
79ebd4147e BList: Slight code and parameter name cleanup.
* Clarify the fResizeThreshold logic and remove the comment.

 * Rename "count" constructor argument to "blockSize", as this is
   what it actually does.

No functional change intended.

Change-Id: I993bf0e695f47da181e9fb50b9a964edfd4a0adc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8629
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-06 19:52:05 +00:00
Andrew Lindesay
ddd374f0fe HaikuDepot: Implement core info model
Breaks out some of the core data about a
package into a sub-model to later support
immutable models.

Change-Id: Ib75ba24c6848829c835199130fe58b0f2d6ebcde
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8587
Reviewed-by: Andrew Lindesay <apl@lindesay.co.nz>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-12-06 08:09:03 +00:00
Augustin Cavalier
edf7c7749c tests/kernel: Move a bunch of VM-related tests to the "vm" subdirectory.
There's still a number of tests in the root that should be moved
to other subdirectories, but this at least gets the VM-related ones
into a subdirectory (and removes a stale entry in the VM Jamfile.)
2024-12-05 23:25:36 -05:00
Augustin Cavalier
6193a477b8 realtekwifi & net80211: Synchronize with FreeBSD.
As of upstream fcb5e8d0c19ac21515ab3047d39a76b32d835cec.
2024-12-05 23:18:45 -05:00
Augustin Cavalier
cd730cbd7c kernel/vm: Drop an actually obsolete comment.
This was introduced in hrev27179 to refer to the member "merge_swap",
which is now gone. The "busy_writing" field isn't used in Merge().
2024-12-05 17:13:26 -05:00
Augustin Cavalier
5cf7633a39 Revert "kernel/vm: Remove an obsolete comment."
This reverts commit 1db0961121.

It turns out the comment is not obsolete; what it refers to isn't
PAE systems but true 32-bit ones. I'm not sure we should use
64-bit cache offsets even there, but that's a decision for another
time.
2024-12-05 17:05:44 -05:00
Augustin Cavalier
319bd18c13 kernel/vm: Use KERNEL_TOP in place of (KERNEL_BASE + (KERNEL_SIZE - 1)).
No functional change.
2024-12-05 17:05:44 -05:00
Niklas Poslovski
5d5dabc2dd Backgrounds: Accept color drop only if color picker is enabled.
Fixes #19264

Change-Id: I90084ae15de4797e6184860af50128ea75dedebc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8656
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
2024-12-05 20:12:35 +00:00
Augustin Cavalier
2d6c8a8481 kernel/vm: Minor coding style cleanups. 2024-12-04 16:43:12 -05:00
Augustin Cavalier
245133b2c1 kernel/vm: Check for overflows in VMUserAddressSpace::CanResizeArea().
It can happen if a very large size is specified.
2024-12-04 16:42:57 -05:00
Augustin Cavalier
6bf630c684 tests/posix: Add symlink_create_test.
Combines the testcases from #19062 and #18355.
2024-12-04 14:09:41 -05:00
Augustin Cavalier
053116301e DebugAnalyzer: Increase the size of the buffer to print pointer values.
We need at least 19 characters on 64-bit architectures:
2 for "0x", 16 for the pointer, and 1 for the \0. So just
use a round 20.

Fixes cut-off pointer values in the display.
2024-12-04 13:38:14 -05:00
Augustin Cavalier
5434ba8dff kernel/debug: Report dummy names for THREAD_BLOCK_TYPE_OTHER_OBJECT.
So that DebugAnalyzer can display them properly.
2024-12-04 13:37:32 -05:00
Augustin Cavalier
149182f6ac kernel/fs: Don't report the leaf node in vnode_path_to_vnode unless it's last.
That is, if we have a path like "/nonexistent-1/nonexistent-2/file",
we shouldn't report "nonexistent-1" as the "leaf" node, but rather
nothing at all. Otherwise, create_vnode() that expects the result to be a
directory vnode plus a nonexistent file will get confused and try
to create a file "/nonexistent-1" rather than just bailing out.

This fixes #19062. The reproducer in that ticket caused a scenario
much like the above; and since rootfs doesn't support regular files,
it returned "EINVAL" when attempting to create the "/nonexistent" file.
After this change, we get ENOENT as expected.

Change-Id: Ifcaaa858403fb747858800afbf644051bb9913ad
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8621
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-04 17:06:59 +00:00
Augustin Cavalier
4c98a54842 kernel/fs: Minor cleanup to vnode_path_to_vnode and related methods.
No functional change intended.

Change-Id: Ie198854ef6bc434db87d362ebc31fd08ab44c176
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8620
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-04 17:06:59 +00:00
Augustin Cavalier
bef7e1c1b1 kernel/device_manager: Adjust assertion in IOBuffer::GetNextVirtualVec.
cookie->mapped_area may be < 0 but not -1 because map_physical_memory_vecs
previously failed.

Fixes #19273.
2024-12-03 15:50:37 -05:00
Augustin Cavalier
23b34b6c0e kernel/fs: Clean up code in synchronous_io.
Minor functional changes: slightly different log message,
error return of GetNextVirtualVec is actually reported properly.
2024-12-03 15:49:53 -05:00
Augustin Cavalier
20f109414c kernel/vm: Write adjacent pages in the page_writer, if possible.
This is an optimization in two ways: first, it allows us to avoid
unlocking the cache or needing the "unreferenced" store-ref acquisition
if we can write the next page in the same cache; and second, the
I/O will be much more tightly combined, as PageWriteTransfer will
be able to merge the iovecs more often and do less I/O (and on
spinning disks, we'll write adjacent regions more often, too.)

Based on some basic logging, this happens very often. I saw adjacent
writes numbers of e.g. 203, 255 (kNumPages), 139, 15, 99, etc. There
were a fair number of 0s, but that case shouldn't add too much overhead
since we bail out very rapidly.

In the case of things like "dd if=/dev/zero of=file ...", this is a
major optimization, since it massively reduces lock contention between
the dd thread and the page_writer thread.

A compile benchmark seems relatively similar, maybe slightly faster.
2024-12-03 13:59:35 -05:00
Augustin Cavalier
487d75717a kernel/disk_device_manager: Invoke base class in KFileDiskDevice::Unset().
Otherwise, the FD won't be closed, and then the underlying vnode
won't ever be released, leading to files whose space can't be reclaimed
without rebooting and running checkfs.
2024-12-03 13:18:07 -05:00
Augustin Cavalier
896f7fdb75 kernel/disk_device_manager: Cleanup code style, fix some minor TODOs. 2024-12-03 12:31:20 -05:00
Jim906
1a98f27639 Tracker: handle case-insensitive move target error
* Do not call entry_cache_add_missing from the FAT driver, because it
  can lead the VFS to believe a filename is missing when it is
  actually present (in a different case).
* Remove CopyFile code that was added to handle a race condition when
  dragging multiple files to a FAT volume.  The race condition only
  occurred in the first place because of the above driver bug.
* Ensure the FAT driver can fail gracefully if dosfs_read_vnode is
  called with an inode number that is not present in the FAT vcache.
  Without any 'missing' entries in the entry cache, there is an
  increased chance that multiple (non-missing) entries representing
  the same file will be added to the entry cache, which can result in
  the VFS calling the FS get_vnode hook on a file after it has been
  unlinked.
* Follows up on https://review.haiku-os.org/c/haiku/+/7623.

Change-Id: I5667119d8149954e0c8a5829617a7d93a6fc7aae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8595
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-03 16:09:11 +00:00
Augustin Cavalier
1fd15efda9 BTimedEventQueue: Use mutex_init to appease GCC2. 2024-12-02 14:06:14 -05:00
Augustin Cavalier
0ffb72029d BTimedEventQueue: Flush events on destruction, other minor cleanup.
* The Be Book specifies that events will be flushed on destruction.
   The previous implementation of this class didn't do that, but
   we ought to. Unless the queued events have attached buffers or
   a cleanup hook, this is a no-op anyway.

 * Use a mutex rather than a BLocker for the allocation lock. This
   saves a semaphore per queue.

 * Put the queue_entry in an anonymous namespace. It shouldn't have
   any global symbols anyway, but it doesn't hurt.
2024-12-02 13:57:03 -05:00
Jérôme Duval
d866277547 virtio_pci: in setup_queue(), only check queue number on v1 devices
* fix #18962
* bus->queue_count wasn't initialized yet so the check could succeed
or not, depending on the init value for memory: on release, 0 mostly,
on nightly, a non-zero value.

Change-Id: Id745932e8171abe3b8b78a3e9b2f2058c9507f7a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8618
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-01 19:32:25 +00:00
Autocomitter
b6190d29d6 Update translations from Pootle 2024-11-30 08:07:48 +00:00
Augustin Cavalier
4055af5143 BTimedEventQueue: Rewrite from scratch, avoiding malloc().
The previous implementation allocated and freed event objects
on every insertion and removal using malloc()/free(). It was also
licensed under a "distributions in binary form must reproduce ...
in the binary" license, which is more restrictive than the MIT license
that we prefer.

So, this is a rewrite from scratch. It uses the standard
DoublyLinkedList<> rather than rolling its own, and manages
a free list of event queue objects rather than hitting malloc()
all the time. It only frees chunks on destruction, though,
but that hopefully won't be an issue anyway.

All tests from the TimedEventQueueTest still pass, and media playback
still works as before.

Change-Id: Ia940b6176f8051ae4823b75acd305ded8783d1e0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8594
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-28 17:48:23 +00:00
Oscar Lesta
2d54103521 mount_server: Tweak the scoring values to avoid (some) false positives.
Before this, having partitions with the same fsName, blocksize, and capacity,
was enough to be considered a match for `initialMountRestore` mode.

That is too prone to false positives.

Now we require those three values, plus either deviceName, or volumeName
(or both) to match, before considering a partition as a valid match for
auto-mounting.

Fixes #19253.

Modifications by waddlesplash: put the score in an enum, and use
bitwise operations in checking the score.

Change-Id: Ifae63cd8e51fe5c8a38130130343a7209bff6d0a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8565
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-26 20:35:36 +00:00
Augustin Cavalier
bb1f240594 file_systems: Invert query equation scoring values.
Previously, lower was better, and higher was worse. But really we want
the scores to be based primarily around the index sizes, which can
grow to be very large, so a maximum score is hard to determine.

Instead, start with the index size, and then divide to make it smaller
based on how "useful" the equation terms will be in searching it.

Improves the performance of queries like those in #19080; according
to humdinger's testing, the query with the most expensive term first
went from ~2.0s execution time down to ~0.7s, same as the query with
the least expensive term first.

Change-Id: Id71fa21c95cfe3d8d0019ff356bdf4935446411f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8593
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-26 17:13:29 +00:00
PulkoMandy
8fbddf13a1 POSIX 2024: add mkostemp
Change-Id: I254b3e5c64f5036e99a94513f05d8c491cbd6273
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8590
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-11-25 22:01:21 +00:00
Augustin Cavalier
4da2ed4103 kernel/vm: Let TRACE_FAULTS enable logging of all faults.
This amends 0f42cf8d7d.

That commit accidentally contained an unrelated patch to the one
described in the commit message, turning a number of prints that
happened unconditionally to ones that happened only for faults
occurring in kernel context. This change re-enables those prints
when TRACE_FAULTS is set (which it isn't by default.)

The original change to reduce prints was done to cut down on syslog spam
from applications like Boehm-GC, the JVM, or emulators that trigger
many (thousands or more) faults on purpose and then catch them in
signal handlers. In the case where these faults are crashes, then
the debug_server will still log those crashes into the syslog anyway.
2024-11-25 14:02:38 -05:00
waddlesplash
e4b10ec126 Revert "ps2_dev: shorter timeout for mouse reset"
This reverts commit 8a00ea4af6.

Reason for revert: #19266.

Change-Id: Ifecd8eac87eb3dd4f5f92a98bf849066db6ba8ed
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8598
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-25 18:55:22 +00:00
Augustin Cavalier
0f42cf8d7d kernel/vm: Handle dynamically-sized commitments properly in copy_area and cut_area.
And handle another corner case in set_memory_protection.

This should fix the remaining causes of #19012.

Change-Id: I92fc184024ffb3923239da5e0bd90efc3085da28
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8589
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-25 18:46:43 +00:00
Augustin Cavalier
3f928f8e10 kernel/vm: Correct address passed to VMCache::LookupPage.
LookupPage() takes an offset in the cache, not a global address.

Helps with #19012, but there are other causes still to be solved.
2024-11-23 13:43:57 -05:00
Autocomitter
f817735275 Update translations from Pootle 2024-11-23 08:09:30 +00:00
Augustin Cavalier
608fd0cdb9 RAMFS: More cleanup of Locker usages in kernel_interface.
No functional change intended.
2024-11-22 23:29:41 -05:00
Augustin Cavalier
ce5375c0bf RAMFS: ramfs_close_attr needs a write-lock. 2024-11-22 21:30:18 -05:00
Augustin Cavalier
bab3f64413 RAMFS: Lock attribute iterators separate from entry iterators.
And clean up the code style while at it.
2024-11-22 20:29:18 -05:00
Augustin Cavalier
e2e7d84d21 RAMFS: Properly check that the Lockers are actually locked.
They pretty much always will be, but better to be safe. Also
de-indent one level and use an early return for this.
2024-11-22 18:07:26 -05:00
Augustin Cavalier
374d7a1eb1 RAMFS: Minor code style cleanups to Volume. 2024-11-22 17:42:00 -05:00
Augustin Cavalier
fe0e833f1f fat, exfat: Add acquire_vnode/put_vnode calls in the I/O hooks.
Same as was done in BFS.
2024-11-22 16:57:27 -05:00