Commit Graph

21 Commits

Author SHA1 Message Date
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
Konstantin Belousov
d485c77f20 Remove #define _KERNEL hacks from libprocstat
Make sys/buf.h, sys/pipe.h, sys/fs/devfs/devfs*.h headers usable in
userspace, assuming that the consumer has an idea what it is for.
Unhide more material from sys/mount.h and sys/ufs/ufs/inode.h,
sys/ufs/ufs/ufsmount.h for consumption of userspace tools, with the
same caveat.

Remove unacceptable hack from usr.sbin/makefs which relied on sys/buf.h
being unusable in userspace, where it override struct buf with its own
definition.  Instead, provide struct m_buf and struct m_vnode and adapt
code to use local variants.

Reviewed by:	mckusick
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D28679
2021-02-21 11:38:21 +02: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
Pedro F. Giffuni
df57947f08 spdx: initial adoption of licensing ID tags.
The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes:	yes
Differential Revision:	https://reviews.freebsd.org/D13133
2017-11-18 14:26:50 +00:00
Ed Maste
1dc349ab95 prefix UFS symbols with UFS_ to reduce namespace pollution
Specifically:
  ROOTINO -> UFS_ROOTINO
  WINO -> UFS_WINO
  NXADDR -> UFS_NXADDR
  NDADDR -> UFS_NDADDR
  NIADDR -> UFS_NIADDR
  MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Also prefix ext2's and nandfs's NDADDR and NIADDR with EXT2_ and NANDFS_

Reviewed by:	kib, mckusick
Obtained from:	NetBSD
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D9536
2017-02-15 19:50:26 +00:00
Gleb Kurtsou
9b33705411 Adjust printf format specifiers for dev_t and ino_t in user space.
ino_t and dev_t are about to become uint64_t.

Reviewed by:	kib, mckusick
2014-12-17 07:10:48 +00:00
Ed Schouten
1efe3c6b58 Add missing static keywords for global variables to tools in sbin/.
These tools declare global variables without using the static keyword,
even though their use is limited to a single C-file, or without placing
an extern declaration of them in the proper header file.
2011-11-04 13:36:02 +00:00
Xin LI
5c68d10833 Don't coredump when executed with -o. 2008-01-29 00:20:00 +00:00
Brian Somers
8428fde517 Default output to stdout as the man page suggests. 2007-02-14 23:22:33 +00:00
Brian Somers
30e3c0fa25 Only go through our cylinder group and inode info when we need to.
This allows ``ffsinfo -o - -l1 /tmp'' to run a lot quicker.
2007-02-14 23:20:30 +00:00
Brian Somers
89f0730d6b Re-indent main() in preparation for further changes. 2007-02-14 23:12:32 +00:00
Robert Watson
c4b2cc12ae Don't default to '/var/tmp/ffsinfo' for the output of ffsinfo(8), since
/var/tmp is a world-writable directory.

MFC after:	3 days
Reported by:	Jon Passki <cykyc@yahoo.com>
2005-03-31 04:05:17 +00:00
Ruslan Ermilov
8d646af581 Sync program's usage() with manpage's SYNOPSIS. 2005-02-10 09:19:34 +00:00
Robert Watson
7bb84191e6 The ffsinfo utility uses atol() to parse numeric values out of optarg
strings.  This isn't necessarily a bug, but it can be slightly inconvenient,
because atol() doesn't know how to parse hexadecimal or octal numbers and at
least one of the options of ffsinfo(8) would be easier to use if it did.

Changing atol() -> strtol() allows one to use hex masks for -l MASK, i.e.:

orion:/a/freebsd/src/sbin/ffsinfo# ./ffsinfo -l 0x3ff /

PR:		73110
Submitted by:	keramida
MFC after:	2 weeks
2005-01-03 18:59:04 +00:00
Stefan Farfeleder
f901ebcfb6 Assign the result of getopt() to an int rather than to a char (which is
possibly unsigned).
2004-07-26 15:04:57 +00:00
Robert Watson
942d2e0205 Commit 1 of 2 to fix ffsinfo(8) for UFS2.
Update ffsinfo(8) to use new UFS2 support in the growfs(8) debugging
functions.  Largely consists of renaming fields and types to be aware
of the UFS1/UFS2 distinction, relying on libufs(3) to open and sanity
check the device/file/label accessed.

Since libufs(3) now handles label/UFS interactions, remove -L argument.

Note: when submitted, this patch had substantial style changes.  I've
attempted to remove the restyling from the patch to separate the
functional and style changes.

Submitted by:	Lukas Ertl <l.ertl@univie.ac.at>
PR:		bin/53517
2003-08-14 18:55:31 +00:00
Tom Rhodes
ce66ddb763 s/filesystem/file system/g as discussed on -developers 2002-08-21 18:11:48 +00:00
Ruslan Ermilov
8af1452cf8 Removed duplicate VCS ID tags, as per style(9). 2001-08-13 14:06:34 +00:00
Thomas-Henning von Kamptz
adcaff07f8 cleanup to get rid of most warnings on alpha
and yes now it also works on alpha

Reviewed by:	chm
MFC after:	3 weeks
2001-06-07 20:43:00 +00:00
Thomas-Henning von Kamptz
4020c5bc54 corrected spelling mistakes in comments
check a couple of mallocs
usage of errx
linebreaks of DBG_ macros,
correcting the usage of nroff macros

Submitted by:	grog, charnier
Reviewed by:	chm
2000-12-12 20:03:17 +00:00
Thomas-Henning von Kamptz
3d5000784d added growfs(8) including ffsinfo(8) to the freebsd base system
Reviewed by:	 grog
2000-12-09 15:27:35 +00:00