Commit Graph

50 Commits

Author SHA1 Message Date
Kirk McKusick
e5d0d1c5fb Rewrite function definitions with identifier lists.
A few functions snuck in with K&R style definitions.

Also add some missing memory frees.

MFC after:    1 week
2023-03-22 15:58:18 -07:00
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
Jessica Clarke
5b13fa7987 ufs: Rework shortlink handling to avoid subobject overflows
Shortlinks occupy the space of both di_db and di_ib when used. However,
everywhere that wants to read or write a shortlink takes a pointer do
di_db and promptly runs off the end of it into di_ib. This is fine on
most architectures, if a little dodgy. However, on CHERI, the compiler
can optionally restrict the bounds on pointers to subobjects to just
that subobject, in order to mitigate intra-object buffer overflows, and
this is enabled in CheriBSD's pure-capability kernels.

Instead, clean this up by inserting a union such that a new di_shortlink
can be added with the right size and element type, avoiding the need to
cast and allowing the use of the DIP macro to access the field. This
also mirrors how the ext2fs code implements extents support, with the
exact same structure other than having a uint32_t i_data[] instead of a
char di_shortlink[].

Reviewed by:	mckusick, jhb
Differential Revision:	https://reviews.freebsd.org/D33650
2022-01-02 20:55:36 +00:00
Kirk McKusick
68d7185b64 The fsdb(8) utility uses the fsck_ffs(8) disk I/O interfaces, so
switch from using libufs's bread() to using fsck_ffs's getdatablk()
when importing tools/diag/prtblnos's prtblknos().

Sponsored by: Netflix
2020-09-19 20:06:12 +00:00
Kirk McKusick
9fc5d538fc In preparation for adding inode check-hashes, clean up and
document the libufs interface for fetching and storing inodes.
The undocumented getino / putino interface has been replaced
with a new getinode / putinode interface.

Convert the utilities that had been using the undocumented
interface to use the new documented interface.

No functional change (as for now the libufs library does not
do inode check-hashes).

Reviewed by:  kib
Tested by:    Peter Holm
Sponsored by: Netflix
2018-11-13 21:40:56 +00:00
Kirk McKusick
28ac223823 Fix incorrect output when printing block lists for files small enough
to fit in only direct blocks whose size is exactly a multiple of the
filesystem block size.

Reported by:  Peter Holm
Tested by:    Peter Holm
Sponsored by: Netflix
2018-08-20 20:44:11 +00:00
Kirk McKusick
d3009da8ad Fix incorrect output for a file consisting of a single full-size
block followed by a discontiguous fragment.

Add checks for unallocated inodes and inodes with unknown mode
types.

Cleanup variable declarations by changing from type `int' to types
like ufs_lbn_t, ufs2_daddr_t, etc.

Reported by: bde
2018-04-19 22:43:55 +00:00
Kirk McKusick
c343fa81a8 In addition to the existing argument format:
prtblknos filesystem_device inode ...

add an additional argument format:

	prtblknos file

which is more convenient than figuring out the filesystem
and inode number for "file".

When given a list of multiple inodes, rather than exiting
the program on an error with one of them, skip over it and
continue with the next one.

Submitted by: bde
2018-04-18 23:08:10 +00:00
Kirk McKusick
15e4030e9e Check the inode type and only attempt to print block lists for
regular files, directories, and symbolic links that require
external storage.

Correct the handling of files with holes and files that have
one or more large blocks and end with a fragment.

Reported by: bde
2018-04-18 22:24:44 +00:00
Kirk McKusick
f33fbc18f5 Add (intmax_t) type casts to some printf parameters to keep i386 happy. 2018-04-08 07:18:29 +00:00
Kirk McKusick
0e3f58b661 Split tools/diag/prtblknos into two parts:
main.c - opens disk and processes the argument list
		 of inodes to be printed
	prtblknos.c - prints out the list of blocks used by an inode

This change allows the fsdb program to import prtblknos() to use when
printing out the set of blocks used by an inode.

This program was switched to using the libufs library to ease its
integration with fsdb and any other filesystem utility that might
want to use it in the future.
2018-04-08 06:52:58 +00:00
Kirk McKusick
c97f1d3f37 Add an explanation of the block size units output by prtblknos.
Suggested by: Ravi Pokala (rpokala@)
2018-02-09 22:23:10 +00:00
Kirk McKusick
16c0c8eeec This is a little C-program that can be used to print out the list
of blocks used by a requested list of inodes.

For example, to list the blocks referenced by your kernel:

guest_12 % df /
Filesystem      1K-blocks     Used   Avail Capacity  Mounted on
/dev/gpt/rootfs  20307196 10707336 7975288    57%    /

guest_12 % ls -i /boot/kernel/kernel
160603 /boot/kernel/kernel

guest_12 % ./prtblknos /dev/gpt/rootfs 160603
160603:	lbn 0-7 blkno 3217584-3217647
	lbn 8-11 blkno 3217864-3217895 distance 216
First-level indirect, blkno 3217896-3217903 distance 0
	lbn 12-19 blkno 3217904-3217967 distance 8
	lbn 20-75 blkno 3251816-3252263 distance 33848
	lbn 76-83 blkno 3252368-3252431 distance 104
	lbn 84-91 blkno 3252464-3252527 distance 32
	lbn 92-852 blkno 3252896-3258983 distance 368

Each contiguous range of blocks is printed on a line.
The distance metric is the size of the gap from the end of the
previous set of blocks to the beginning of the next set of blocks.
Short distances are desirable.
2018-02-09 19:10:46 +00:00
Eitan Adler
efea29ab90 diag/httpd-error: remove
This is a script for a web server in a specific
configuration. Current web servers don't produce
similar log files and it isn't FreeBSD's
goal to produce a log file analyzer.
2017-12-02 17:10:13 +00:00
Bryan Drewery
eacae6dc66 Fix LDADD/DPADD that should be LIBADD.
Sponsored by:	EMC / Isilon Storage Division
2015-12-04 03:17:47 +00:00
Warner Losh
3bdf775801 NO_MAN= has been deprecated in favor of MAN= for some time, go ahead
and finish the job. ncurses is now the only Makefile in the tree that
uses it since it wasn't a simple mechanical change, and will be
addressed in a future commit.
2014-04-13 05:21:56 +00:00
Eitan Adler
2ab4fdc460 Remove scripts and tools which only functioned when src was using CVS
Approved by:	cperciva
MFC after:	1 week
2012-09-13 17:49:11 +00:00
Ruslan Ermilov
e653b48c80 Start the dreaded NOFOO -> NO_FOO conversion.
OK'ed by:	core
2004-12-21 08:47:35 +00:00
Ruslan Ermilov
a35d88931c For variables that are only checked with defined(), don't provide
any fake value.
2004-10-24 15:33:08 +00:00
Ruslan Ermilov
c97869c8aa Fixed ``make checkdpadd''. Removed redundant dependency. 2004-02-05 21:52:33 +00:00
Alexey Zelkin
ac5e4e9c9e Learn about new world order 2003-11-26 10:43:05 +00:00
Andrey A. Chernov
6fd04a1f52 Make it works with POSIX sort (POS arg)
All old sorts understand -k too.
2002-09-24 20:05:01 +00:00
Dag-Erling Smørgrav
d397408818 Usage style sweep: spell "usage" with a small 'u'.
Also change one case of blatant __progname abuse (several more remain)
This commit does not touch anything in src/{contrib,crypto,gnu}/.
2002-04-22 13:44:47 +00:00
Ruslan Ermilov
6239d3aebd Finish style fixes. 2002-03-26 13:02:15 +00:00
Alexey Zelkin
b5ed0bcd23 Complete '_' hack. 2002-02-07 19:32:40 +00:00
Alexey Zelkin
dca7443ba8 . add a hack dedicated to n_himba (or correctly to say problem with his nick
in docbook environment)
. clarify comments
. mention that this script is dedicated to freefall's environment
. add bsd style copyright
2002-02-07 19:27:29 +00:00
Alexey Zelkin
99349513d0 This script has served its purpose. Now its function is one of subfunctions
of recently added cknames.pl.
2002-02-07 19:13:06 +00:00
Alexey Zelkin
d97a65d2a1 Add script to check integrity between access/authors.ent/passwd@freefall 2002-02-07 19:09:49 +00:00
Alexey Zelkin
7658e887d3 Fix sentence in comment 2002-02-06 18:00:11 +00:00
Alexey Zelkin
e0738f01ca Update description of 'ac' subdirectory 2002-02-06 17:50:05 +00:00
Alexey Zelkin
1afcdc8a91 Add descirptions of scripts in this directory 2002-02-06 17:49:13 +00:00
Alexey Zelkin
f1c3a0188c Add script that checks contents of .ent files (sorting and addresses) 2002-02-06 17:47:18 +00:00
Alexey Zelkin
d6d290cbca List of committers was moved out of handbook. Teach 'ac' about new location.
Also teach it about complex entries in access file (or correctly to say
simplify them)
2002-02-06 17:09:08 +00:00
Alexey Zelkin
364a805b9f * fix some warnings
* set WARNS
* few style/whitespace fixes

Submitted by:	ru
2002-02-04 16:17:19 +00:00
Alexey Zelkin
df3cc3c14d describe localeck
plus some capitalization/whitespace fixes
2002-02-04 14:00:29 +00:00
Alexey Zelkin
ac6e0aed98 Add simple diagnostic utility to checking for invalid/incomplete
locales
2002-02-04 13:59:16 +00:00
Kelly Yancey
f1d24f0dfd Include definition for struct namecache (it isn't exported via any header)
so this builds again. Replace hardcoded name length magic with NAME_MAX.
2002-01-02 06:25:39 +00:00
Andrey A. Chernov
c09ed64a72 ISO_ -> ISO 2001-06-11 01:29:40 +00:00
Jake Burkholder
e39756439c Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by:		msmith and others
2000-05-26 02:09:24 +00:00
Jake Burkholder
740a1973a6 Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by:	phk
Reviewed by:	phk
Approved by:	mdodd
2000-05-23 20:41:01 +00:00
Sheldon Hearn
21edc5f5c8 Correct grammar in the synoptic comment.
Submitted by:	ru
2000-03-03 09:25:00 +00:00
Sheldon Hearn
d72d02311f Use double-quotes instead of single-quotes when displaying the usage
so that the shell interpolates $0.

PR:		17121
Submitted by:	Peng HaiJie <phj@cn.FreeBSD.org>
2000-03-02 15:00:53 +00:00
Wolfram Schneider
6c36ecd55c Include BSD-license.
PR:		misc/15262
Submitted by:	 alex@big.endian.de
1999-12-06 22:33:40 +00:00
Alexey Zelkin
3fcae27b92 Bring ``ac'' into reality. This great tools now works correctly (for
current state of the tree)
1999-11-04 08:45:02 +00:00
Alexey Zelkin
d4dee594a4 Add short description of dumpvfscache 1999-11-04 08:42:29 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Wolfram Schneider
40d75fab43 httpd-error is a shell script which print a summary about
Web files which does not exists on your host.

E.g.

	httpd-error -userhits < /var/log/httpd-error.log

print the number of errors by users, sorted by error hits.
1998-02-15 18:54:26 +00:00
Poul-Henning Kamp
c9e186fb37 A little gadget to dump the contents of the vfs name cache. 1997-09-04 08:28:55 +00:00
Wolfram Schneider
caccaa9b2a Add ac which check if the FreeBSD handbook is in sync with the committers list 1997-03-28 14:40:39 +00:00
Poul-Henning Kamp
04022b1194 README reads:
This directory is for diagnostic programs.

A diagnostic program is one that will inform you that something is wrong
somewhere, for instance by traversing a kernel-structure and verifying
the integrity.

Please make a subdir per program, and add a brief description to this file.
1995-10-15 11:27:15 +00:00