Ticket #5643: quota-support-for-NetBSD-6.diff

File quota-support-for-NetBSD-6.diff, 2.2 KB (added by _wiz_, 8 years ago)

Patch fixing the problem.

  • configure.ac

     
    117117AC_SEARCH_LIBS(cos, [m])
    118118AC_SEARCH_LIBS([socket], [socket net])
    119119AC_SEARCH_LIBS([gethostbyname], [nsl bind])
     120AC_SEARCH_LIBS([quotacursor_skipidtype], [quota])
    120121PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
    121122PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
    122123PKG_CHECK_MODULES(LIBEVENT, [libevent >= $LIBEVENT_MINIMUM])
  • libtransmission/platform-quota.c

     
    1717 #include <sys/types.h> /* types needed by quota.h */
    1818 #if defined(__FreeBSD__) || defined(__OpenBSD__)
    1919  #include <ufs/ufs/quota.h> /* quotactl() */
     20 #elif defined (__NetBSD__)
     21  #include <sys/param.h>
     22  #ifndef statfs
     23   #define statfs statvfs
     24  #endif
    2025 #elif defined (__sun)
    2126  #include <sys/fs/ufs_quota.h> /* quotactl */
    2227 #else
     
    192197  return device;
    193198}
    194199
     200#if defined(__NetBSD__) && (__NetBSD_Version__ >= 600000000)
     201#include <quota.h>
     202
    195203static int64_t
    196204getquota (const char * device)
    197205{
     206  struct quotahandle *qh;
     207  struct quotakey qk;
     208  struct quotaval qv;
     209  int64_t limit;
     210  int64_t freespace;
     211  int64_t spaceused;
     212
     213  qh = quota_open(device);
     214  if (qh == NULL) {
     215    return -1;
     216  }
     217  qk.qk_idtype = QUOTA_IDTYPE_USER;
     218  qk.qk_id = getuid();
     219  qk.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
     220  if (quota_get(qh, &qk, &qv) == -1) {
     221    quota_close(qh);
     222    return -1;
     223  }
     224  if (qv.qv_softlimit > 0) {
     225    limit = qv.qv_softlimit;
     226  }
     227  else if (qv.qv_hardlimit > 0) {
     228    limit = qv.qv_hardlimit;
     229  }
     230  else {
     231    quota_close(qh);
     232    return -1;
     233  }
     234  spaceused = qv.qv_usage;
     235  quota_close(qh);
     236
     237  freespace = limit - spaceused;
     238  return (freespace < 0) ? 0 : freespace;
     239}
     240#else
     241static int64_t
     242getquota (const char * device)
     243{
    198244  struct dqblk dq;
    199245  int64_t limit;
    200246  int64_t freespace;
     
    256302  /* something went wrong */
    257303  return -1;
    258304}
     305#endif
    259306
    260307#ifdef HAVE_XQM
    261308static int64_t