(trunk, libT) #5643 'quota support for NetBSD >= 6' -- patch by wiz
This commit is contained in:
parent
157bbe73f6
commit
fef15a7ab2
|
@ -108,6 +108,7 @@ fi
|
|||
AC_SEARCH_LIBS(cos, [m])
|
||||
AC_SEARCH_LIBS([socket], [socket net])
|
||||
AC_SEARCH_LIBS([gethostbyname], [nsl bind])
|
||||
AC_SEARCH_LIBS([quotacursor_skipidtype], [quota])
|
||||
PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
|
||||
PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
|
||||
PKG_CHECK_MODULES(LIBEVENT, [libevent >= $LIBEVENT_MINIMUM])
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
#include <sys/types.h> /* types needed by quota.h */
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#include <ufs/ufs/quota.h> /* quotactl() */
|
||||
#elif defined (__NetBSD__)
|
||||
#include <sys/param.h>
|
||||
#ifndef statfs
|
||||
#define statfs statvfs
|
||||
#endif
|
||||
#elif defined (__sun)
|
||||
#include <sys/fs/ufs_quota.h> /* quotactl */
|
||||
#else
|
||||
|
@ -192,6 +197,47 @@ getblkdev (const char * path)
|
|||
return device;
|
||||
}
|
||||
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 600000000)
|
||||
#include <quota.h>
|
||||
|
||||
static int64_t
|
||||
getquota (const char * device)
|
||||
{
|
||||
struct quotahandle *qh;
|
||||
struct quotakey qk;
|
||||
struct quotaval qv;
|
||||
int64_t limit;
|
||||
int64_t freespace;
|
||||
int64_t spaceused;
|
||||
|
||||
qh = quota_open(device);
|
||||
if (qh == NULL) {
|
||||
return -1;
|
||||
}
|
||||
qk.qk_idtype = QUOTA_IDTYPE_USER;
|
||||
qk.qk_id = getuid();
|
||||
qk.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
|
||||
if (quota_get(qh, &qk, &qv) == -1) {
|
||||
quota_close(qh);
|
||||
return -1;
|
||||
}
|
||||
if (qv.qv_softlimit > 0) {
|
||||
limit = qv.qv_softlimit;
|
||||
}
|
||||
else if (qv.qv_hardlimit > 0) {
|
||||
limit = qv.qv_hardlimit;
|
||||
}
|
||||
else {
|
||||
quota_close(qh);
|
||||
return -1;
|
||||
}
|
||||
spaceused = qv.qv_usage;
|
||||
quota_close(qh);
|
||||
|
||||
freespace = limit - spaceused;
|
||||
return (freespace < 0) ? 0 : freespace;
|
||||
}
|
||||
#else
|
||||
static int64_t
|
||||
getquota (const char * device)
|
||||
{
|
||||
|
@ -256,6 +302,7 @@ getquota (const char * device)
|
|||
/* something went wrong */
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XQM
|
||||
static int64_t
|
||||
|
|
Loading…
Reference in New Issue