vidcontrol: keep the failing ioctl's errno across revert()
revert() calls ioctls of its own, so if one of them fails it replaces the
error that made us revert in the first place and the message names the wrong
error. Save errno before calling revert().
Following FreeBSD commit 1b8c842e ("Fix some parsing and error handling
bugs"), which does this for the mode-set failure; done here for all
three calls in video_mode() (CONS_MODEINFO, CONS_SET, KDRASTER).
Bug: https://bugs.dragonflybsd.org/issues/2493
vidcontrol: accept the documented [mode] [fg [bg]] [show] forms
Fixes the syntax documented in vidcontrol(1).
video_mode() treated any unrecognized first positional argument as an
invalid video mode, so the documented color-only form
vidcontrol yellow blue
failed with "invalid video mode name". Leave such an argument to
get_normal_colors() instead, as FreeBSD does (see FreeBSD commit
1b8c842e: "Fix some parsing and error handling bugs"). A mistyped mode
name then reaches usage() with exit status 1, and MODE_<non-digit> still
reports "invalid video mode number".
The "show" handling also sat before the mode and color arguments, so it was
only accepted as the *first* positional argument and the documented
vidcontrol 80x25 white black show
[8 lines not shown]
bsd.sys.mk: A few more cleanups
* Add WERROR variable to help manage -Werror, similar to the handling in
<bsd.kern.mk>.
* Reorgnize a few feature cases to group -fxxx flags together.
bsd.sys.mk: Fix regression to make CWARNFLAGS be appended at last
CWARNFLAGS allows a user to specify custom warning flags, so it should
be appended to CFLAGS at last. This commit fixes the regression
introduced in commit 6dd738473955429dcfc85a5829c422837216bb26.
Meanwhile, document CWARNFLAGS in make.conf(5) man page.
Discussed-with: swildner
bsd.sys.mk: Adjust _cnowarnflags for WARNS=3
* -Wunused-but-set-parameter is included in -Wextra, which is enabled at
WARNS=3, so move the -Wno-unused-but-set-parameter flag to WARNS=3.
* Merge -Wno-unused-but-set-parameter and -Wno-unused-parameter, and
remove the GCC check because it also applies to Clang (its -Wextra
also enables the two warnings).
* Adjust the -Wno-implicit-fallthrough case to clean up the condition a
bit.
Reviewed-by: swildner
dsynth - Fix improper deletions with "prepare-system"
* Don't delete "obsolete" packages for "prepare-system"
* Obsolete packages can only be properly deleted when
a full scan is done. "prepare-system" only does a
partial scan so it winds up deleting stuff it
should not delete.
kernel - Fix page fault in the jail unmount check
sys_unmount() printed the "does not belong to this jail" message using
uap->path, a user-space pointer. With SMAP enabled, kprintf() -> strlen()
faults on it.
Use nd.nl_path, the kernel copy that nlookup_init() already made.
Panic reproduce steps, assuming a jail is prepared at `/jail`:
```
jail# umount /dev
```
Reported-by: tuxillo
Bug: https://bugs.dragonflybsd.org/issues/3386
gcc120,gcc80: Reuse COMPILE.cc to avoid duplicating explicit rules
Make use of COMPILE.cc from <sys.mk> to avoid duplicating explicit rules
(in particular the various flags) in libstdc++/components/libconv_2011.
In addition, create a ".USE" reusable rule to further reduce duplicate
code.
bsd.sys.mk: Adjust -Wno-unused-value for WARNS level
Without this adjustment, building gnu/usr.bin/gdb/libdecnumber with
WARNS=2 would fail with the -Werror=unused-value warning, but with
WARNS=3 the building would succeed.
Discussed-with: swildner
gcc120,gcc80: Get rid of duplicate explicit compile rules
Make use of the new features implemented in the last commit.
Actually, this fixed one mistake in gcc80/libgcc that the 'raise'
flags group was ignored, because the explicit compile rules didn't refer
to the group flags. Luckily, the build result was good; md5 checksums
of the libraries don't change.
stand/pxeldr_tftp: Remove obsolete AFLAGS
Two reasons:
- AFLAGS is not used by the .S suffix rule; should use CFLAGS instead.
- This is no longer needed after the commit
6c644be32975767831a57868196e63523af13989 that collapsed makefile with
parent to avoid duplication.
gnu/lib: Add missing WARNS to gcc120 and gcc80
Note that the following libraries require WARNS=0:
- gcc80/libstdc++/components/libconv_supc
- gcc120/libstdc++/components/libconv_1998
- gcc120/libstdc++/components/libconv_supc
share/mk: Support per-target flags and explicit source mapping
* Add the "FLAGS.<target>.o" variable to specify per-target flags for
compiling a library target of all kinds, i.e., <target>.o, <target>.po
and <target>.So.
* Implement the reusable "_LIB_COMPILE.<ext>" compile rules to support
explicit source mapping. This is required to support compiling one
source file into multiple objects with different defines/flags.
The two features are combined to avoid duplicating the explicit compile
commands in GCC libraries (i.e., libgcc, libgcov, and libatomic).
share/mk: Implement reusable COMPILE.<ext> compile commands
Implement per-extension COMPILE.<ext> compile commands and introduce the
per-mode flags (e.g., _CFLAGS_MODE.o) to make them reusable in
<bsd.lib.mk>, and therefore avoid duplicate code.
This refactoring helps further introduce the per-target flags and .USE
targets for explicit source mappings in the forthcoming commits.
share/mk: Update suffix rules to avoid duplicates
* Add ${STATIC_CFLAGS} and ${STATIC_CXXFLAGS} flags to the .c and .cc
rules in <sys.mk>, so that they can be reused by <bsd.lib.mk>. The
${STATIC_CFLAGS} is only used by lib/libpam.
* Use the .o suffix rules from <sys.mk> and remove the duplicates in
<bsd.lib.mk>.
* Fix the .s rule to compile with "${AS} ${AFLAGS}", the same rule as
defined in <sys.mk>.
* Fix the .S rule to compile with "${CC} -x assembler-with-cpp" instead
of plain ${CC}.
* Some minor tweaks for consistency.
Also referred to FreeBSD.
hammer2(8): hash inode numbers and media offsets together
The recovery secondary hash XORs inode numbers with shifted media
offsets. The two values are correlated, so the XOR often cancels and
puts many entries in one bucket. This is a real concern because the
recovery is basically a block scan on a copy-on-write filesystem, so
there can be *many* copies of the same inode in the scan.
Hash the two complete values with the existing HAMMER2 XXH64 and share
the helper between both inode insertion paths.
Reported-by: tkusumi
Reviewed-by: dillon
Bug: https://bugs.dragonflybsd.org/issues/3378
vkernel64: Fix -Waddress warning in trap_fatal()
Fixes building with gcc120 that has -Werror enabled.
```
/usr/src/sys/platform/vkernel64/x86_64/trap.c: In function 'trap_fatal':
/usr/src/sys/platform/vkernel64/x86_64/trap.c:937:61: error: the comparison will always evaluate as 'true' for the address of 'p_comm' will never be NULL [-Werror=address]
937 | (u_long)curproc->p_pid, curproc->p_comm ?
| ^
In file included from ./machine/cpufunc.h:70,
from /usr/src/sys/sys/systm.h:50,
from /usr/src/sys/platform/vkernel64/x86_64/trap.c:51:
/usr/src/sys/sys/proc.h:290:25: note: 'p_comm' declared here
290 | char p_comm[MAXCOMLEN+1]; /* typ 16+1 bytes */
| ^~~~~~
cc1: all warnings being treated as errors
```
vkernel64: Fix kern_envp building bug with multiple '-e' flags
The 'name=value' environment entries are separated by one NUL in the
'kern_envp' buffer, which is ended by another NUL.
The '-e' flag parsing code previously determined the write position from
the allocated size (i.e., pos = kenv_size - 1), which counted the
stripped quote characters, so any environment entries specified by later
'-e' flags were appended after a premature end-of-environment and
therefore invisible.
Fix the bug by using 'kenv_pos' (renamed from 'pos') to correctly track
the write position for every '-e' flag. Meanwhile, consolidate the
malloc() into realloc(), which can handle a NULL input.
Assisted-by: DeepSeek-v4.1-flash (with Pi Coding Agent)
netinet: fix ARP resolution during the first second of uptime
A cloned route created while time_uptime is zero passes a zero expiry
to its neighbors. Zero denotes a permanent entry, so unresolved dynamic
neighbors never send ARP requests.
Add the arp_expire_unresolved (= time_uptime + 1) to keep dynamic expiry
nonzero and track the last request time separately, using la_asked to
indicate whether that time is valid. This preserves same-second rate
limiting and permanent-entry semantics without changing the routing ABI.
While there, fix the code to add arpt_down to rt_expire only when it's a
cloned route.
Co-authored-by: Aaron LI <aly at aaronly.me>
GitHub-PR: https://github.com/DragonFlyBSD/DragonFlyBSD/pull/58
kernel - Fix cache_fullpath() races in procfs
* Address races where an exiting process can cause procfs to
crash when procfs is building its directory for the process.
cache_fullpath() can have its nchandle ripped out from under it.
* Generally solved by making cache_fullpath() create ref'd copies
of the nchandle. Also provide a cache_fullpath_refd() that avoids
this.
* Make the file paths returned by procfs be relative to the calling
process so the path is actually useful regardless of chroot. If
the calling process happens to be within the same chroot, or in
a parent root / real root.
If the calling process is in a different chroot than the target
process such that the path is inaccessible, the path will be
be shown as "unknown".
[5 lines not shown]
amdgpu: Fix #GP panic on module loading caused by misaligned accesses
After the FPU/SIMD flag changes (commits 8363c80b88 and c12d11212d),
loading the amdgpu.ko module could simply panic the system, as reported
by kentish on ThinkPad T495 with Ryzen 5 3500U.
Various tests showed that compiling only dcn_calcs.o with '-O0' and
gcc80 made the module work, but '-O0' with gcc120 didn't. Tracking this
down revealed the kernel-stack misalignment issue for these amdgpu
sources. After the flags change, GCC generates 16-byte aligned SSE
memory accesses on the kernel stack, but our kernel stack is only 8-byte
aligned (TF_SIZE = 200 bytes), so this misaligned accesses caused #GP
panic as reported.
Add '-mpreferred-stack-boundary=3' to tell GCC about the real alignment
so it realigns the stack where needed, and thus fix the loading panic.
Tested-on: ThinkPad T495 with Ryzen 5 3500U
Reported-by: kentish
Assisted-by: DeepSeek-v4.1-flash (with Pi Coding Agent)