2009-01-30 13:54:03 +00:00
|
|
|
.\"-
|
2009-12-28 22:44:19 +00:00
|
|
|
.\" Copyright (c) 2009 Dag-Erling Coïdan Smørgrav and
|
|
|
|
.\" Marshall Kirk McKusick. All rights reserved.
|
2009-01-30 13:54:03 +00:00
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2009-12-28 22:44:19 +00:00
|
|
|
.Dd December 28, 2009
|
2009-01-30 13:54:03 +00:00
|
|
|
.Dt QUOTAFILE 3
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm quota_open
|
2009-11-16 18:59:04 +00:00
|
|
|
.Nm quota_close
|
|
|
|
.Nm quota_on
|
|
|
|
.Nm quota_off
|
|
|
|
.Nm quota_read
|
|
|
|
.Nm quota_write_limits
|
|
|
|
.Nm quota_write_usage
|
2009-09-26 23:16:06 +00:00
|
|
|
.Nm quota_fsname
|
|
|
|
.Nm quota_qfname
|
2009-10-20 05:37:54 +00:00
|
|
|
.Nm quota_maxid
|
2009-09-26 23:16:06 +00:00
|
|
|
.Nm quota_check_path
|
2009-12-28 22:44:19 +00:00
|
|
|
.Nm quota_convert
|
2009-02-14 08:08:08 +00:00
|
|
|
.Nd "Manipulate quotas"
|
2009-01-30 13:54:03 +00:00
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libutil
|
|
|
|
.Sh SYNOPSIS
|
2009-09-26 23:16:06 +00:00
|
|
|
.In sys/param.h
|
|
|
|
.In sys/mount.h
|
2009-01-30 13:54:03 +00:00
|
|
|
.In ufs/ufs/quota.h
|
2009-10-20 05:37:54 +00:00
|
|
|
.In fcntl.h
|
2009-02-14 08:08:08 +00:00
|
|
|
.In fstab.h
|
2009-10-20 05:37:54 +00:00
|
|
|
.In libutil.h
|
2009-01-30 13:54:03 +00:00
|
|
|
.Ft "struct quotafile *"
|
2009-02-14 08:08:08 +00:00
|
|
|
.Fn quota_open "struct fstab *fs" "int quotatype" "int openflags"
|
2009-09-26 23:16:06 +00:00
|
|
|
.Ft int
|
2009-11-16 18:59:04 +00:00
|
|
|
.Fn quota_close "struct quotafile *qf"
|
2009-10-20 05:37:54 +00:00
|
|
|
.Ft int
|
2009-11-16 18:59:04 +00:00
|
|
|
.Fn quota_on "const struct quotafile *qf"
|
|
|
|
.Ft int
|
|
|
|
.Fn quota_off "const struct quotafile *qf"
|
2009-01-30 13:54:03 +00:00
|
|
|
.Ft int
|
2009-02-10 08:11:44 +00:00
|
|
|
.Fn quota_read "struct quotafile *qf" "struct dqblk *dqb" "int id"
|
2009-01-30 13:54:03 +00:00
|
|
|
.Ft int
|
2009-02-14 08:08:08 +00:00
|
|
|
.Fn quota_write_limits "struct quotafile *qf" "struct dqblk *dqb" "int id"
|
2009-01-30 13:54:03 +00:00
|
|
|
.Ft int
|
2009-02-14 08:08:08 +00:00
|
|
|
.Fn quota_write_usage "struct quotafile *qf" "struct dqblk *dqb" "int id"
|
2009-11-16 18:59:04 +00:00
|
|
|
.Ft "const char *"
|
|
|
|
.Fn quota_fsname "const struct quotafile *qf"
|
|
|
|
.Ft "const char *"
|
|
|
|
.Fn quota_qfname "const struct quotafile *qf"
|
2009-02-13 06:17:53 +00:00
|
|
|
.Ft int
|
2009-11-16 18:59:04 +00:00
|
|
|
.Fn quota_maxid "const struct quotafile *qf"
|
|
|
|
.Ft int
|
|
|
|
.Fn quota_check_path "const struct quotafile *qf" "const char *path"
|
2009-12-28 22:44:19 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn quota_convert "struct quotafile *qf" "int wordsize"
|
2009-01-30 13:54:03 +00:00
|
|
|
.Sh DESCRIPTION
|
2009-02-14 08:08:08 +00:00
|
|
|
These functions are designed to simplify access to filesystem quotas.
|
|
|
|
If quotas are active on a filesystem,
|
|
|
|
these functions will access them directly from the kernel using the
|
|
|
|
.Fn quotactl
|
|
|
|
system call.
|
|
|
|
If quotas are not active,
|
|
|
|
these functions will access them by reading and writing
|
|
|
|
the quota files directly.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn quota_open
|
|
|
|
function takes a pointer to an
|
|
|
|
.Vt fstab
|
|
|
|
entry corresponding to the filesystem on which quotas
|
|
|
|
are to be accessed.
|
|
|
|
The
|
|
|
|
.Va quotatype
|
|
|
|
field indicates the type of quotas being sought, either
|
|
|
|
.Dv USRQUOTA
|
|
|
|
or
|
|
|
|
.Dv GRPQUOTA .
|
|
|
|
The
|
|
|
|
.Va openflags
|
|
|
|
are those used by the
|
|
|
|
.Fn open
|
|
|
|
system call, usually either
|
|
|
|
.Dv O_RDONLY
|
|
|
|
if the quotas are just to be read, or
|
|
|
|
.Dv O_RDWR
|
|
|
|
if the quotas are to be updated.
|
|
|
|
The
|
|
|
|
.Dv O_CREAT
|
2009-09-26 23:16:06 +00:00
|
|
|
flag should be specified if a new quota file of the requested type
|
|
|
|
should be created if it does not already exist.
|
|
|
|
.Pp
|
|
|
|
The
|
2009-11-16 18:59:04 +00:00
|
|
|
.Fn quota_close
|
|
|
|
function closes any open file descriptors and frees any storage
|
|
|
|
associated with the filesystem and quota type referenced by
|
|
|
|
.Va qf .
|
2009-09-26 23:16:06 +00:00
|
|
|
.Pp
|
|
|
|
The
|
2009-11-16 18:59:04 +00:00
|
|
|
.Fn quota_on
|
|
|
|
function enables quotas for the filesystem associated with its
|
2009-09-26 23:16:06 +00:00
|
|
|
.Va qf
|
2010-08-16 15:18:30 +00:00
|
|
|
argument which may have been opened with
|
2009-11-16 18:59:04 +00:00
|
|
|
.Dv O_RDONLY
|
|
|
|
or
|
|
|
|
.Dv O_RDWR .
|
2009-09-26 23:16:06 +00:00
|
|
|
The
|
2009-11-16 18:59:04 +00:00
|
|
|
.Fn quota_on
|
|
|
|
function returns 0 if successful;
|
|
|
|
otherwise the value\~-1 is returned and the global variable
|
|
|
|
.Va errno
|
|
|
|
is set to indicate the error, see
|
|
|
|
.Xr quotactl 2
|
|
|
|
for the possible errors.
|
2009-10-20 05:37:54 +00:00
|
|
|
.Pp
|
|
|
|
The
|
2009-11-16 18:59:04 +00:00
|
|
|
.Fn quota_off
|
|
|
|
function disables quotas for the filesystem associated with its
|
2009-09-26 23:16:06 +00:00
|
|
|
.Va qf
|
2010-08-16 15:18:30 +00:00
|
|
|
argument which may have been opened with
|
2009-11-16 18:59:04 +00:00
|
|
|
.Dv O_RDONLY
|
|
|
|
or
|
|
|
|
.Dv O_RDWR .
|
|
|
|
The
|
|
|
|
.Fn quota_off
|
|
|
|
function returns 0 if successful;
|
|
|
|
otherwise the value\~-1 is returned and the global variable
|
|
|
|
.Va errno
|
|
|
|
is set to indicate the error, see
|
|
|
|
.Xr quotactl 2
|
|
|
|
for the possible errors.
|
2009-02-14 08:08:08 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn quota_read
|
2009-11-16 18:59:04 +00:00
|
|
|
function reads the quota from the filesystem and quota type referenced by
|
2009-02-14 08:08:08 +00:00
|
|
|
.Va qf
|
|
|
|
for the user (or group) specified by
|
|
|
|
.Va id
|
|
|
|
into the
|
|
|
|
.Vt dqblk
|
|
|
|
quota structure pointed to by
|
|
|
|
.Va dqb .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn quota_write_limits
|
|
|
|
function updates the limit fields (but not the usage fields)
|
|
|
|
for the filesystem and quota type referenced by
|
|
|
|
.Va qf
|
|
|
|
for the user (or group) specified by
|
|
|
|
.Va id
|
|
|
|
from the
|
|
|
|
.Vt dqblk
|
|
|
|
quota structure pointed to by
|
|
|
|
.Va dqb .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn quota_write_usage
|
|
|
|
function updates the usage fields (but not the limit fields)
|
|
|
|
for the filesystem and quota type referenced by
|
|
|
|
.Va qf
|
|
|
|
for the user (or group) specified by
|
|
|
|
.Va id
|
|
|
|
from the
|
|
|
|
.Vt dqblk
|
|
|
|
quota structure pointed to by
|
|
|
|
.Va dqb .
|
|
|
|
.Pp
|
|
|
|
The
|
2009-11-16 18:59:04 +00:00
|
|
|
.Fn quota_fsname
|
|
|
|
function returns a pointer to a buffer containing the path to the root
|
|
|
|
of the file system that corresponds to its
|
|
|
|
.Va qf
|
|
|
|
argument, as listed in
|
|
|
|
.Pa /etc/fstab .
|
|
|
|
Note that this may be a symbolic link to the actual directory.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn quota_qfname
|
|
|
|
function returns a pointer to a buffer containing the name of the
|
|
|
|
quota file that corresponds to its
|
|
|
|
.Va qf
|
|
|
|
argument.
|
|
|
|
Note that this may be a symbolic link to the actual file.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn quota_maxid
|
|
|
|
function returns the maximum user (or group)
|
|
|
|
.Va id
|
|
|
|
contained in the quota file associated with its
|
|
|
|
.Va qf
|
|
|
|
argument.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn quota_check_path
|
|
|
|
function checks if the specified path is within the filesystem that
|
|
|
|
corresponds to its
|
|
|
|
.Va qf
|
|
|
|
argument.
|
|
|
|
If the
|
|
|
|
.Va path
|
|
|
|
argument refers to a symbolic link,
|
|
|
|
.Fn quota_check_path
|
|
|
|
will follow it.
|
2009-12-28 22:44:19 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn quota_convert
|
|
|
|
function converts the quota file associated with its
|
|
|
|
.Va qf
|
|
|
|
argument to the data size specified by its
|
|
|
|
.Va wordsize
|
|
|
|
argument.
|
|
|
|
The supported wordsize arguments are 32 for the old 32-bit
|
|
|
|
quota file format and 64 for the new 64-bit quota file format.
|
|
|
|
The
|
|
|
|
.Fn quota_convert
|
|
|
|
function may only be called to operate on quota files that
|
|
|
|
are not currently active.
|
2009-09-26 23:16:06 +00:00
|
|
|
.Sh IMPLEMENTATION NOTES
|
2009-12-28 22:44:19 +00:00
|
|
|
If the underlying quota file is in or converted to the old 32-bit format,
|
|
|
|
limit and usage values written to the quota file will be clipped to 32 bits.
|
2009-01-30 13:54:03 +00:00
|
|
|
.Sh RETURN VALUES
|
2009-02-14 08:08:08 +00:00
|
|
|
If the filesystem has quotas associated with it,
|
|
|
|
.Fn quota_open
|
|
|
|
returns a pointer to a
|
|
|
|
.Vt quotafile
|
|
|
|
structure used in subsequent quota access calls.
|
|
|
|
If the filesystem has no quotas, or access permission is denied
|
|
|
|
.Dv NULL
|
|
|
|
is returned and
|
|
|
|
.Va errno
|
2009-09-26 23:16:06 +00:00
|
|
|
is set to indicate the error.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn quota_check_path
|
|
|
|
function returns\~1 for a positive result and\~0 for a negative
|
|
|
|
result.
|
|
|
|
If an error occurs, it returns\~-1 and sets
|
|
|
|
.Va errno
|
|
|
|
to indicate the error.
|
2009-02-14 08:08:08 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn quota_read ,
|
|
|
|
.Fn quota_write_limits ,
|
|
|
|
.Fn quota_write_usage ,
|
2009-12-28 22:44:19 +00:00
|
|
|
.Fn quota_convert ,
|
2009-02-14 08:08:08 +00:00
|
|
|
and
|
|
|
|
.Fn quota_close
|
|
|
|
functions return zero on success.
|
2009-09-26 23:16:06 +00:00
|
|
|
On error they return\~-1
|
2009-02-14 08:08:08 +00:00
|
|
|
and set
|
|
|
|
.Va errno
|
2009-09-26 23:16:06 +00:00
|
|
|
to indicate the error.
|
2009-01-30 13:54:03 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr quotactl 2 ,
|
|
|
|
.Xr quota.user 5 ,
|
|
|
|
.Xr quota.group 5
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
2009-12-28 22:44:19 +00:00
|
|
|
.Nm quotafile
|
2009-01-30 13:54:03 +00:00
|
|
|
functions first appeared in
|
2009-12-28 22:44:19 +00:00
|
|
|
.Fx 8.1 .
|
2009-01-30 13:54:03 +00:00
|
|
|
.Sh AUTHORS
|
|
|
|
.An -nosplit
|
|
|
|
The
|
2009-12-28 22:44:19 +00:00
|
|
|
.Nm quotafile
|
2009-01-30 13:54:03 +00:00
|
|
|
functions and this manual page were written by
|
2009-02-14 08:08:08 +00:00
|
|
|
.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org
|
|
|
|
and
|
2009-11-16 18:59:04 +00:00
|
|
|
.An Marshall Kirk McKusick Aq mckusick@mckusick.com .
|