FreeBSD/libexec/rpc.rquotad/rquotad.c
/* read quota for the specified id, and send it */
read quota for the specified id, and send it
read quota for the specified id and send it
static void
sendquota(struct svc_req *request, SVCXPRT *transp)
{
	struct 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_getquota_args, &getq_args)) {
		svcerr_decode(transp);
		return;
	}
	if (request->rq_cred.oa_flavor != AUTH_UNIX) {
		getq_rslt.status = Q_EPERM;
	} else if (!getfsquota(getq_args.gqa_uid, getq_args.gqa_pathp, &dqblk)) {
		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);
	}
}
static void sendquota ( struct svc_req * request , SVCXPRT * transp ) { struct 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_getquota_args , & getq_args ) ) { svcerr_decode ( transp ) ; return ; } if ( request -> rq_cred . oa_flavor != AUTH_UNIX ) { getq_rslt . status = Q_EPERM ; } else if ( ! getfsquota ( getq_args . gqa_uid , getq_args . gqa_pathp , & dqblk ) ) { 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 , " " ) ; exit ( 1 ) ; } }
read quota for the specified id, and send it
read quota for the specified id and send it
/* bad auth */ /* failed, return noquota */