We were storing real_time_clock_usecs() but comparing against
BStatable::GetModificationTime() which is just a time_t. The
values were thus displayed wrongly in the "Get Info" window,
but also thumbnails would not have been updated when the file was.
Should fix#18691 and possibly some other tickets.
* Rename the "tun" network device to "tunnel". FreeBSD calls theirs
"tuntap" but speaks of both TUN and TAP devices as interfaces for
tunnels. The other BSDs seem to do likewise.
* Fold the "tun" driver into the "tunnel" network device. The
network device now publishes entries in devfs when interfaces
are created, and unpublishes them when interfaces are destroyed.
This removes the need for the driver and device to communicate
through a file descriptor, and thus allows the receive queue
to be totally eliminated, massively simplifying that logic.
* Use standard net-stack FIFOs instead of TCP BufferQueue, which is
specialized to TCP's needs in far too many ways. Thanks to the
previous commit adding support for interrupting semaphore waits,
we can use the FIFO wait mechanisms, too.
* Restructure the TAP logic, and generate MAC addresses more like
Linux does.
* Actually set type = IFT_TUN, and use the "loopback" frame handler
instead of the "ethernet" frame handler. This allows significant
cleanup of the header handling logic.
* In TUN mode, reject packets that don't look like IP packets.
* Delete "tunconfig"; it was mostly stubs and is now unnecessary.
TUN mode tested and confirmed as working by kallisti5 with OpenVPN.
TAP mode partially tested, but not yet confirmed as working.
Fixes#18673.
Change-Id: Ibd803139474e8db556a4f567901da15ee4083621
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7143
Reviewed-by: Alex von Gluck IV <[email protected]>
Previously, "count" did nothing for B_RELEASE_ALL. Now, if it is
< 0, it will be the error code returned by acquire_sem() of any
waiting threads.
As B_RELEASE_ALL is a Haiku extension, this change should not
cause any compatibility problems that we cannot fix.
This will be useful in implementing some features of TUN/TAP
with network FIFOs.
Change-Id: I2dbccedefac2024fe740b87543ff3b80f5257e20
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7163
Reviewed-by: waddlesplash <[email protected]>
* Reshuffle variable declarations, most are placed much
closer to first usages now.
* Turn a confusingly worded comment into an ASSERT(),
and remove another one that was outdated.
* Fix some minor code style problems.
* Make the copying logic more consistent between first
and then subsequent copies.
* Make it possible for B_BAD_ADDRESS (EFAULT) to be
returned. This is not listed in POSIX, but as per
online sources, at least Linux does do this.
Change-Id: Idcfbed30531c1ab4796c4ee37f7f4ce8078e535b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7147
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This is a Linux extension (which at least FreeBSD has also
adopted.) It's used in the Haiku port of libpcap (where it's
a necessity) and wpa_supplicant (where it wasn't, and I
removed it.) It seems that we've had it for quite some time.
Fixes tcpdump following addition of flag checks.
GCC2 tolerates [] FLAs in C++ mode but not in C mode, as discovered
when trying to build wpa_supplicant against R1/beta4. A workaround
was added there for now, but this is the more general solution.
These have not been used in years (maybe since the redesign of the
network stack?). Only socket_writev had an implementation, which was
mostly just an incomplete version of socket_send.
Scatter/gather I/O is already supported via msghdr's msg_iov/len fields,
so this is redundant anyway.
Change-Id: If41c4f4ee021856f6db49c7cb95422a9c1aa7700
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7127
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
They only described things that the function names and parameters
already indicated. As per the Coding Guidelines, such excessive
commenting is to be removed.
Also fix some other (minor) code style issues while at it.
"LGTM" code scanning was bought out and merged into GitHub Actions.
The code scanning setup there has a different mechanism for configuration,
and so this file is not useful anymore.
The filesystem name returned by read_fs_info will be correct (i.e.
returning "ext3" or "ext4" as appropriate), but some things just list
the filesystem driver's name, which can cause confusion.
Change-Id: Ic4acf497fc5db5c167131aeb323b45eeb78594d6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7126
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
This removes the burden of determining whether to and then
actually sending SIGPIPE from the protocol modules, meaning
the MSG_NOSIGNAL flag can now be implemented entirely in
the socket module and not even passed further down the chain.
Change-Id: I9ba976c4aff60d533cb4b390bbba1560c0de423f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7124
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Fixes WebKitGTK spinning endlessly and spawning lots of
short-lived worker processes following the addition of
flag checks and EOPNOTSUPP to the various socket modules.
Change-Id: I6d944b4d0235eea9e8a9333645fcb531805f340f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7123
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Its declarations were moved from another header to this file
in 2008, with a comment in the commit message and a TODO here
questioning whether it was needed for anything. In the 15 years
since then, nothing has used it.
Waiting for state changes correctly checked MSG_DONTWAIT,
but the overall data timeout only did in ReadData, not
SendData. This corrects that and makes the implementation
more consistent overall.
Same logic as in the TCP protocol module.
This fixes a regression from hrev57383: curl now works
again. (Perhaps it shouldn't be called a "regression",
though, but instead an uncovered bug / missing feature.)
Fixes#18666.
The debug_server sends MSG_DEBUG_THIS_TEAM but of course it doesn't
have a way to specify the internal interface pointer. We should thus
assume the local one is implied.
Fixes#18645, which is not a regression but has been the case since
the initial host-interface refactors years ago, apparently.
Change-Id: I48078232f154f2f8f7cdf28792d39ae58471ce19
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7074
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
* Declare databridge buffer lengths in LocaleBackend.
* Use strcpy instead of strlcpy when writing to databridge buffers
(this is the first fix for #18598.)
* Check for overflows and error out when they happen.
* Verify that ICU actually knows the timezone in question
and fall back to GMT if it does not (this would also fix that crash.)
Fixes#18598.
While debugging some problems on the HaikuPorts build VMs, mmlr
noticed their clocks had an alarming amount of drift. This prompted
an investigation into TSC calibration mechanisms, and the discovery
that there is a VM-specific one which we did not implement.
This mechanism is more accurate than counting cycles on VMs where
cycles can be "stolen" (the probable cause of the aforementioned
clock drift.)
Tested in VMware (works out of the box) and on QEMU/KVM
(may need TSC frequency specified or a host with invariant TSC.)
Change-Id: I4ccfdb2e4e2621404ec9026e7106c02bf96faf18
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7063
Reviewed-by: waddlesplash <[email protected]>
The previous code did not work on non-English locales,
a problem readily detectable when running in Terminal
inside a Terminal session, e.g.:
PrefHandler::getRGB(Hintergrund) - key not found
Fixes#18614.
There are now some system headers (e.g. <stdatomic.h>) that have outright
different versions for C and C++ which are not compatible with each other.
Change-Id: Ibf797e0817f0fe4d5241424d7d06023b19888c02
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6991
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This undoes fc7864091e.
It was only ever used by the FreeBSD compatibility layer,
only supported one structure, and created problems with
concurrent builds.
Use sizeof()+roundup() to build a char[] of the correct size,
and add a static_assert to ensure it stays so.
The <kernel_c++_structs.h> header needs to have its dependency
manually declared, and not all consumers of this file properly
declared it as such. This then fixes a concurrent build problem.
Fixes#17965 as this was the only consumer of this header.
The comment above this block specified the correct behavior: the
button's status is already updated elsewhere, so just check IsEnabled().
But the code did not actually do that.
It appears this has been incorrect all the way back to the initial
OpenTracker import in 2001.
Fixes#13721.
In hrev51155, it was changed to be always enabled no matter what,
so that the current directory (without anything selected) could be opened.
But this means it would also be enabled for files, which is misleading.
Instead, remove the function, and adjust the logic detecting whether
to enable the button or not to take B_DIRECTORY_NODE into account.
CVS revision(s) are in first-line comments.
Requires a new firmware package (from HaikuPorts). There are some
changes in here which may fix some of the odder issues, like failures
to connect to access points. There is also support for one new PCI ID.
Tested by PulkoMandy who reports it's still working.
* Replace count_low/count_high with bigtime_t fields plus an int32.
sizeof(spinlock) is now 32 bytes with the debug option enabled.
* Adjust and clean up all spinlock code to use the new fields.
* Fold DEBUG_SPINLOCK_LATENCIES into the new code. Remove the bootloader
option and other flags for it (these were not compiled in by default.)
The new code should be much easier to understand and also more powerful.
However, the information transmitted to userland isn't as useful now;
the KDL command output will have the interesting information.
(Things could be reworked to transmit more interesting information to
userland again if desired, but as this code clearly hadn't been compiled
for many years, as it referred to global spinlocks that have been gone
for a very long time.)
Change-Id: I2cb34078bfdc7604f288a297b6cd1aa7ff9cc512
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6943
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Only the x86 and PPC implementations look like they would have worked,
while the builtin is available and will work across all architectures.
We already use it unconditionally in some parts of libroot.
Change-Id: I2dffb3b2c7cdd605092382b9d649151adb921bb4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6942
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This is the loop that runs on all CPUs besides the one
actually running the kernel debugger. It's functionally
a spin-loop around a few different variables, and so it
should be safe to use cpu_pause() here, just as real
spinlocks do.
(cpu_pause() just runs a "pause" or equivalent instruction,
it doesn't use the CPU-idle modules, which indeed may be
unsafe to use in KDL.)
A glance at FreeBSD seems to indicate they also do this
when their kernel debugger is active.
Seriously improves power consumption while KDL is active:
even running in a VM with only a few cores, there would be
obvious fan spin-up when entering KDL. After this change,
there's barely any at all (while overall CPU usage % remains
basically identical.)
I looked at this code as a reference when writing similar code in another
project, and realized then that this was broken to the point where I
don't think anyone could have actually used it:
1. Writes larger than the buffer should only return the amount written
by this Write() call, not the amount flushed beforehand.
2. fDirty was only set if there were bytes remaining after the first
write to the buffer. So, if you wrote small amounts of data, they
would be silently discarded most of the time!
3. When filling the buffer, we might as well flush simultaneously.
This allows the logic to be consolidated into a loop and remove the
duplicate memcpy. In case of failure, just return the bytes-written
as the write could be retried later.
4. Flush() should always return an error or 0, not bytes written.
While at it, add some basic tests for this class.
Change-Id: I2de01d0b31e3fe22863cef21dd7b0b62ed47121b
* Remove unused/unneeded parameters to Dequeue.
* Make use of StackOrHeapArray.
* Reorder syscall-entry checks for efficiency.
* Inline the unlock-block method and unset variables in the process.
* Reorder code for clarity and to reduce indentation.
When breaking out of _RemovePackageContentRootNode() by encountering
a specified "endPackageNode", we need to unlock all directories.
This case is only possible to encounter when _AddPackageContentRootNode()
fails partway and invokes _Remove() to remove the just-added nodes.
Fixes a hang/deadlock encountered by Diver while testing some (disabled)
HaikuPorts recipes.
Some of the Haiku-specific modifications that were previously unmarked
are now clearly marked with #ifdef __HAIKU__.
BIND9-specific files containing private APIs never exposed in public
headers have been removed.
Tested with wget, curl, pkgman (Network Kit), WebPositive (WebKit/curl),
and Falkon (QtWebEngine/Chromium). All DNS-related operations seem
to still work just fine.
(One patch also imported from NetBSD trunk for GCC 12+ compatibility.)
Change-Id: I4a349577b24b4df008fd9cba5d3a322cd24397f1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6879
Reviewed-by: waddlesplash <[email protected]>
This has not been included in the build for years, probably since the
initial NetResolv merge. Services are now returned via the "protocols"
file, and getservent() has no need for these utility functions.
Change-Id: If18bdd9593463b38a9aaedb7a621d0ddc15530e4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6878
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
There was a TODO comment about this, which dated all the way back
to the original OpenTracker import over 20 years ago.
There's still more cleanup needed, so I left another TODO.
* We can return early from duplocale() so set the "magic" flag early.
* Initialize all fields up front.
* Add an internal method __posix_locale_t() which returns a locale_t
usable as a global C/POSIX locale type, and add the appropriate
definition to the musl internal header.
Our features.h does not define __USE_GNU, and so applications trying
to use this GNU-ism would have to define it for themselves, even if
_GNU_SOURCE had already been specified.
BSlowContextPopup was mostly a duplicate class of BNavMenu
only on top of BPopUpMenu instead of BMenu. Now, BPopUpNavMenu
just subclasses BNavMenu and adds the few features of BPopUpMenu
neccessary.
Drag-and-drop of files using the pop-up nav menu seems to still work fine.
Change-Id: Ic1f49c5bed60fff7a3076a22f74aebc6eba51d57
The original change to fix ramfs appearance (hrev56642)
in Tracker and elsewhere said the reason for adding the
FS_IS_REMOVABLE flag instead of removing FS_IS_PERSISTENT
was because of problems encountered with writing/deleting
entries on ramfs mounts.
I was unable to reproduce those problems; writing and
deleting entries on RAMFS mounts still works just fine
in Tracker and elsewhere, even after removing the flag.
So it seems safe to remove; subsequent problems can be
addressed as they come up.
Fixes#18173.
The common version was also derived from BFS' original implementation,
but was genericized during packagefs development, and has more recent
fixes and additions.
Only lightly tested, but arbitrary-attribute-indexed queries seem to be
working just fine.
This data comes from the PNP registry, where deprecated entries
have "DO NOT USE". But those deprecated entries were often once used
in actual products, and we don't want to display "DO NOT USE" for them.
So remove such text, and replace it with the actual vendor name in a few places.
The per-heap locks are reinitialized already by the routine which
invokes this one, but this global lock was previously missed.
May fix a deadlock reported by trungnt2910 to happen in the .NET port.
* If we received a wait status, always return with it.
* Only count those entries for which we set the wait-status as
having been notified.
In conjunction with the prior commit, this fixes some rare deadlocks
that could occur with timeouts or signals.
It turns out this code actually is possible to trigger, e.g. using
Git checkouts, where EINTR due to signals happens quite often.
However, even with this commit, it still does not work quite right,
due to an oversight in condition-variable notify accounting. That
will be addressed in the next commit.
Once B_EVENT_INVALID has been set, the select routine is free to
delete the select_info at any time. We therefore cannot access
the "next" pointer after notify_select_events returns.
May fix a KDL seen by trungnt2910.
The dequeue routine expects that if B_EVENT_INVALID is set,
it is free to delete the object. So we must only set it with
the lock held, so that by the time the dequeue routine sees it,
we will be done with the event.
1. Set fShutdownRead & fShutdownWrite. This is necessary
because in Send(), there is a lock-unlock dance between the
source and target sockets which could potentially race with
some other thread closing the socket. The "shutdown" state
is checked before actually writing, and so we need to set it
here. Otherwise, the other thread could allocate a new receive
FIFO for us, which we do not want.
2. Don't return early when unbinding, but only if there's an
error (there shouldn't be.)
3. Merely ASSERT() in Free() that closing was already done
and nothing remains to be deallocated.
Should fix#18535.
unix_dgram_test still passes.
When the select/deselect API consumers invoke deselect(), they
expect that when this function returns, no further references to
the select_infos will remain and they can be safely deleted.
In order for that to be true, we cannot remove the select_infos from
the list in one step and deselect them in another; we must do both
without releasing the lock in the middle.
Should hopefully fix a rare KDL seen while testing .NET and
the new event_queue.
* Check fFirst/fLast instead of previous/next. Avoids
list corruption when trying to remove already-removed
elements, instead will cause null-dereference KDL.
* Always set next/previous to NULL even when DEBUG is not
enabled.
Notable changes include:
* fts: Stat things relative to the directory fd, if possible.
* fts: Fix double-free with conflicting concurrent modifications.
* fts: Don't abort if an empty pathname is given.
* fts: Don't return FTS_SLNONE if it's not a symlink (if race).
* fts_children: preserve errno after running close/fchdir
* Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.
* fts: Fix a potential memory leak in error case
* libc: Check for readdir(2) errors in fts(3)
It only supports file descriptors and processes (threads),
and a few flags (not all) to go with them.
This has been tested extensively against libuv.
Change-Id: I6fc5930fa7273698172c9c695965842b5df44f03
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6746
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Based on hamishm's original patch from 2015, but heavily modified,
refactored, and reworked.
From the original commit message:
> When an object is deleted, a B_EVENT_INVALID event is delivered,
> and the object is unregistered from the queue.
>
> The special event flag B_EVENT_ONE_SHOT can be passed in when adding
> an object so that the object is automatically unregistered when an
> event is delivered.
Modifications to the original change include:
* Removed the public interface (syscalls remain private for the moment)
* Event list queueing/dequeueing almost entirely rewritten, including:
- Clear events field when dequeueing.
- Have B_EVENT_QUEUED actually indicate whether the event has been
appended to the linked list (or not), based around lock state.
The previous logic was prone to races and double-insertions.
- "Modify" is now just "Deselect + Select" performed at once;
previously it could cause use-after-frees.
- Unlock for deselect only once at the end of dequeue.
- Handle INVALID events still in the queue upon destruction,
fixing memory leaks.
* Deduplified code with wait_for_objects.
* Use of C++ virtual dispatch instead of C-style enum + function calls,
and BReferenceable plus destructors for teardown.
* Removed select/modify/delete flags. Select/Modify are now the same
operation on the syscall interface, and "Delete" is done when 0
is passed for "events". Additionally, the events selected can be fetched
by passing -1 for "events".
* Implemented level-triggered mode.
* Use of BStackOrHeapArray and other convenience routines in syscalls.
Change-Id: I1d2f094fd981c95215a59adbc087523c7bbbe40b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6745
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>