/*
- * $Id: nfsquota.c,v 1.7 2002-01-19 21:29:55 jmarcus Exp $
*
* parts of this are lifted from the bsd quota program and are
* therefore under the following copyright:
#include "config.h"
#endif /* HAVE_CONFIG_H */
+#if !defined(NO_QUOTA_SUPPORT) && !defined(HAVE_LIBQUOTA)
#include <stdio.h>
-
-/* STDC check */
-#if STDC_HEADERS
#include <string.h>
-#else /* STDC_HEADERS */
-#ifndef HAVE_STRCHR
-#define strchr index
-#define strrchr index
-#endif /* HAVE_STRCHR */
-char *strchr (), *strrchr ();
-#ifndef HAVE_MEMCPY
-#define memcpy(d,s,n) bcopy ((s), (d), (n))
-#define memmove(d,s,n) bcopy ((s), (d), (n))
-#endif /* ! HAVE_MEMCPY */
-#endif /* STDC_HEADERS */
-
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h> /* for DEV_BSIZE */
#include <sys/time.h> /* <rpc/rpc.h> on ultrix doesn't include this */
-#include <atalk/logger.h>
-
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif /* HAVE_NETDB_H */
#include <netinet/in.h>
+#ifndef PORTMAP
+#define PORTMAP 1
+#endif
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#include <rpcsvc/rquota.h>
+
#include <atalk/afp.h>
+#include <atalk/logger.h>
#include "unix.h"
-#ifndef NO_QUOTA_SUPPORT
/* lifted (with modifications) from the bsd quota program */
static int
-callaurpc(vol, prognum, versnum, procnum, inproc, in, outproc, out)
-struct vol *vol;
-u_long prognum, versnum, procnum;
-xdrproc_t inproc, outproc;
-char *in, *out;
+callaurpc(struct vol *vol,
+ u_long prognum, u_long versnum, u_long procnum,
+ xdrproc_t inproc, char *in,
+ xdrproc_t outproc, char *out)
{
enum clnt_stat clnt_stat;
struct timeval tottimeout;
#define GQR_RQUOTA getquota_rslt_u.gqr_rquota
#endif /* USE_OLD_RQUOTA */
-int getnfsquota(const struct vol *vol, const int uid, const u_int32_t bsize,
+int getnfsquota(struct vol *vol, const int uid, const uint32_t bsize,
struct dqblk *dqp)
{
/* figure out the host and path */
if ((hostpath = strchr(vol->v_gvs, ':')) == NULL) {
- LOG(log_error, logtype_default, "can't find hostname for %s", vol->v_gvs);
+ LOG(log_error, logtype_afpd, "can't find hostname for %s", vol->v_gvs);
return AFPERR_PARAM;
}
if(callaurpc(vol, RQUOTAPROG, RQUOTAVERS, RQUOTAPROC_GETQUOTA,
(xdrproc_t) xdr_getquota_args, (char *) &gq_args,
(xdrproc_t) xdr_getquota_rslt, (char *) &gq_rslt) != 0) {
- LOG(log_info, logtype_default, "nfsquota: can't retrieve nfs quota information. \
+ LOG(log_info, logtype_afpd, "nfsquota: can't retrieve nfs quota information. \
make sure that rpc.rquotad is running on %s.", vol->v_gvs);
*hostpath = ':';
return AFPERR_PARAM;
break;
case Q_EPERM:
- LOG(log_error, logtype_default, "nfsquota: quota permission error, host: %s\n",
+ LOG(log_error, logtype_afpd, "nfsquota: quota permission error, host: %s",
vol->v_gvs);
break;
case Q_OK: /* we only copy the bits that we need. */
gettimeofday(&tv, NULL);
-#ifdef __svr4__
+#if defined(__svr4__) || defined(TRU64)
/* why doesn't using bsize work? */
-#define NFS_BSIZE (gq_rslt.GQR_RQUOTA.rq_bsize / DEV_BSIZE)
-#else /* __svr4__ */
+#define NFS_BSIZE gq_rslt.GQR_RQUOTA.rq_bsize / DEV_BSIZE
+#else /* __svr4__ || TRU64 */
/* NOTE: linux' rquotad program doesn't currently report the
* correct rq_bsize. */
-#define NFS_BSIZE (gq_rslt.GQR_RQUOTA.rq_bsize / bsize)
-#endif /* __svr4__ */
+ /* NOTE: This is integer division and can introduce rounding errors */
+#define NFS_BSIZE gq_rslt.GQR_RQUOTA.rq_bsize / bsize
+#endif /* __svr4__ || TRU64 */
dqp->dqb_bhardlimit =
gq_rslt.GQR_RQUOTA.rq_bhardlimit*NFS_BSIZE;
break;
default:
- LOG(log_info, logtype_default, "bad rpc result, host: %s\n", vol->v_gvs);
+ LOG(log_info, logtype_afpd, "bad rpc result, host: %s", vol->v_gvs);
break;
}
*hostpath = ':';
return AFPERR_PARAM;
}
-#endif /* ! NO_QUOTA_SUPPORT */
+#endif /* ! NO_QUOTA_SUPPORT && !HAVE_LIBQUOTA */