gpt(8): Improve "show" command to print a disk summary line
Before print the partition entries, print a disk summary line like:
"Disk /dev/da0: 50.0GB (104857600 512-byte sectors)".
In addition, add a blank line between disks.
Example new output:
```
$ sudo gpt show /dev/da0 ad0
Disk /dev/da0: 50.0GB (104857600 512-byte sectors)
start size index contents
0 1 - PMBR
1 1 - Pri GPT header
2 32 - Pri GPT table
34 2014 - Unused
2048 262144 0 GPT part - EFI System
264192 104591360 1 GPT part - DragonFly Label64
104855552 2015 - Unused
[14 lines not shown]
gpt(8): Print a warning message when gpt_write() fails
gpt_write() is used in many places and all of them don't handle the
writing failure, so update gpt_write() to print a warning message when
it fails.
gpt(8): Fix surrogate pair handling bug in utf16_to_utf8()
* The old code mishandled surrogate pairs and thus failed to recognize
valid UTF-16 characters and would replace them with 0xFFFD. Fix the
code to correctly handle the surrogate pairs.
* Fix an out-of-bound access in the old code when it tried to handle the
surrogate pairs. Check `s16idx < s16len` before accessing it with
`le16toh(s16[s16idx])`.
* Remove the `if (utfchar < 0x200000)` branch, because it's impossible
for `utfchar` exceeding 0x200000.
* Tweak the `while` loop conditional to clean up the code.
Credit: ChatGPT (https://chatgpt.com/)
gpt(8): Change utf8_to_utf16/utf16_to_utf8() to use 'char *'
Use 'char *' instead of 'uint8_t *' for NUL-terminated UTF-8 strings,
making it easier for callers.
Makefile.inc1: Allow safe installkernel with pkgbase
Commit 74a6bb524e5b added a check to install{world,kernel} to avoid
people accidentally running this on pkgbase systems and leaving their
system broken. This had two issues:
(1) The warning was not sufficiently scary, leading people to think
this was safe to do as long as they set DESTDIR=/.
(2) The installkernel check was too strict, and prevented installing
kernels that don't conflict with packaged kernels.
Fix (1) by rewording the warning to be scarier, and while here, add
two new variables (ALLOW_PKGBASE_INSTALL{WORLD,KERNEL}) which could
be set in /etc/make.conf for people who want to break their systems
by default.
Fix (2) by improving the installkernel check to see if the kernel(s)
we're actually installing are packaged. This means a new kernel can
[12 lines not shown]
Makefile.inc1: Fix INSTALLEXTRAKERNELS for one-kernel case
If BUILDKERNELS contains a single kernel, and NO_INSTALLEXTRAKERNELS=no,
then ${BUILDKERNELS:[2..-1]} returns the first kernel in the list and
that kernel ends up in both INSTALLKERNEL and INSTALLEXTRAKERNELS.
This breaks the package build because it means we generate that package
twice, once with an incorrect install path of /boot/kernel.NAME instead
of /boot/kernel.
Only set INSTALLEXTRAKERNELS if we're building at least two kernels.
Fixes: 2c0e9a76c1ce ("Makefile.inc1: Make NO_INSTALLKERNEL less of a hack")
Reviewed by: jrtc27
Sponsored by: https://www.patreon.com/bsdivy
Differential Revision: https://reviews.freebsd.org/D54539
(cherry picked from commit 0b298e314a8b47c1f2bf8a9ff86c050accbd744d)
Makefile.inc1: Make NO_INSTALLKERNEL less of a hack
Rather than adding a dummy entry which requires everyone to know to skip
it, introduce a new INSTALLEXTRAKERNELS which contains the set of
kernels to install as kernel.KERNCONF.
Reviewed by: ivy
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54291
(cherry picked from commit 2c0e9a76c1cee8766245a0b5bdad73e995b790c6)
gpt(8): Fix bugs in utf8_to_utf16()
- The 'utfchar' was incorrectly reinitialized to zero on every loop
iteration and thus destroyed the decoding state of multi-byte UTF-8
sequences. Fix it.
- Fix the endianness by adding the missing htole16() calls.
Obtained-from: NetBSD
gpt(8): Improve utf8_to_utf16()
- No need to NUL-terminate the UTF-16 string when it needs truncation.
- Pad the remaining characters with zeros. (obtained from NetBSD)
gpt(8): Improve utf16_to_utf8()
- Let caller pass the buffer and thus avoid memory allocation.
- Handle the case that there is no NUL termination, i.e., the partition
name is exactly 36 characters, which is allowed by the specification.
Obtained-from: NetBSD
gpt(8): Fix gpt_read() to report partial read error
A partial read() wouldn't touch 'errno', so the caller was unable to
know the error reason. This caused the program to print an error
message like:
```
gpt show: unable to open device 'vn4': Undefined error: 0
```
Fix gpt_read() to return E2BIG (I couldn't find a better choice) for a
partial read(), so the above error becomes:
```
gpt show: unable to open device 'vn4': Argument list too long
```
Still a bit weird, but better, I guess.
gpt(8): Clear errno before retrying open() in gpt_open()
Otherwise, the stale errno would go through gpt_read() when it failed
with a partial read, and the program would print a weird error message
like:
```
gpt show: unable to open device 'vn4': No such file or directory
```
Suggested-by: swildner
powerpc: Update CPUTYPE options in make.conf
Document the supported PPC/POWER CPUTYPEs in the example make.conf.
Update bsd.cpu.mk to handle CPUs newer than POWER9, and remove
32-bit CPUTYPEs since we no longer support those at all.
Reviewed by: imp, jhibbits
Sponsored by: https://www.patreon.com/bsdivy
Differential Revision: https://reviews.freebsd.org/D54257
(cherry picked from commit 665ac052aa04c4dc240d67c3c2166ac63e7f86eb)
bridge: Allow BRDGSIFVLANSET without IFBRF_VLANFILTER
Currently, we disallow BRDGSIFVLANSET when IFBRF_VLANFILTER is disabled.
There's no particular reason to do this, and it causes some undesirable
behaviour such as not being able to remove the tagged config on a member
after disabling vlanfilter on the bridge.
Remove the restriction so BRDGSIFVLANSET is always accepted.
PR: 292019
MFC after: 1 week
Reviewed by: zlei, p.mousavizadeh_protonmail.com
Sponsored by: https://www.patreon.com/bsdivy
Differential Revision: https://reviews.freebsd.org/D54435
(cherry picked from commit 2e92aeede85c8986bd6f4dde65d2ac2449eccf51)
[ELF] Add target-specific relocation scanning for ARM (#182440)
Implement ARM::scanSectionImpl, following the pattern established for
AArch64 and other targets. This merges the getRelExpr and TLS handling
for SHF_ALLOC sections into the target-specific scanner, enabling
devirtualization and eliminating abstraction overhead.
- Inline relocation classification into scanSectionImpl with a switch
on relocation type, replacing the generic rs.scan() path.
- Use processR_PC/processR_PLT_PC for common PC-relative and PLT
relocations.
- Handle TLS inline: checkTlsLe for TLS LE, handleTlsIe<false> for
TLS IE (no IE-to-LE optimization for ARM), and direct flag/reloc
emission for TLS GD/LD (no GD/LD optimization for ARM).
- Set hasGotOffRel for R_GOTREL/R_GOTONLY_PC relocations.
- Simplify getRelExpr to only handle relocations needed by
relocateNonAlloc and preprocessRelocs.
pkg-stage.sh: Add ext2 and ntfs
Having these packages available on release media may help users who
need to sneakernet other packages (e.g. firmware) from systems running
Linux or Windows.
Suggested by: vladlen, ziaee
MFC after: 3 days
pkg-stage.sh: Add ext2 and ntfs
Having these packages available on release media may help users who
need to sneakernet other packages (e.g. firmware) from systems running
Linux or Windows.
Suggested by: vladlen, ziaee
MFC after: 3 days