Changeset 13714


Ignore:
Timestamp:
Dec 29, 2012, 1:47:44 AM (8 years ago)
Author:
jordan
Message:

(trunk, libT) #3833 'freespace argument for session-get' -- 0001-Port-quota-handling-to-BSD-and-Mac-OS-X.patch from taem

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/platform.c

    r13705 r13714  
    1414 #include <sys/types.h> /* types needed by quota.h */
    1515 #include <sys/quota.h> /* quotactl */
     16 #ifdef __FreeBSD__
     17  #include <ufs/ufs/quota.h> /* quotactl() */
     18 #else
     19  #include <sys/quota.h> /* quotactl() */
     20 #endif
    1621 #ifdef HAVE_GETMNTENT
    1722  #include <mntent.h>
     
    829834  int64_t limit;
    830835  int64_t freespace;
    831 
    832   if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device, getuid(), (caddr_t) & dq) == 0)
     836  int64_t spaceused;
     837
     838#if defined(__FreeBSD__) || defined(SYS_DARWIN)
     839  if (quotactl(device, QCMD(Q_GETQUOTA, USRQUOTA), getuid(), &dq) == 0)
     840#else
     841  if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device, getuid(), (caddr_t) &dq) == 0)
     842#endif
    833843    {
    834844      if (dq.dqb_bsoftlimit > 0)
     
    846856          return -1;
    847857        }
    848 
    849       freespace = limit - btodb(dq.dqb_curspace);
     858#if defined(__FreeBSD__) || defined(SYS_DARWIN)
     859      spaceused = (int64_t) dqb_curblocks >> 1;
     860#else
     861      spaceused = btodb(dq.dqb_curspace);
     862#endif
     863      freespace = limit - spaceused;
    850864      return (freespace < 0) ? 0 : freespace * 1024;
    851865    }
Note: See TracChangeset for help on using the changeset viewer.