mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
Add and document new quoat_on and quota_off functions.
This commit is contained in:
parent
708a2897f1
commit
e525d16a80
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/quota64/; revision=199328
|
@ -144,6 +144,9 @@ int pidfile_remove(struct pidfh *pfh);
|
||||||
struct quotafile;
|
struct quotafile;
|
||||||
struct fstab;
|
struct fstab;
|
||||||
struct quotafile *quota_open(struct fstab *, int, int);
|
struct quotafile *quota_open(struct fstab *, int, int);
|
||||||
|
void quota_close(struct quotafile *);
|
||||||
|
int quota_on(struct quotafile *);
|
||||||
|
int quota_off(struct quotafile *);
|
||||||
const char *quota_fsname(const struct quotafile *);
|
const char *quota_fsname(const struct quotafile *);
|
||||||
const char *quota_qfname(const struct quotafile *);
|
const char *quota_qfname(const struct quotafile *);
|
||||||
int quota_maxid(struct quotafile *);
|
int quota_maxid(struct quotafile *);
|
||||||
|
@ -151,7 +154,6 @@ int quota_check_path(const struct quotafile *, const char *path);
|
||||||
int quota_read(struct quotafile *, struct dqblk *, int);
|
int quota_read(struct quotafile *, struct dqblk *, int);
|
||||||
int quota_write_limits(struct quotafile *, struct dqblk *, int);
|
int quota_write_limits(struct quotafile *, struct dqblk *, int);
|
||||||
int quota_write_usage(struct quotafile *, struct dqblk *, int);
|
int quota_write_usage(struct quotafile *, struct dqblk *, int);
|
||||||
void quota_close(struct quotafile *);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
|
@ -30,14 +30,16 @@
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm quota_open
|
.Nm quota_open
|
||||||
|
.Nm quota_close
|
||||||
|
.Nm quota_on
|
||||||
|
.Nm quota_off
|
||||||
|
.Nm quota_read
|
||||||
|
.Nm quota_write_limits
|
||||||
|
.Nm quota_write_usage
|
||||||
.Nm quota_fsname
|
.Nm quota_fsname
|
||||||
.Nm quota_qfname
|
.Nm quota_qfname
|
||||||
.Nm quota_maxid
|
.Nm quota_maxid
|
||||||
.Nm quota_check_path
|
.Nm quota_check_path
|
||||||
.Nm quota_read
|
|
||||||
.Nm quota_write_limits
|
|
||||||
.Nm quota_write_usage
|
|
||||||
.Nm quota_close
|
|
||||||
.Nd "Manipulate quotas"
|
.Nd "Manipulate quotas"
|
||||||
.Sh LIBRARY
|
.Sh LIBRARY
|
||||||
.Lb libutil
|
.Lb libutil
|
||||||
|
@ -50,6 +52,18 @@
|
||||||
.In libutil.h
|
.In libutil.h
|
||||||
.Ft "struct quotafile *"
|
.Ft "struct quotafile *"
|
||||||
.Fn quota_open "struct fstab *fs" "int quotatype" "int openflags"
|
.Fn quota_open "struct fstab *fs" "int quotatype" "int openflags"
|
||||||
|
.Ft int
|
||||||
|
.Fn quota_close "struct quotafile *qf"
|
||||||
|
.Ft int
|
||||||
|
.Fn quota_on "const struct quotafile *qf"
|
||||||
|
.Ft int
|
||||||
|
.Fn quota_off "const struct quotafile *qf"
|
||||||
|
.Ft int
|
||||||
|
.Fn quota_read "struct quotafile *qf" "struct dqblk *dqb" "int id"
|
||||||
|
.Ft int
|
||||||
|
.Fn quota_write_limits "struct quotafile *qf" "struct dqblk *dqb" "int id"
|
||||||
|
.Ft int
|
||||||
|
.Fn quota_write_usage "struct quotafile *qf" "struct dqblk *dqb" "int id"
|
||||||
.Ft "const char *"
|
.Ft "const char *"
|
||||||
.Fn quota_fsname "const struct quotafile *qf"
|
.Fn quota_fsname "const struct quotafile *qf"
|
||||||
.Ft "const char *"
|
.Ft "const char *"
|
||||||
|
@ -58,14 +72,6 @@
|
||||||
.Fn quota_maxid "const struct quotafile *qf"
|
.Fn quota_maxid "const struct quotafile *qf"
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fn quota_check_path "const struct quotafile *qf" "const char *path"
|
.Fn quota_check_path "const struct quotafile *qf" "const char *path"
|
||||||
.Ft int
|
|
||||||
.Fn quota_read "struct quotafile *qf" "struct dqblk *dqb" "int id"
|
|
||||||
.Ft int
|
|
||||||
.Fn quota_write_limits "struct quotafile *qf" "struct dqblk *dqb" "int id"
|
|
||||||
.Ft int
|
|
||||||
.Fn quota_write_usage "struct quotafile *qf" "struct dqblk *dqb" "int id"
|
|
||||||
.Ft int
|
|
||||||
.Fn quota_close "struct quotafile *qf"
|
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
These functions are designed to simplify access to filesystem quotas.
|
These functions are designed to simplify access to filesystem quotas.
|
||||||
If quotas are active on a filesystem,
|
If quotas are active on a filesystem,
|
||||||
|
@ -103,6 +109,81 @@ flag should be specified if a new quota file of the requested type
|
||||||
should be created if it does not already exist.
|
should be created if it does not already exist.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
|
.Fn quota_close
|
||||||
|
function closes any open file descriptors and frees any storage
|
||||||
|
associated with the filesystem and quota type referenced by
|
||||||
|
.Va qf .
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn quota_on
|
||||||
|
function enables quotas for the filesystem associated with its
|
||||||
|
.Va qf
|
||||||
|
argument which may have been opened
|
||||||
|
.Dv O_RDONLY
|
||||||
|
or
|
||||||
|
.Dv O_RDWR .
|
||||||
|
The
|
||||||
|
.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.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn quota_off
|
||||||
|
function disables quotas for the filesystem associated with its
|
||||||
|
.Va qf
|
||||||
|
argument which may have been opened
|
||||||
|
.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.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn quota_read
|
||||||
|
function reads the quota from the filesystem and quota type referenced by
|
||||||
|
.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
|
||||||
.Fn quota_fsname
|
.Fn quota_fsname
|
||||||
function returns a pointer to a buffer containing the path to the root
|
function returns a pointer to a buffer containing the path to the root
|
||||||
of the file system that corresponds to its
|
of the file system that corresponds to its
|
||||||
|
@ -138,48 +219,6 @@ If the
|
||||||
argument refers to a symbolic link,
|
argument refers to a symbolic link,
|
||||||
.Fn quota_check_path
|
.Fn quota_check_path
|
||||||
will follow it.
|
will follow it.
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fn quota_read
|
|
||||||
function reads the quota from the filesystem and quota type referenced
|
|
||||||
by
|
|
||||||
.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
|
|
||||||
.Fn quota_close
|
|
||||||
function closes any open file descriptors and frees any storage
|
|
||||||
associated with the filesystem and quota type referenced by
|
|
||||||
.Va qf .
|
|
||||||
.Sh IMPLEMENTATION NOTES
|
.Sh IMPLEMENTATION NOTES
|
||||||
If the underlying quota file is in the old 32-bit format, limit and
|
If the underlying quota file is in the old 32-bit format, limit and
|
||||||
usage values written to the quota file will be clipped to 32 bits.
|
usage values written to the quota file will be clipped to 32 bits.
|
||||||
|
@ -230,4 +269,4 @@ The
|
||||||
functions and this manual page were written by
|
functions and this manual page were written by
|
||||||
.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org
|
.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org
|
||||||
and
|
and
|
||||||
.An Marshall Kirk McKusick .
|
.An Marshall Kirk McKusick Aq mckusick@mckusick.com .
|
||||||
|
|
|
@ -61,7 +61,6 @@ static const char *qfextension[] = INITQFNAMES;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check to see if a particular quota is to be enabled.
|
* Check to see if a particular quota is to be enabled.
|
||||||
* XXX merge into quota_open
|
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
hasquota(struct fstab *fs, int type, char *qfnamep, int qfbufsize)
|
hasquota(struct fstab *fs, int type, char *qfnamep, int qfbufsize)
|
||||||
|
@ -73,7 +72,6 @@ hasquota(struct fstab *fs, int type, char *qfnamep, int qfbufsize)
|
||||||
static char initname, usrname[100], grpname[100];
|
static char initname, usrname[100], grpname[100];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX
|
|
||||||
* 1) we only need one of these
|
* 1) we only need one of these
|
||||||
* 2) fstab may specify a different filename
|
* 2) fstab may specify a different filename
|
||||||
*/
|
*/
|
||||||
|
@ -207,6 +205,22 @@ quota_close(struct quotafile *qf)
|
||||||
free(qf);
|
free(qf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
quota_on(struct quotafile *qf)
|
||||||
|
{
|
||||||
|
int qcmd;
|
||||||
|
|
||||||
|
qcmd = QCMD(Q_QUOTAON, qf->quotatype);
|
||||||
|
return (quotactl(qf->fsname, qcmd, 0, qf->qfname));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
quota_off(struct quotafile *qf)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (quotactl(qf->fsname, QCMD(Q_QUOTAOFF, qf->quotatype), 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
quota_fsname(const struct quotafile *qf)
|
quota_fsname(const struct quotafile *qf)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue