History log of /freebsd-current/sbin/quotacheck/quotacheck.c
Revision Date Author Comments
# 0b8224d1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

Remove copyright strings ifdef'd out

We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by: Netflix


# 51e16cb8 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

sbin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

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


# 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


# 37e18df3 16-Jun-2018 Eitan Adler <eadler@FreeBSD.org>

quotacheck: build with WARNS=3

WARNS++

Tested with amd64, arm64, i386, mips


# 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


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

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.


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# 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


# f8358c11 15-May-2016 Marcelo Araujo <araujo@FreeBSD.org>

For pointers use NULL instead of 0.

MFC after: 2 weeks.


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

Fix sbin/ build with a 64-bit ino_t.

Original code by: Gleb Kurtsou


# 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.


# 46d2decf 28-Dec-2009 Kirk McKusick <mckusick@FreeBSD.org>

Add the -c option to quotacheck to use the quota_convert(3) function to
convert between quota file formats.


# 3af26d4a 26-Dec-2009 Kirk McKusick <mckusick@FreeBSD.org>

Convert quotacheck to use new quotafile functions in libutil.
Still to come, conversion between 64-bit and 32-bit quotafile formats.


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

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


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

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


# 3b9401db 25-Jan-2008 Mike Pritchard <mpp@FreeBSD.org>

Sync up quotacheck's preen.c with fsck's. This makes quotacheck
process parallel checks in the same way as fsck, since fsck supports
pass numbers other than 0, 1 or 2. Without this, quotacheck would
ignore file systems with pass numbers > 2.

The -l (maxrun) option is now deprecated and can be tuned with pass
numbers in /etc/fstab if needed.


# eee55ebd 14-Jan-2008 Mike Pritchard <mpp@FreeBSD.org>

Quotacheck may possibly skip quota accounting for up to 2 files
on a filesystem if the quota data files reside on a different
filesystem (e.g. the userquota=/somepath,groupquota=/somepath2
options are specified in /etc/fstab to place the quota files
somewhere other than the default location).

Fix quotacheck to only skip accounting if the quota data file
actually resides on the filesystem being checked.


# 4e41e905 13-Sep-2007 Mike Pritchard <mpp@FreeBSD.org>

Flush stdout at the end of the update phase to prevent possible
duplicate output when "quotacheck -a -v" is used.

Approved by: re (bmah)


# fbb42904 03-Feb-2007 Mike Pritchard <mpp@FreeBSD.org>

If two files systems, /a and /b are marked as having quotas enabled
in fstab and they are normally mounted as /a/b, if /b is not mounted,
the various quota utilities will incorrectly operate with the quotas on
/a (silently) when operations are attemted on /b.

Sync up all the hasquota() routines between all the different
quota utilities and change it to detect if the file system we are
attempting to perform quota operations on is not currently mounted
and warn the user accordingly.

PR: bin/38918


# db957a6f 03-Feb-2007 Mike Pritchard <mpp@FreeBSD.org>

Do not touch the block or i-node grace times for id 0.
These are used to indicate the default grace period for
the file system, and should not be touched by quotacheck.


# 952a9714 03-Feb-2007 Mike Pritchard <mpp@FreeBSD.org>

Fix quotqcheck to correctly use the curinode count, and not the
curblock count when checking if the inode soft limit has been
crossed.


# 37675524 22-Jan-2007 Mike Pritchard <mpp@FreeBSD.org>

Use fseeko to seek in the file, instead of fseek to prevent seek
errors for extremely large uids (e.g. in the billions range).


# b32c2af1 22-Jan-2007 Mike Pritchard <mpp@FreeBSD.org>

Make sure that unknown uids/gids that now have non-zero usage and
had a previously recorded usage of zero are correctly displayed in
verbose mode. Generalize the print routine a little too.


# f01beaa6 19-Jan-2007 Mike Pritchard <mpp@FreeBSD.org>

Quota system cleanup.

1) Do not account for uids/gids that appear negative to prevent
the creation of 131GB+ quota files. This is the same as the kernel
now determines which files to provide quota accounting for.
Related to PR kern/38156. This should also prevent boots from
hanging if a negative uid appears in the file systems.
2) Do not count system files in the usage counts. These currently are
file system snapshot and quota data files. This is how the kernel
now handles those files.
3) Correctly generate new quota data files if the current files
do not exist or are zero length in size. PR kern/30958.
It should now be possible to newfs / mount / touch quota.{user,group}
and quotaon a file system and have everything work.
4) Change some diagnostics to report the file system and type of
id (uid or gid) that is being reported.
5) Truncate the quota data files if possible, instead of letting
them grow to a big enough size to hold the largest UID/GID on
the system (typically "nobody"). The kernel should now be able to
grow the files as needed without deadlocking the system.

PR: kern/30958, kern/38156


# bbb83feb 07-Nov-2006 Ceri Davies <ceri@FreeBSD.org>

Document the -l option.

Reviewed by: brd
Approved by: ru (mentor)


# 8d646af5 10-Feb-2005 Ruslan Ermilov <ru@FreeBSD.org>

Sync program's usage() with manpage's SYNOPSIS.


# 4c723140 09-Apr-2004 Mark Murray <markm@FreeBSD.org>

Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core, imp


# 5cfe0423 22-Jan-2004 Peter Grehan <grehan@FreeBSD.org>

Userland signed char fixes for PPC build. Problems were using a char
return for getopt() and comparing to -1, ditto with fgetc() and EOF,
and using the kg_nice value from <sys/user.h>

Submitted by: Stefan Farfeleder <stefan@fafoe.narf.at>
Reviewed by: obrien, bde (a while back)
Tested lightly on: ppc, i386, make universe


# 534734ed 06-Aug-2003 Warner Losh <imp@FreeBSD.org>

Prefer PATH_MAX to MAXPATHLEN. Both contain the trailing NUL, so
remove the unneeded +1.


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

Use __FBSDID() to quiet GCC 3.3 warnings.


# ada981b2 26-Nov-2002 Kirk McKusick <mckusick@FreeBSD.org>

Create a new 32-bit fs_flags word in the superblock. Add code to move
the old 8-bit fs_old_flags to the new location the first time that the
filesystem is mounted by a new kernel. One of the unused flags in
fs_old_flags is used to indicate that the flags have been moved.
Leave the fs_old_flags word intact so that it will work properly if
used on an old kernel.

Change the fs_sblockloc superblock location field to be in units
of bytes instead of in units of filesystem fragments. The old units
did not work properly when the fragment size exceeeded the superblock
size (8192). Update old fs_sblockloc values at the same time that
the flags are moved.

Suggested by: BOUWSMA Barry <freebsd-misuser@netscum.dyndns.dk>
Sponsored by: DARPA & NAI Labs.


# a5a82fa8 19-Nov-2002 Kirk McKusick <mckusick@FreeBSD.org>

Properly handle UFS2 sparsely allocated inodes. Fix bug that caused
the error "quotacheck: bad inode number 1 to nextinode".

Sponsored by: DARPA & NAI Labs.
Reported-by: Franky <franky@jasna.tarnow.pl> and Matthew Kolb <muk@msu.edu>


# 5af4935a 26-Aug-2002 Tom Rhodes <trhodes@FreeBSD.org>

Fix some 'SYNOPSIS' and 'usage' messages.


# ce66ddb7 21-Aug-2002 Tom Rhodes <trhodes@FreeBSD.org>

s/filesystem/file system/g as discussed on -developers


# 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>


# 3468b317 15-May-2002 Tom Rhodes <trhodes@FreeBSD.org>

more file system > filesystem


# 75766e17 12-May-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Sigh, more BBSIZE related breakage.

Sponsored by: DARPA & NAI Labs.


# d476a036 21-Mar-2002 Warner Losh <imp@FreeBSD.org>

o remove __P
o remove main prototype


# 6b67c2ee 25-Jan-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Fix some function prototypes.
Cure the "lets put everything in registers" ailment.
Set WARNS=2
Fix two problems where casting messed up large quotafiles.

PR: 34108
Submitted by: Maxim Katargin <kmv@asplinux.ru>
MFC after: 3 weeks


# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 25f014db 15-Jul-1998 Philippe Charnier <charnier@FreeBSD.org>

Correct use of .Nm. Add rcsid. Remove unused #includes. Use warn().
Errx(1, "malloc failed") is better than err(1, NULL).


# ca46ad5f 28-Jun-1998 Bruce Evans <bde@FreeBSD.org>

Fixed printf format errors.


# 41e964cb 30-Jun-1997 Philippe Charnier <charnier@FreeBSD.org>

Remove lines inside #ifdef 0/#endif.


# 441f9207 16-Jun-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3) instead of local err() (a errx() like function).


# 8d64695c 28-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 1811bdf3 11-Mar-1997 Peter Wemm <peter@FreeBSD.org>

Import some CSRG 4.4BSD-Lite2 components for sbin onto vendor branch.
(note that some of these have already been imported, this is a no-op)


# 22329515 27-Feb-1996 Mike Pritchard <mpp@FreeBSD.org>

Silence some cc -Wall warnings in quotacheck.


# 93b5f489 26-Feb-1996 Mike Pritchard <mpp@FreeBSD.org>

Fix quotacheck to not do a bunch of unneeded fseeks if the
quota file information is accurate. This makes it about twice as
fast when the uid name space is very large.


# 1ba797fb 21-Feb-1996 Mike Pritchard <mpp@FreeBSD.org>

Print out an informative message if the verbose option is given
and an unknown uid/gid is found in the file system. This is useful
if you wind up with a file in your file system that has a uid
that is extremely large, since quotacheck will wind up running
a very very long time due to it not handling large gaps in uids
very well (this is a problem that should be addressed some day).

Update the man page to reflect that fact the the -v flag now prints
some additional diagnostic messages.


# 78f93454 20-Jun-1995 Dima Ruban <dima@FreeBSD.org>

`dev_bsize' must be reset to 1 before the bread() or
quotacheck -a will fail after the first partition (because
dev_bsize is 512 and is messes up the superblock read of the second
partition)

Submitted by: dillon@best.com (Mattew Dillon)


# 8fae3551 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite sbin Sources

Note: XNSrouted and routed NOT imported here, they shall be imported with
usr.sbin.