1996-01-05 08:47:12 +00:00
|
|
|
/*
|
|
|
|
* by Manuel Bouyer (bouyer@ensta.fr)
|
2008-11-04 14:17:49 +00:00
|
|
|
*
|
1996-01-05 08:47:12 +00:00
|
|
|
* There is no copyright, you can use it as you want.
|
|
|
|
*/
|
|
|
|
|
2008-11-04 14:17:49 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
1997-11-26 07:31:14 +00:00
|
|
|
|
1996-01-05 08:47:12 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/socket.h>
|
2008-11-04 14:17:49 +00:00
|
|
|
|
|
|
|
#include <ufs/ufs/quota.h>
|
|
|
|
#include <rpc/rpc.h>
|
|
|
|
#include <rpcsvc/rquota.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <netdb.h>
|
1996-01-05 08:47:12 +00:00
|
|
|
|
|
|
|
#include <ctype.h>
|
1997-11-26 07:31:14 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <fstab.h>
|
|
|
|
#include <grp.h>
|
2009-01-30 13:54:03 +00:00
|
|
|
#include <libutil.h>
|
1997-11-26 07:31:14 +00:00
|
|
|
#include <pwd.h>
|
2008-11-04 14:17:49 +00:00
|
|
|
#include <signal.h>
|
1997-11-26 07:31:14 +00:00
|
|
|
#include <stdio.h>
|
1996-01-05 08:47:12 +00:00
|
|
|
#include <stdlib.h>
|
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
2018-07-05 22:56:13 +00:00
|
|
|
#include <err.h>
|
1996-01-05 08:47:12 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <syslog.h>
|
2008-11-04 14:17:49 +00:00
|
|
|
#include <unistd.h>
|
1996-01-05 08:47:12 +00:00
|
|
|
|
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
2018-07-05 22:56:13 +00:00
|
|
|
static void rquota_service_1(struct svc_req *request, SVCXPRT *transp);
|
|
|
|
static void rquota_service_2(struct svc_req *request, SVCXPRT *transp);
|
2009-09-26 23:05:01 +00:00
|
|
|
static void sendquota(struct svc_req *request, SVCXPRT *transp);
|
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
2018-07-05 22:56:13 +00:00
|
|
|
static void sendquota_extended(struct svc_req *request, SVCXPRT *transp);
|
|
|
|
static int getfsquota(int type, long id, char *path, struct dqblk *dqblk);
|
1996-01-05 08:47:12 +00:00
|
|
|
|
2009-09-26 23:05:01 +00:00
|
|
|
static int from_inetd = 1;
|
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
2018-07-05 22:56:13 +00:00
|
|
|
static int debug = 0;
|
1996-01-05 08:47:12 +00:00
|
|
|
|
2008-11-04 14:17:49 +00:00
|
|
|
static void
|
2002-02-07 05:24:53 +00:00
|
|
|
cleanup(int sig)
|
1996-01-05 08:47:12 +00:00
|
|
|
{
|
2008-11-04 14:17:49 +00:00
|
|
|
|
2009-09-25 22:20:30 +00:00
|
|
|
(void)sig;
|
|
|
|
(void)rpcb_unset(RQUOTAPROG, RQUOTAVERS, NULL);
|
1996-01-05 08:47:12 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
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
2018-07-05 22:56:13 +00:00
|
|
|
main(int argc, char **argv)
|
1996-01-05 08:47:12 +00:00
|
|
|
{
|
|
|
|
SVCXPRT *transp;
|
2002-07-15 18:51:57 +00:00
|
|
|
int ok;
|
|
|
|
struct sockaddr_storage from;
|
2005-02-14 17:42:58 +00:00
|
|
|
socklen_t fromlen;
|
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
2018-07-05 22:56:13 +00:00
|
|
|
int vers;
|
|
|
|
int ch;
|
|
|
|
|
|
|
|
while ((ch = getopt(argc, argv, "d")) != -1) {
|
|
|
|
switch (ch) {
|
|
|
|
case 'd':
|
|
|
|
debug++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1996-01-05 08:47:12 +00:00
|
|
|
|
|
|
|
fromlen = sizeof(from);
|
2009-09-25 22:20:30 +00:00
|
|
|
if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0)
|
1996-01-05 08:47:12 +00:00
|
|
|
from_inetd = 0;
|
|
|
|
|
|
|
|
if (!from_inetd) {
|
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
2018-07-05 22:56:13 +00:00
|
|
|
if (!debug)
|
|
|
|
daemon(0, 0);
|
2009-09-25 22:20:30 +00:00
|
|
|
(void)rpcb_unset(RQUOTAPROG, RQUOTAVERS, NULL);
|
|
|
|
(void)signal(SIGINT, cleanup);
|
|
|
|
(void)signal(SIGTERM, cleanup);
|
|
|
|
(void)signal(SIGHUP, cleanup);
|
1996-01-05 08:47:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
openlog("rpc.rquotad", LOG_CONS|LOG_PID, LOG_DAEMON);
|
|
|
|
|
|
|
|
/* create and register the service */
|
2002-07-15 18:51:57 +00:00
|
|
|
if (from_inetd) {
|
|
|
|
transp = svc_tli_create(0, NULL, NULL, 0, 0);
|
|
|
|
if (transp == NULL) {
|
|
|
|
syslog(LOG_ERR, "couldn't create udp service.");
|
|
|
|
exit(1);
|
|
|
|
}
|
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
2018-07-05 22:56:13 +00:00
|
|
|
vers = RQUOTAVERS;
|
2002-07-15 18:51:57 +00:00
|
|
|
ok = svc_reg(transp, RQUOTAPROG, RQUOTAVERS,
|
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
2018-07-05 22:56:13 +00:00
|
|
|
rquota_service_1, NULL);
|
|
|
|
if (ok) {
|
|
|
|
vers = EXT_RQUOTAVERS;
|
|
|
|
ok = svc_reg(transp, RQUOTAPROG, EXT_RQUOTAVERS,
|
|
|
|
rquota_service_2, NULL);
|
|
|
|
}
|
2009-09-25 22:20:30 +00:00
|
|
|
} else {
|
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
2018-07-05 22:56:13 +00:00
|
|
|
vers = RQUOTAVERS;
|
|
|
|
ok = svc_create(rquota_service_1,
|
2009-09-25 22:20:30 +00:00
|
|
|
RQUOTAPROG, RQUOTAVERS, "udp");
|
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
2018-07-05 22:56:13 +00:00
|
|
|
if (ok) {
|
|
|
|
vers = EXT_RQUOTAVERS;
|
|
|
|
ok = svc_create(rquota_service_2,
|
|
|
|
RQUOTAPROG, EXT_RQUOTAVERS, "udp");
|
|
|
|
|
|
|
|
}
|
2009-09-25 22:20:30 +00:00
|
|
|
}
|
2002-07-15 18:51:57 +00:00
|
|
|
if (!ok) {
|
2008-11-04 14:17:49 +00:00
|
|
|
syslog(LOG_ERR,
|
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
2018-07-05 22:56:13 +00:00
|
|
|
"unable to register (RQUOTAPROG, %s, %s)",
|
|
|
|
vers == RQUOTAVERS ? "RQUOTAVERS" : "EXT_RQUOTAVERS",
|
|
|
|
from_inetd ? "(inetd)" : "udp");
|
1996-01-05 08:47:12 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
svc_run();
|
|
|
|
syslog(LOG_ERR, "svc_run returned");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2009-09-26 23:05:01 +00:00
|
|
|
static void
|
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
2018-07-05 22:56:13 +00:00
|
|
|
rquota_service_2(struct svc_req *request, SVCXPRT *transp)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (request->rq_proc) {
|
|
|
|
case NULLPROC:
|
|
|
|
(void)svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL);
|
|
|
|
break;
|
|
|
|
case RQUOTAPROC_GETQUOTA:
|
|
|
|
case RQUOTAPROC_GETACTIVEQUOTA:
|
|
|
|
sendquota_extended(request, transp);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
svcerr_noproc(transp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (from_inetd)
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rquota_service_1(struct svc_req *request, SVCXPRT *transp)
|
1996-01-05 08:47:12 +00:00
|
|
|
{
|
2008-11-04 14:17:49 +00:00
|
|
|
|
1996-01-05 08:47:12 +00:00
|
|
|
switch (request->rq_proc) {
|
|
|
|
case NULLPROC:
|
2002-04-28 15:18:50 +00:00
|
|
|
(void)svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL);
|
1996-01-05 08:47:12 +00:00
|
|
|
break;
|
|
|
|
case RQUOTAPROC_GETQUOTA:
|
|
|
|
case RQUOTAPROC_GETACTIVEQUOTA:
|
|
|
|
sendquota(request, transp);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
svcerr_noproc(transp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (from_inetd)
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read quota for the specified id, and send it */
|
2009-09-26 23:05:01 +00:00
|
|
|
static void
|
2002-02-07 05:24:53 +00:00
|
|
|
sendquota(struct svc_req *request, SVCXPRT *transp)
|
1996-01-05 08:47:12 +00:00
|
|
|
{
|
|
|
|
struct getquota_args getq_args;
|
|
|
|
struct getquota_rslt getq_rslt;
|
|
|
|
struct dqblk dqblk;
|
|
|
|
struct timeval timev;
|
2010-04-25 00:05:51 +00:00
|
|
|
int scale;
|
1996-01-05 08:47:12 +00:00
|
|
|
|
2009-09-25 22:20:30 +00:00
|
|
|
bzero(&getq_args, sizeof(getq_args));
|
2002-04-28 15:18:50 +00:00
|
|
|
if (!svc_getargs(transp, (xdrproc_t)xdr_getquota_args, &getq_args)) {
|
1996-01-05 08:47:12 +00:00
|
|
|
svcerr_decode(transp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (request->rq_cred.oa_flavor != AUTH_UNIX) {
|
|
|
|
/* bad auth */
|
|
|
|
getq_rslt.status = Q_EPERM;
|
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
2018-07-05 22:56:13 +00:00
|
|
|
} else if (!getfsquota(USRQUOTA, getq_args.gqa_uid, getq_args.gqa_pathp, &dqblk)) {
|
1996-01-05 08:47:12 +00:00
|
|
|
/* failed, return noquota */
|
|
|
|
getq_rslt.status = Q_NOQUOTA;
|
|
|
|
} else {
|
|
|
|
gettimeofday(&timev, NULL);
|
|
|
|
getq_rslt.status = Q_OK;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_active = TRUE;
|
2010-04-25 00:05:51 +00:00
|
|
|
scale = 1 << flsll(dqblk.dqb_bhardlimit >> 32);
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize =
|
|
|
|
DEV_BSIZE * scale;
|
1996-01-05 08:47:12 +00:00
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_bhardlimit =
|
2010-04-25 00:05:51 +00:00
|
|
|
dqblk.dqb_bhardlimit / scale;
|
1996-01-05 08:47:12 +00:00
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_bsoftlimit =
|
2010-04-25 00:05:51 +00:00
|
|
|
dqblk.dqb_bsoftlimit / scale;
|
1996-01-05 08:47:12 +00:00
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_curblocks =
|
2010-04-25 00:05:51 +00:00
|
|
|
dqblk.dqb_curblocks / scale;
|
1996-01-05 08:47:12 +00:00
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_fhardlimit =
|
|
|
|
dqblk.dqb_ihardlimit;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_fsoftlimit =
|
|
|
|
dqblk.dqb_isoftlimit;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_curfiles =
|
|
|
|
dqblk.dqb_curinodes;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_btimeleft =
|
|
|
|
dqblk.dqb_btime - timev.tv_sec;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_ftimeleft =
|
|
|
|
dqblk.dqb_itime - timev.tv_sec;
|
|
|
|
}
|
2009-09-25 23:03:24 +00:00
|
|
|
if (!svc_sendreply(transp, (xdrproc_t)xdr_getquota_rslt, &getq_rslt))
|
1996-01-05 08:47:12 +00:00
|
|
|
svcerr_systemerr(transp);
|
2002-04-28 15:18:50 +00:00
|
|
|
if (!svc_freeargs(transp, (xdrproc_t)xdr_getquota_args, &getq_args)) {
|
1996-01-05 08:47:12 +00:00
|
|
|
syslog(LOG_ERR, "unable to free arguments");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-26 23:05:01 +00:00
|
|
|
static void
|
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
2018-07-05 22:56:13 +00:00
|
|
|
sendquota_extended(struct svc_req *request, SVCXPRT *transp)
|
1996-01-05 08:47:12 +00:00
|
|
|
{
|
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
2018-07-05 22:56:13 +00:00
|
|
|
struct ext_getquota_args getq_args;
|
|
|
|
struct getquota_rslt getq_rslt;
|
|
|
|
struct dqblk dqblk;
|
|
|
|
struct timeval timev;
|
|
|
|
int scale;
|
|
|
|
|
|
|
|
bzero(&getq_args, sizeof(getq_args));
|
|
|
|
if (!svc_getargs(transp, (xdrproc_t)xdr_ext_getquota_args, &getq_args)) {
|
|
|
|
svcerr_decode(transp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (request->rq_cred.oa_flavor != AUTH_UNIX) {
|
|
|
|
/* bad auth */
|
|
|
|
getq_rslt.status = Q_EPERM;
|
|
|
|
} else if (!getfsquota(getq_args.gqa_type, getq_args.gqa_id, getq_args.gqa_pathp, &dqblk)) {
|
|
|
|
/* failed, return noquota */
|
|
|
|
getq_rslt.status = Q_NOQUOTA;
|
|
|
|
} else {
|
|
|
|
gettimeofday(&timev, NULL);
|
|
|
|
getq_rslt.status = Q_OK;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_active = TRUE;
|
|
|
|
scale = 1 << flsll(dqblk.dqb_bhardlimit >> 32);
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize =
|
|
|
|
DEV_BSIZE * scale;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_bhardlimit =
|
|
|
|
dqblk.dqb_bhardlimit / scale;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_bsoftlimit =
|
|
|
|
dqblk.dqb_bsoftlimit / scale;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_curblocks =
|
|
|
|
dqblk.dqb_curblocks / scale;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_fhardlimit =
|
|
|
|
dqblk.dqb_ihardlimit;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_fsoftlimit =
|
|
|
|
dqblk.dqb_isoftlimit;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_curfiles =
|
|
|
|
dqblk.dqb_curinodes;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_btimeleft =
|
|
|
|
dqblk.dqb_btime - timev.tv_sec;
|
|
|
|
getq_rslt.getquota_rslt_u.gqr_rquota.rq_ftimeleft =
|
|
|
|
dqblk.dqb_itime - timev.tv_sec;
|
|
|
|
}
|
|
|
|
if (!svc_sendreply(transp, (xdrproc_t)xdr_getquota_rslt, &getq_rslt))
|
|
|
|
svcerr_systemerr(transp);
|
|
|
|
if (!svc_freeargs(transp, (xdrproc_t)xdr_getquota_args, &getq_args)) {
|
|
|
|
syslog(LOG_ERR, "unable to free arguments");
|
|
|
|
exit(1);
|
1996-01-05 08:47:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* gets the quotas for id, filesystem path.
|
|
|
|
* Return 0 if fail, 1 otherwise
|
|
|
|
*/
|
2009-09-26 23:05:01 +00:00
|
|
|
static int
|
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
2018-07-05 22:56:13 +00:00
|
|
|
getfsquota(int type, long id, char *path, struct dqblk *dqblk)
|
1996-01-05 08:47:12 +00:00
|
|
|
{
|
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
2018-07-05 22:56:13 +00:00
|
|
|
struct quotafile *qf;
|
|
|
|
/*
|
|
|
|
* Remote quota checking is limited to mounted filesystems.
|
|
|
|
* Since UFS and ZFS support the quota system calls, we
|
|
|
|
* only need to make an fstab object that has the path, and
|
|
|
|
* a blank name for the filesystem type.
|
|
|
|
* This allows the quota_open() call to work the way we
|
|
|
|
* expect it to.
|
|
|
|
*
|
|
|
|
* The static char declaration is because compiler warnings
|
|
|
|
* don't allow passing a const char * to a char *.
|
|
|
|
*/
|
|
|
|
int rv;
|
|
|
|
static char blank[] = "";
|
|
|
|
struct fstab fst;
|
|
|
|
|
|
|
|
fst.fs_file = path;
|
|
|
|
fst.fs_mntops = blank;
|
|
|
|
fst.fs_vfstype = blank;
|
|
|
|
|
|
|
|
if (type != USRQUOTA && type != GRPQUOTA)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
qf = quota_open(&fst, type, O_RDONLY);
|
|
|
|
if (debug)
|
|
|
|
warnx("quota_open(<%s, %s>, %d) returned %p",
|
|
|
|
fst.fs_file, fst.fs_mntops, type,
|
|
|
|
qf);
|
|
|
|
if (qf == NULL)
|
|
|
|
return (0);
|
1996-01-05 08:47:12 +00:00
|
|
|
|
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
2018-07-05 22:56:13 +00:00
|
|
|
rv = quota_read(qf, dqblk, id) == 0;
|
|
|
|
quota_close(qf);
|
|
|
|
if (debug)
|
|
|
|
warnx("getfsquota(%d, %ld, %s, %p) -> %d",
|
|
|
|
type, id, path, dqblk, rv);
|
|
|
|
return (rv);
|
1996-01-05 08:47:12 +00:00
|
|
|
}
|