Changeset 14259


Ignore:
Timestamp:
Apr 27, 2014, 12:02:00 AM (8 years ago)
Author:
jordan
Message:

(trunk, libT) #5643 'quota support for NetBSD >= 6' -- patch by wiz

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r14256 r14259  
    109109AC_SEARCH_LIBS([socket], [socket net])
    110110AC_SEARCH_LIBS([gethostbyname], [nsl bind])
     111AC_SEARCH_LIBS([quotacursor_skipidtype], [quota])
    111112PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
    112113PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
  • trunk/libtransmission/platform-quota.c

    r14241 r14259  
    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 */
     
    193198}
    194199
     200#if defined(__NetBSD__) && (__NetBSD_Version__ >= 600000000)
     201#include <quota.h>
     202
     203static int64_t
     204getquota (const char * device)
     205{
     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
    195241static int64_t
    196242getquota (const char * device)
     
    257303  return -1;
    258304}
     305#endif
    259306
    260307#ifdef HAVE_XQM
Note: See TracChangeset for help on using the changeset viewer.