Add quota support using libquota (also called quota v2) on NetBSD.

Add comments to patches.
Ride update.
This commit is contained in:
wiz 2014-04-01 11:13:28 +00:00
parent aa5dd38696
commit 2ed511c1c1
6 changed files with 158 additions and 49 deletions

View file

@ -1,12 +1,14 @@
$NetBSD: distinfo,v 1.3 2014/04/01 09:48:04 adam Exp $
$NetBSD: distinfo,v 1.4 2014/04/01 11:13:28 wiz Exp $
SHA1 (transmission-2.82.tar.xz) = 1081542e2692147e45dde7c310b793abc4f33f2d
RMD160 (transmission-2.82.tar.xz) = 468ac753cd7143f2789a4b2515b9b6eb1745717f
Size (transmission-2.82.tar.xz) = 3172024 bytes
SHA1 (patch-aa) = 75d6df8cf8105dbb55ec3a4ed967036c28cfae3c
SHA1 (patch-ab) = 96174f474e3301f9062eaa17fafe3cd5c26a5243
SHA1 (patch-aa) = 1a3761226a9986e69a61f531213a447bbdb2c54f
SHA1 (patch-ab) = 796faa7c61762dc3ffe563748e55160c827149d2
SHA1 (patch-ac) = 75e0d1fbfc5bb895b17fa22d8d09d6257e798847
SHA1 (patch-libtransmission_platform-quota.c) = d87c6cfba6ef91585afac1063a8f47e39777a9a8
SHA1 (patch-configure) = f7df68a574fba475578e352283f43e6c058db494
SHA1 (patch-configure.ac) = a0445df6bf43029e7cb16ee346a27fd016f98889
SHA1 (patch-libtransmission_platform-quota.c) = 08999288207643b97efca558c824489ea745d411
SHA1 (patch-qt_qtr.pro) = 9a272f1e60f1b59d513b62451b4e0fc085dbae18
SHA1 (patch-qt_torrent-filter.cc) = 490babef551fd43cfed18c0efdfd9624c8c3527e
SHA1 (patch-third-party_miniupnp_miniupnp.c) = df4957ccf5b08af14d2df98e953dd2d1b584c294

View file

@ -1,4 +1,6 @@
$NetBSD: patch-aa,v 1.1 2013/03/02 19:33:29 wiz Exp $
$NetBSD: patch-aa,v 1.2 2014/04/01 11:13:28 wiz Exp $
Include header for select().
--- third-party/miniupnp/connecthostport.c.orig 2012-07-06 01:26:19.000000000 +0000
+++ third-party/miniupnp/connecthostport.c

View file

@ -1,4 +1,6 @@
$NetBSD: patch-ab,v 1.1 2013/03/02 19:33:29 wiz Exp $
$NetBSD: patch-ab,v 1.2 2014/04/01 11:13:28 wiz Exp $
Provide default implementation if none exists.
--- third-party/libnatpmp/getgateway.c.orig 2008-08-09 06:08:13.000000000 +0200
+++ third-party/libnatpmp/getgateway.c

View file

@ -0,0 +1,70 @@
$NetBSD: patch-configure,v 1.1 2014/04/01 11:13:28 wiz Exp $
Quota support for NetBSD-6+.
http://trac.transmissionbt.com/ticket/5643
--- configure.orig 2014-03-31 11:48:05.000000000 +0000
+++ configure
@@ -16935,6 +16935,62 @@ if test "$ac_res" != no; then :
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing quotacursor_skipidtype" >&5
+$as_echo_n "checking for library containing quotacursor_skipidtype... " >&6; }
+if ${ac_cv_search_quotacursor_skipidtype+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char quotacursor_skipidtype ();
+int
+main ()
+{
+return quotacursor_skipidtype ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' quota; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_quotacursor_skipidtype=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_quotacursor_skipidtype+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_quotacursor_skipidtype+:} false; then :
+
+else
+ ac_cv_search_quotacursor_skipidtype=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_quotacursor_skipidtype" >&5
+$as_echo "$ac_cv_search_quotacursor_skipidtype" >&6; }
+ac_res=$ac_cv_search_quotacursor_skipidtype
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then

View file

@ -0,0 +1,15 @@
$NetBSD: patch-configure.ac,v 1.1 2014/04/01 11:13:28 wiz Exp $
Quota support for NetBSD-6+.
http://trac.transmissionbt.com/ticket/5643
--- configure.ac.orig 2013-08-09 02:47:38.000000000 +0000
+++ configure.ac
@@ -117,6 +117,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])

View file

@ -1,57 +1,75 @@
$NetBSD$
Add NetBSD support.
Quota support for NetBSD-6+.
http://trac.transmissionbt.com/ticket/5643
--- libtransmission/platform-quota.c.orig 2014-03-31 18:47:50.000000000 +0000
--- libtransmission/platform-quota.c.orig 2013-08-09 02:45:44.000000000 +0000
+++ libtransmission/platform-quota.c
@@ -20,6 +20,8 @@
@@ -20,6 +20,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 <ufs/ufs/quota1.h>
+ #elif defined (__NetBSD__)
+ #include <sys/param.h>
+ #ifndef statfs
+ #define statfs statvfs
+ #endif
#elif defined (__sun)
#include <sys/fs/ufs_quota.h> /* quotactl */
#else
@@ -104,7 +106,11 @@ getdev (const char * path)
@@ -195,6 +200,47 @@ getblkdev (const char * path)
return device;
}
int i;
int n;
+#if defined(__NetBSD__)
+ struct statvfs * mnt;
+#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
struct statfs * mnt;
static int64_t
getquota (const char * device)
{
@@ -259,6 +305,7 @@ getquota (const char * device)
/* something went wrong */
return -1;
}
+#endif
n = getmntinfo(&mnt, MNT_WAIT);
if (!n)
@@ -154,7 +160,11 @@ getfstype (const char * device)
int i;
int n;
+#if defined(__NetBSD__)
+ struct statvfs *mnt;
+#else
struct statfs *mnt;
+#endif
n = getmntinfo(&mnt, MNT_WAIT);
if (!n)
@@ -203,7 +213,7 @@ getquota (const char * device)
int64_t freespace;
int64_t spaceused;
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(SYS_DARWIN)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(SYS_DARWIN)
if (quotactl(device, QCMD(Q_GETQUOTA, USRQUOTA), getuid(), (caddr_t) &dq) == 0)
{
#elif defined(__sun)
@@ -235,7 +245,7 @@ getquota (const char * device)
/* No quota enabled for this user */
return -1;
}
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
spaceused = (int64_t) dq.dqb_curblocks >> 1;
#elif defined(SYS_DARWIN)
spaceused = (int64_t) dq.dqb_curbytes;
#ifdef HAVE_XQM
static int64_t