History log of /freebsd-current/usr.bin/quota/quota.c
Revision Date Author Comments
# 5e3934b1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: 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


# 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


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

usr.bin: 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/


# 1a7ac2bd 07-Jul-2023 Alfonso Gregory <gfunni234@gmail.com>

Mark usage function as __dead2 in programs where it does not return

In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

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


# 04389c85 08-Aug-2021 Gordon Bergling <gbe@FreeBSD.org>

Fix some common typos in comments

- s/configuraiton/configuration/
- s/specifed/specified/
- s/compatiblity/compatibility/

MFC after: 5 days


# 740a5434 20-Sep-2019 Hiroki Sato <hrs@FreeBSD.org>

Add a workaround for servers which respond RPC_PROGNOTREGISTERED
to a clnt_create() call even when it is actually a program
version mismatch.

Normally the server is supposed to return RPC_PROGVERSMISMATCH
when it supports the specified program but not support
the specified version. Some filers return RPC_PROGNOTREGISTERED
to RQUOTA v2 calls and FreeBSD does not retry with the old
v1 calls. This change fixes this failure scenario.

Submitted by: Jian-Bo Liao
PR: 236179


# aad5531e 05-Jul-2018 Sean Eric Fagan <sef@FreeBSD.org>

This exposes ZFS user and group quotas via the normal
quatactl(2) mechanism. (Read-only at this point, however.)
In particular, this is to allow rpc.rquotad query quotas
for NFS mounts, allowing users to see their quotas on the
hosts using the datasets.

The changes specifically:

* Add new RPC entry points for querying quotas.
* Changes the library routines to allow non-UFS quotas.
* Changes rquotad to check for quotas on mounted filesystems,
rather than being limited to entries in /etc/fstab
* Lastly, adds a VFS entry-point for ZFS to query quotas.

Note that this makes one unavoidable behavioural change: if quotas
are enabled, then they can be queried, as opposed to the current
method of checking for quotas being specified in fstab. (With
ZFS, if there are user or group quotas, they're used, always.)

Reviewed by: delphij, mav
Approved by: mav
Sponsored by: iXsystems Inc
Differential Revision: https://reviews.freebsd.org/D15886


# 404d2fee 16-Apr-2018 Conrad Meyer <cem@FreeBSD.org>

quota(1): Fix calculation overflow and underflow

For very large quotas, do the multiplication as a 64 bit value to avoid
overflow.

For very small block sizes (smaller than DEV_BSIZE), multiple first
before dividing by block size to avoid underflow.

PR: 227496
Submitted by: Per Andersson <pa AT chalmers.se>
Sponsored by: Dell EMC Isilon


# 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


# a3010446 26-Apr-2016 Marcelo Araujo <araujo@FreeBSD.org>

Use MIN() macro from sys/param.h.

MFC after: 2 weeks.


# 754f368c 07-Jul-2015 Hiroki Sato <hrs@FreeBSD.org>

- Add IPv6 support in quota(1). While rpc.rquotad has supported PF_INET6
for a long time, quota(1) utility supported only PF_INET.

- Clean up confusing changes in f_mntfromname.

- Add an entry for rquotad with rpc/udp6 to inetd.conf.

PR: 194084


# 865ff609 06-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Add missing static keywords to quota(1)


# 2f39985f 30-Jun-2011 Sergey Kandaurov <pluknet@FreeBSD.org>

Fix quota(1) output.

- Fix calculation of 1024-byte sized blocks from disk blocks shown when -h
option isn't specified. It was broken with quota64 integration.
- In prthumanval(): limit the size of a buffer passed to humanize_number()
to a width of 5 bytes but allow a shorter length if requested. That's what
users expect.

PR: bin/150151
Reviewed by: Kirk McKusick


# da52b4ca 11-Dec-2010 Joel Dahl <joel@FreeBSD.org>

Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with: imp, rwatson


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


# 829b3f6b 04-Mar-2010 Dag-Erling Smørgrav <des@FreeBSD.org>

Fix warnings + minor style issues


# 37ed8e48 20-Oct-2009 Kirk McKusick <mckusick@FreeBSD.org>

Update to work with quotafile functions in -libutil.


# 54404cfb 19-Jun-2009 Brooks Davis <brooks@FreeBSD.org>

In preparation for raising NGROUPS and NGROUPS_MAX, change base
system callers of getgroups(), getgrouplist(), and setgroups() to
allocate buffers dynamically. Specifically, allocate a buffer of size
sysconf(_SC_NGROUPS_MAX)+1 (+2 in a few cases to allow for overflow).

This (or similar gymnastics) is required for the code to actually follow
the POSIX.1-2008 specification where {NGROUPS_MAX} may differ at runtime
and where getgroups may return {NGROUPS_MAX}+1 results on systems like
FreeBSD which include the primary group.

In id(1), don't pointlessly add the primary group to the list of all
groups, it is always the first result from getgroups(). In principle
the old code was more portable, but this was only done in one of the two
places where getgroups() was called to the overall effect was pointless.

Document the actual POSIX requirements in the getgroups(2) and
setgroups(2) manpages. We do not yet support a dynamic NGROUPS, but we
may in the future.

MFC after: 2 weeks


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

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


# 61328d7a 03-Aug-2008 Xin LI <delphij@FreeBSD.org>

Make quota(1) to compile with WARNS=6:
- ANSI'fy showrawquotas().
- Shut up GCC by initializing bgrace and igrace. The situation
that caused the GCC warning can never happen though.


# 049aa2e8 03-Aug-2008 Olivier Houchard <cognet@FreeBSD.org>

ctime() expects a time_t, but qup->dqblk.dqb_btime is an int32_t, so for
big endian platforms where time_t is 64bits (ie armeb and sparc64), it will
be a problem.
Use a temporary time_t to work around this.

Submitted by: Matthew Luckie <mjl AT luckie DOT org dot nz>
MFC after: 3 days


# df272553 17-Feb-2008 Mike Pritchard <mpp@FreeBSD.org>

Make the human readable numbers printed with the -h option a bit
more human readable by telling the human print routines to use
a smaller buffer to format the value.

This makes it so a value that was previously being printed
as 600000K will now print as 586M.


# 2ffe6bbf 06-May-2007 David Malone <dwmalone@FreeBSD.org>

Use [u]intmax_t to printf unknown integer types.
Make timeprt always allocate memory, to make things a little simpler.
Remove an unused variable.


# f3aad16b 23-Apr-2007 Yaroslav Tykhiy <ytykhiy@gmail.com>

Insert explicit space between the output fields to prevent them
from running together when a field overflows.

MFC after: 1 week


# 2e1f5ad9 11-Feb-2007 Mike Pritchard <mpp@FreeBSD.org>

Add two new options to quota:

-f path
Only print quota information for the file system that path resides on.
-r
Display the quota information in a raw format.

Reviewed by: freebsd-hackers


# f5374712 04-Feb-2007 Mike Pritchard <mpp@FreeBSD.org>

If a user is over both the soft block limit and soft i-node
limit, quota will report one of the grace times incorrectly.
This is due to it storing the result in a static buffer, and the
routine being called like:
printf("....", ..., timeprnt(btime), timeprnt(itime), ...)

The problem becomes very obvious if you change one of the default
grace periods to be much larger than the other one.

Changed timeprnt to dynamically allocate the string to be displayed.


# 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


# dfaa8068 01-Feb-2007 Mike Pritchard <mpp@FreeBSD.org>

Make quota exit with a non-zero status if one more more file
systems are over quota, as documented in the man page.

PR: bin/77918


# 478bf774 21-Oct-2006 Ruslan Ermilov <ru@FreeBSD.org>

- Document the default disk block usage unit.
- Add option -h, human-readable output.

PR: docs/53732


# 009cb168 13-Mar-2005 Ceri Davies <ceri@FreeBSD.org>

Remove an unused #define. md5's with and without this commit match.

Approved by: murray (mentor)


# 4e14c144 07-Aug-2004 Stefan Farfeleder <stefanf@FreeBSD.org>

Assign the result of getopt() to an int rather than to a char.


# 09a6b6c3 05-Aug-2003 David Schultz <das@FreeBSD.org>

Remove redundant declarations.


# 923e62f9 05-Aug-2003 David Schultz <das@FreeBSD.org>

Don't overflow the block quota calculations for NFS mounts.

PR: 47607
Submitted by: Eric van Gyzen <vangyzen@stat.duke.edu>


# aee1b42a 15-Jun-2003 Robert Watson <rwatson@FreeBSD.org>

Now that the kernel access control for quotactl(2) appears to work
properly, clean up quota(1). quota(1) has the ability to query
quotas either directly from the kernel, or if that fails, by reading
the quota.user or quota.group files specified for the file system
in /etc/fstab. The setuid bit existed solely (apparently) to let
non-operator users query their quotas and consumption when quotas
weren't enabled for the file system.

o Remove the setuid bit from quota(1).

o Remove the logic used by quota(1) when running setuid to prevent
users from querying the quotas of other users or groups. Note
that this papered over previously broken kernel access control;
if you queried directly using the system call, you could access
some of the data "restricted" by quota(1).

In the new world order, the ability to inspect the (live) quotas of
other uids and gids via the kernel is controlled by the privilege
requirement sysctl. The ability to query via the file is controlled
by the file permissions on the quota database backing files
(root:operator, group readable by default).


# 41b0d1a0 15-Jun-2003 Robert Watson <rwatson@FreeBSD.org>

Now that the kernel access control for quotactl(2) appears to work
properly, clean up quota(1). quota(1) has the ability to query
quotas either directly from the kernel, or if that fails, by reading
the quota.user or quota.group files specified for the file system
in /etc/fstab. The setuid bit existed solely (apparently) to let
non-operator users query their quotas and consumption when quotas
weren't enabled for the file system.

o Remove the setuid bit from quota(1).

o Remove the logic used by quota(1) when running setuid to prevent
users from querying the quotas of other users or groups. Note
that this papered over previously broken kernel access control.


# e56990e4 08-Aug-2002 Ian Dowse <iedowse@FreeBSD.org>

Add a new flag (-l) that suppresses quota checks on NFS filesystems.

PR: bin/12939
Submitted by: Neil Blakey-Milner <nbm@rucus.ru.ac.za>


# e608ec61 08-Aug-2002 Ian Dowse <iedowse@FreeBSD.org>

Fix a few compiler warnings, sort options and make the usage()
output match the synopsis.


# ab5ff6a6 02-Jun-2002 Ian Dowse <iedowse@FreeBSD.org>

Call getmntinfo with MNT_NOWAIT to avoid hanging if any NFS servers
are down. Avoid trying to send RPCs to the pidXXX@machine names
used in the special amd(8) mounts.

PR: bin/6183
Submitted by: Petr Lampa <lampa@fee.vutbr.cz>


# ff288009 28-Apr-2002 Mark Murray <markm@FreeBSD.org>

Fix some low-hanging fruit in the warnings department; ANSIfy functions,
sort out some const issues.


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

remove __P


# 44501248 23-May-2001 Jim Pirzyk <pirzyk@FreeBSD.org>

Changed 'blocks' to 'usage' because we may not be getting quotas from
a ufs filesystem and it may be reporting in K instead of 512b blocks.
This is true when using a vxfs filesystem (on a solaris box) for instance.

PR: bin/14545
Submitted by: Jim Pirzyk
Reviewed by: jkh
MFC after: 1 week


# b189011d 26-Mar-2000 Philippe Charnier <charnier@FreeBSD.org>

Remove incorrect use of .Nm. Wrap long lines, Unwrap short lines
Options: -> The following options are available:


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

$Id$ -> $FreeBSD$


# abf0f067 10-Jun-1998 Andrey A. Chernov <ache@FreeBSD.org>

Local filesystems are ufs not ffs
Submitted by: "D. Rock" <rock@cs.uni-sb.de>


# a716ad66 08-Jun-1998 Warner Losh <imp@FreeBSD.org>

Don't assume that hp->h_lenght == 4. Be conservative in its use.
Submitted by: J. Assange a long time ago.


# d63b9ba4 19-Jan-1998 Bruce Evans <bde@FreeBSD.org>

Converted to Lite2 mount interface - decide filesystem types by name
instead of by number.


# 9d63ad49 04-Aug-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3). Cosmetic in usage string. Typo in man page.


# c44252b6 06-Jul-1997 Bruce Evans <bde@FreeBSD.org>

Finish importing Lite2's src/usr.bin, except for ex, diff, grep, mail,
pascal and vmstat.sparc. All changed files on the vendor branch should
already have been imported.


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


# 77ae30e9 14-Jun-1996 Alexander Langer <alex@FreeBSD.org>

Code clean up. Prototypes, casting, and parentheses around assignments
used as truth value.


# 1d00bf00 09-Jan-1996 Thomas Graichen <graichen@FreeBSD.org>

fixed some printf format mismatches and some lines exceeding 80 col's
(thanks to bruce)


# 9288f266 05-Jan-1996 Thomas Graichen <graichen@FreeBSD.org>

Obtained from: NetBSD
replaced our quota with the NetBSD one, then added all changes we made
to our - this is done to support the displaying of quota's over nfs
using the rpc.rquotad


# da2aae3b 07-May-1995 Bruce Evans <bde@FreeBSD.org>

Fix 3 fatal mismatches in format args involving dbtob() and 10 nonfatal
mismatches.


# 9b50d902 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite Usr.bin Sources