History log of /freebsd-current/usr.sbin/quot/quot.c
Revision Date Author Comments
# 752a3404 02-Feb-2024 Ricardo Branco <rbranco@suse.de>

quot: Use getopt(3) and show usage() if no arguments

Also update the man page and usage to be a little more accurate with the
-a flag.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/983


# 4d65a7c6 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.sbin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# b21582ee 30-Jul-2022 Kirk McKusick <mckusick@FreeBSD.org>

Add a flags parameter to the ffs_sbget() function that reads UFS superblocks.

Rather than trying to shoehorn flags into the requested superblock
address, create a separate flags parameter to the ffs_sbget()
function in sys/ufs/ffs/ffs_subr.c. The ffs_sbget() function is
used both in the kernel and in user-level utilities through export
to the sbget() function in the libufs(3) library (see sbget(3)
for details). The kernel uses ffs_sbget() when mounting UFS
filesystems, in the glabel(8) and gjournal(8) GEOM utilities,
and in the standalone library used when booting the system
from a UFS root filesystem.

The ffs_sbget() function reads the superblock located at the byte
offset specified by its sblockloc parameter. The value UFS_STDSB
may be specified for sblockloc to request that the standard
location for the superblock be read.

The two existing options are now flags:

UFS_NOHASHFAIL will note if the check hash is wrong but will still
return the superblock. This is used by the bootstrap code to
give the system a chance to come up so that fsck can be run to
correct the problem.

UFS_NOMSG indicates that superblock inconsistency error messages
should not be printed. It is used by programs like fsck that
want to print their own error message and programs like glabel(8)
that just want to know if a UFS filesystem exists on a partition.

One additional flag is added:

UFS_NOCSUM causes only the superblock itself to be returned, but does
not read in any auxiliary data structures like the cylinder group
summary information. It is used by clients like glabel(8) that
just want to check for possible filesystem types. Using UFS_NOCSUM
skips the superblock checks for csum data which allows superblocks
that have corrupted csum data to be read and used.

The validate_sblock() function checks that the superblock has not
been corrupted in a way that can crash or hang the system. Unless
the UFS_NOMSG flag is specified, it will print out any errors that
it finds. Prior to this commit, validate_sblock() returned as soon
as it found an inconsistency so would print at most one message.
It now does all its checks so when UFS_NOMSG has not been specified
will print out everything that it finds inconsistent.

Sponsored by: The FreeBSD Foundation


# 34816cb9 18-Jun-2020 Kirk McKusick <mckusick@FreeBSD.org>

Move the pointers stored in the superblock into a separate
fs_summary_info structure. This change was originally done
by the CheriBSD project as they need larger pointers that
do not fit in the existing superblock.

This cleanup of the superblock eases the task of the commit
that immediately follows this one.

Suggested by: brooks
Reviewed by: kib
PR: 246983
Sponsored by: Netflix


# fb14e73c 05-Dec-2018 Kirk McKusick <mckusick@FreeBSD.org>

Normally when an attempt is made to mount a UFS/FFS filesystem whose
superblock has a check-hash error, an error message noting the
superblock check-hash failure is printed and the mount fails. The
administrator then runs fsck to repair the filesystem and when
successful, the filesystem can once again be mounted.

This approach fails if the filesystem in question is a root filesystem
from which you are trying to boot. Here, the loader fails when trying
to access the filesystem to get the kernel to boot. So it is necessary
to allow the loader to ignore the superblock check-hash error and make
a best effort to read the kernel. The filesystem may be suffiently
corrupted that the read attempt fails, but there is no harm in trying
since the loader makes no attempt to write to the filesystem.

Once the kernel is loaded and starts to run, it attempts to mount its
root filesystem. Once again, failure means that it breaks to its prompt
to ask where to get its root filesystem. Unless you have an alternate
root filesystem, you are stuck.

Since the root filesystem is initially mounted read-only, it is
safe to make an attempt to mount the root filesystem with the failed
superblock check-hash. Thus, when asked to mount a root filesystem
with a failed superblock check-hash, the kernel prints a warning
message that the root filesystem superblock check-hash needs repair,
but notes that it is ignoring the error and proceeding. It does
mark the filesystem as needing an fsck which prevents it from being
enabled for writing until fsck has been run on it. The net effect
is that the reboot fails to single user, but at least at that point
the administrator has the tools at hand to fix the problem.

Reported by: Rick Macklem (rmacklem@)
Discussed with: Warner Losh (imp@)
Sponsored by: Netflix


# d8ba45e2 16-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Revert r313780 (UFS_ prefix)


# 1e2b9afc 16-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Prefix UFS symbols with UFS_ to reduce namespace pollution

Followup to r313780. Also prefix ext2's and nandfs's versions with
EXT2_ and NANDFS_.

Reported by: kib
Reviewed by: kib, mckusick
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D9623


# dffce215 25-Jan-2018 Kirk McKusick <mckusick@FreeBSD.org>

Refactoring of reading and writing of the UFS/FFS superblock.
Specifically reading is done if ffs_sbget() and writing is done
in ffs_sbput(). These functions are exported to libufs via the
sbget() and sbput() functions which then used in the various
filesystem utilities. This work is in preparation for adding
subperblock check hashes.

No functional change intended.

Reviewed by: kib


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

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.

No functional change intended.


# 1dc349ab 15-Feb-2017 Ed Maste <emaste@FreeBSD.org>

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


# 6e560add 01-May-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

quot: make use of our rounddown() macro when <sys/param.h> is available.

No functional change.


# b424efd5 27-Sep-2012 Matthew D Fleming <mdf@FreeBSD.org>

Fix usr.bin/ and usr.sbin/ build with a 64-bit ino_t.

Original code by: Gleb Kurtsou


# 7649cb00 23-Jan-2011 Kirk McKusick <mckusick@FreeBSD.org>

The dump, fsck_ffs, fsdb, fsirand, newfs, makefs, and quot utilities
include sys/time.h instead of time.h. This include is incorrect as
per the manpages for the APIs and the POSIX definitions. This commit
replaces sys/time.h where necessary with time.h.

The commit also includes some minor style(9) header fixup in newfs.

This commit is part of a larger effort by Garrett Cooper started in
//depot/user/gcooper/posix-conformance-work/ -- to make FreeBSD more
POSIX compliant.

Submitted by: Garrett Cooper yanegomi at gmail dot com


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# b4eca767 14-Sep-2008 Ed Schouten <ed@FreeBSD.org>

Make `quot -a' work when we've got slashes in the device name.

A very long time ago we had raw device nodes. quot(8) was supposed to
use these when running `quot -a'. For some reason the code got once
changed to strip the device name until it reaches the last slash. This
is not reliable, because this means /dev/mirror/foo will be stripped to
/dev/foo.

This bug also exists on RELENG_7 and RELENG_6, but I think I'll just
merge them back somewhere after the upcoming releases. There's no rush.

MFC after: 2 months


# 8f518424 02-Jul-2008 Dag-Erling Smørgrav <des@FreeBSD.org>

Drag this code kicking and screaming into the twenty-first century.


# c433b438 30-Sep-2006 Maxim Konovalov <maxim@FreeBSD.org>

o Check we have a non-NULL pointer to a super block before dereference it.

PR: misc/103822
Submitted by: Dmitry Stefankov
MFC after: 2 weeks


# bee3d34f 25-Feb-2006 David Malone <dwmalone@FreeBSD.org>

The quot command expected all inodes contents to be valid, however
on UFS2 inodes are initialised as they are needed, rather than at
newfs time. When quot encountered these inodes it could produce
crazy results.

Now, on UFS2 filesystems, quot's get_inode function will bzero
unallicated inodes before passing them back to a caller. This is
how UFS2 initialises new inodes, so this should work OK.

Also, while I'm here, make quot exit with an error if it finds
inodes of an unknown type. This should help catch future problems
of this type.

Reviewed by: iedowse
MFC after: 1 week


# 18b51f79 09-Apr-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Remove unused variables.


# b728350e 03-May-2003 David E. O'Brien <obrien@FreeBSD.org>

Use __FBSDID over rcsid[]. Protect copyright[] where needed.


# 6c45bec6 25-Apr-2003 Tim J. Robbins <tjr@FreeBSD.org>

Repair the UFS2 superblock location consistency check so that it succeeds
on valid superblocks instead of issuing the error "not a BSD filesystem".
fs_sblockloc is a byte offset, not a fragment number. This change makes
quot work properly on UFS2 filesystems, which is important now that UFS2
is the default.


# bc6ba9ae 30-Dec-2002 Mike Barcroft <mike@FreeBSD.org>

Back out rev 1.19; getbsize(3)'s original interface has been restored.


# f6a807d6 24-Oct-2002 Andrew Gallatin <gallatin@FreeBSD.org>

another int * to size_t * change for getbsize() to make it compile
on LP64 hosts


# 1c85e6a3 21-Jun-2002 Kirk McKusick <mckusick@FreeBSD.org>

This commit adds basic support for the UFS2 filesystem. The UFS2
filesystem expands the inode to 256 bytes to make space for 64-bit
block pointers. It also adds a file-creation time field, an ability
to use jumbo blocks per inode to allow extent like pointer density,
and space for extended attributes (up to twice the filesystem block
size worth of attributes, e.g., on a 16K filesystem, there is space
for 32K of attributes). UFS2 fully supports and runs existing UFS1
filesystems. New filesystems built using newfs can be built in either
UFS1 or UFS2 format using the -O option. In this commit UFS1 is
the default format, so if you want to build UFS2 format filesystems,
you must specify -O 2. This default will be changed to UFS2 when
UFS2 proves itself to be stable. In this commit the boot code for
reading UFS2 filesystems is not compiled (see /sys/boot/common/ufsread.c)
as there is insufficient space in the boot block. Once the size of the
boot block is increased, this code can be defined.

Things to note: the definition of SBSIZE has changed to SBLOCKSIZE.
The header file <ufs/ufs/dinode.h> must be included before
<ufs/ffs/fs.h> so as to get the definitions of ufs2_daddr_t and
ufs_lbn_t.

Still TODO:
Verify that the first level bootstraps work for all the architectures.
Convert the utility ffsinfo to understand UFS2 and test growfs.
Add support for the extended attribute storage. Update soft updates
to ensure integrity of extended attribute storage. Switch the
current extended attribute interfaces to use the extended attribute
storage. Add the extent like functionality (framework is there,
but is currently never used).

Sponsored by: DARPA & NAI Labs.
Reviewed by: Poul-Henning Kamp <phk@freebsd.org>


# 9f60cc9e 15-May-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Unbreak Alpha build.


# 386f1d1bf 12-May-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Sigh... Yet a BBSIZE breakage.


# 57cdc152 09-Dec-2001 Mike Heffner <mikeh@FreeBSD.org>

WARNS=2 cleanup.

PR: bin/32567
MFC after: 2 weeks


# 81f1ec27 09-Mar-2001 Paul Saab <ps@FreeBSD.org>

Allow for the last arugment to be the mountpoint of a filesystem,
not just the device.


# 1a37aa56 09-Dec-2000 David E. O'Brien <obrien@FreeBSD.org>

Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.


# 5744d836 30-May-2000 Mike Smith <msmith@FreeBSD.org>

/dev/rXXX -> /dev/XXX


# 652b7200 27-Nov-1999 Philippe Charnier <charnier@FreeBSD.org>

Do not repeat the name of the flag. Change alloc to allocate for better
spelling of printed messages.


# 97d92980 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 9983067e 13-Dec-1998 Matthew Dillon <dillon@FreeBSD.org>

PR: bin/8624

Fixed intermediate calculation overflow when reporting users with > 2GB of
disk space.


# b49d184b 17-Jan-1998 Bruce Evans <bde@FreeBSD.org>

Started getting rid of the compatibility cruft for the Lite1 mount()
and the pre-Lite2 vfsconf interfaces.

For quot, just back out revs. 1.1 and 1.2 and change MNT_FFS to
"ufs", so that vfsconf isn't used at all. Revs. 1.1 and 1.2 were
hacks to get around f_fstypename not being in `struct statfs' in
Lite1.


# 6980f0eb 10-Oct-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3). Silent -Wall.


# c9d12677 12-Aug-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Cast argument to lseek() properly to off_t.
PR: 4246
Obtained from: review of PR and NetBSD sources.


# 476602a9 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# c24ee47c 03-Nov-1995 Peter Wemm <peter@FreeBSD.org>

No need to go back quite _that_ far to the MOUNT_UFS constant when we have
a perfectly good getvfsbyname("ufs").. :-)

Pointed out by: wollman and bde


# 696322c8 03-Nov-1995 Peter Wemm <peter@FreeBSD.org>

Minor tweaks to get quot to compile on FreeBSD..
Basically back-port the dynamic fsname strings back to static constants.


# 16c2ba93 03-Nov-1995 Peter Wemm <peter@FreeBSD.org>

Import NetBSD's quot command, filling the gap in our sources
(We only have the man page...)

Obtained from: NetBSD; Wolfgang Solfrank / TooLs GmbH.