freebsd-dev/stand/libsa
Kirk McKusick e688661642 Move the ability to search for alternate UFS superblocks from fsck_ffs(8)
into ffs_sbsearch() to allow use by other parts of the system.

Historically only fsck_ffs(8), the UFS filesystem checker, had code
to track down and use alternate UFS superblocks. Since fsdb(8) used
much of the fsck_ffs(8) implementation it had some ability to track
down alternate superblocks.

This change extracts the code to track down alternate superblocks
from fsck_ffs(8) and puts it into a new function ffs_sbsearch() in
sys/ufs/ffs/ffs_subr.c. Like ffs_sbget() and ffs_sbput() also found
in ffs_subr.c, these functions can be used directly by the kernel
subsystems. Additionally they are exported to the UFS library,
libufs(8) so that they can be used by user-level programs. The new
functions added to libufs(8) are sbfind(3) that is an alternative
to sbread(3) and sbsearch(3) that is an alternative to sbget(3).
See their manual pages for further details.

The utilities that have been changed to search for superblocks are
dumpfs(8), fsdb(8), ffsinfo(8), and fsck_ffs(8). Also, the prtblknos(8)
tool found in tools/diag/prtblknos searches for superblocks.

The UFS specific mount code uses the superblock search interface
when mounting the root filesystem and when the administrator doing
a mount(8) command specifies the force flag (-f). The standalone UFS
boot code (found in stand/libsa/ufs.c) uses the superblock search
code in the hope of being able to get the system up and running so
that fsck_ffs(8) can be used to get the filesystem cleaned up.

The following utilities have not been changed to search for
superblocks: clri(8), tunefs(8), snapinfo(8), fstyp(8), quot(8),
dump(8), fsirand(8), growfs(8), quotacheck(8), gjournal(8), and
glabel(8). When these utilities fail, they do report the cause of
the failure. The one exception is the tasting code used to try and
figure what a given disk contains. The tasting code will remain
silent so as not to put out a slew of messages as it trying to taste
every new mass storage device that shows up.

Reviewed by: kib
Reviewed by: Warner Losh
Tested by:   Peter Holm
Differential Revision: https://reviews.freebsd.org/D36053
Sponsored by: The FreeBSD Foundation
2022-08-13 12:43:40 -07:00
..
amd64 libsa: Remove conflicting .global/.weak directive 2021-03-30 14:59:41 +01:00
geli stand: Add disk_fmtdev for dv_fmtdev for all the disk devices 2022-08-11 10:27:16 -06:00
i386
mips libsa: mips: fix typo that had slipped into the diff on local machine 2019-08-22 21:49:13 +00:00
powerpc Add CFI start/end proc directives to arm64, i386, and ppc 2020-12-05 00:33:28 +00:00
x86 Add support for hypervisor check on x86 2019-10-24 20:02:48 +00:00
zfs stand: Only compile decompression routines 2022-08-12 21:48:18 -06:00
__main.c
abort.c
arp.c
assert.c
bcd.c
bootp.c stand: use snprintf here 2022-08-03 11:24:38 -06:00
bootp.h
bootparam.c
bootparam.h
bzipfs.c stand: Use c99 structure initialization for bzipfs_fsops 2022-07-24 16:53:35 -06:00
cd9660.c loader: implement mount/unmount rootfs 2021-09-08 04:01:20 +03:00
cd9660read.c loader: cd9660_open() warn: is 'buf' large enough for 'struct iso_primary_descriptor'? 2019-12-13 12:36:16 +00:00
close.c loader: open file list should be dynamic 2021-08-10 21:54:32 +03:00
closeall.c loader: open file list should be dynamic 2021-08-10 21:54:32 +03:00
crc32_libkern.c Separate kernel crc32() implementation to its own header (gsb_crc32.h) and 2019-06-17 19:49:08 +00:00
dev.c stand: Add devformat to return formatted string for a device 2022-08-11 10:27:16 -06:00
dosfs.c stand: Use devformat rather than disk_devfmt 2022-08-11 10:27:16 -06:00
dosfs.h
environment.c libsa: remove leftover whitespace 2020-08-19 20:41:22 +00:00
ether.c
ext2fs.c stand: Use c99 structure initialization for ext2fs_fsops 2022-07-24 16:53:35 -06:00
fstat.c loader: open file list should be dynamic 2021-08-10 21:54:32 +03:00
getopt.c
gets.c
globals.c
gpt.c loader: remove libsa/crc32.c and use version from zlib 2020-03-19 21:05:11 +00:00
gpt.h Eliminate unused uuid parameters from gptread and gptread_table. We 2019-06-05 02:34:58 +00:00
gzipfs.c stand: Use c99 structure initialization for gzipfs_fsops 2022-07-24 16:53:35 -06:00
hexdump.c zalloc_malloc:Free hexdump preceeding buffer when we detect overflow 2020-08-29 21:05:43 +00:00
in_cksum.c ANSIify libsa functions 2021-11-18 22:43:02 -07:00
inet_ntoa.c ANSIify libsa functions 2021-11-18 22:43:02 -07:00
ioctl.c loader: open file list should be dynamic 2021-08-10 21:54:32 +03:00
iodesc.h loader: open file list should be dynamic 2021-08-10 21:54:32 +03:00
ip.c
libsa.3
lseek.c loader: open file list should be dynamic 2021-08-10 21:54:32 +03:00
Makefile stand: Compile out the extensive superblock diagnostic messages for BIOS loader 2022-08-12 21:48:17 -06:00
Makefile.depend
mount.c loader: implement mount/unmount rootfs 2021-09-08 04:01:20 +03:00
net.c loader: ip: Do not call getsecs so much 2021-12-16 11:50:36 +01:00
net.h loader: open file list should be dynamic 2021-08-10 21:54:32 +03:00
netif.c stand: netif kill set but unused variables 2021-12-15 19:44:28 -07:00
netif.h
nfs.c stand: Use c99 structure initialization for nfs_fsops 2022-07-24 16:53:35 -06:00
nfsv2.h
nullfs.c
open.c loader: open file list should be dynamic 2021-08-10 21:54:32 +03:00
pager.c
panic.c
pkgfs.c stand: Use c99 structure initialization for pkgfs_fsops 2022-07-24 16:53:35 -06:00
preload.c loader: Add preload operation to fs_ops 2021-12-16 11:50:38 +01:00
printf.c loader printf: Profile with TSLOG 2021-09-24 20:23:49 -07:00
random.c
rarp.c
read.c loader: open file list should be dynamic 2021-08-10 21:54:32 +03:00
readdir.c loader: open file list should be dynamic 2021-08-10 21:54:32 +03:00
rpc.c
rpc.h
rpcv2.h
saioctl.h
sbrk.c
smbios.c libsa: smbios: Parse the chassis type and export it as smbios.chassis.type 2020-08-20 12:50:49 +00:00
smbios.h Move smbios.c to libsa. 2020-02-20 00:46:22 +00:00
splitfs.c stand: Use c99 structure initialization for splitfs_fsops 2022-07-24 16:53:35 -06:00
stand.h stand: Add dv_devfmt to return a string represenation of the device 2022-08-11 10:27:16 -06:00
stat.c ANSIify libsa functions 2021-11-18 22:43:02 -07:00
strcasecmp.c ANSIify libsa functions 2021-11-18 22:43:02 -07:00
strdup.c ANSIify libsa functions 2021-11-18 22:43:02 -07:00
strerror.c
tftp.c stand: tftp.c doesn't need bootinfo.h 2022-07-27 09:04:13 -06:00
tftp.h
time.c Implement some time variables from kernel 2020-09-29 16:29:50 +00:00
tslog.c loader tslog: Don't use sprintf 2021-09-24 20:23:37 -07:00
twiddle.c loader: Set twiddle globaldiv to 16 by default 2021-09-28 15:24:02 -07:00
udp.c
ufs.c Move the ability to search for alternate UFS superblocks from fsck_ffs(8) 2022-08-13 12:43:40 -07:00
ufsread.c
uuid_from_string.c Regularize my copyright notice 2019-12-04 16:56:11 +00:00
uuid_to_string.c Regularize my copyright notice 2019-12-04 16:56:11 +00:00
write.c loader: open file list should be dynamic 2021-08-10 21:54:32 +03:00
xlocale_private.h
zalloc_defs.h stand: remove mips support 2021-12-10 11:05:31 -07:00
zalloc_malloc.c zalloc_malloc:Free hexdump preceeding buffer when we detect overflow 2020-08-29 21:05:43 +00:00
zalloc_mem.h loader: cstyle cleanup libsa zalloc sources 2019-09-17 11:35:53 +00:00
zalloc_protos.h loader: add memalign() to libsa 2019-09-17 13:15:27 +00:00
zalloc.c stand: Fix a common typo in source code comments 2022-06-05 09:49:51 +02:00