Changeset 13698


Ignore:
Timestamp:
Dec 27, 2012, 7:45:01 PM (8 years ago)
Author:
jordan
Message:

(trunk, libT) #3833 'freespace' argument for 'session-get' RPC method -- apply taem's 0003-Cache-download-dir-s-block-device-and-FS-type.patch​ to cache the download dir's block device and FS type

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/platform.c

    r13697 r13698  
    889889
    890890static int64_t
    891 tr_getQuotaFreeSpace( const char * path )
     891tr_getQuotaFreeSpace( const char * path, char * device, char * fstype )
    892892{
    893893    int64_t ret=-1;
    894894#ifndef WIN32
    895     char *d, *device;
    896     char *fstype;
    897 
    898     if ((d = getblkdev(path)) == NULL)
    899     {
    900         return ret;
    901     }
    902     /* 'd' points to static area of memory, so copy it */
    903     device = tr_strdup(d);
    904 
    905     fstype = getfstype(device);
    906     if (fstype != NULL && strcasecmp(fstype, "xfs") == 0)
     895    char *d;
     896    char *fs;
     897
     898    if (strlen(device) == 0)
     899    {
     900        if ((d = getblkdev(path)) == NULL)
     901        {
     902            return ret;
     903        }
     904        /* Save device for future use */
     905        tr_strlcpy(device, d, PATH_MAX + 1);
     906    }
     907
     908    if (strlen(fstype) == 0)
     909    {
     910        if ((fs = getfstype(device)) != NULL)
     911        {
     912             /* Save FS type for future use */
     913             tr_strlcpy(fstype, fs, PATH_MAX + 1);
     914        }
     915    }
     916
     917    if (strcasecmp(fstype, "xfs") == 0)
    907918    {
    908919#ifdef HAVE_XQM
     
    913924    }
    914925
    915     tr_free(device);
    916926#endif /* WIN32 */
    917927    return ret;
     
    936946
    937947int64_t
    938 tr_getFreeSpace( const char * path )
    939 {
    940     int64_t i = tr_getQuotaFreeSpace( path );
     948tr_getFreeSpace( const char * path, char * device, char * fstype )
     949{
     950    int64_t i = tr_getQuotaFreeSpace( path, device, fstype );
    941951    if( i < 0 )
    942952        i = tr_getDiskFreeSpace( path );
  • trunk/libtransmission/platform.h

    r13696 r13698  
    4545/** If the disk quota is enabled and readable, this returns how much is available in the quota.
    4646    Otherwise, it returns how much is available on the disk, or -1 on error. */
    47 int64_t tr_getFreeSpace (const char * path);
     47int64_t tr_getFreeSpace (const char * path, char * device, char * fstype);
    4848
    4949
  • trunk/libtransmission/session.c

    r13683 r13698  
    591591    session->tag = tr_strdup (tag);
    592592    session->magicNumber = SESSION_MAGIC_NUMBER;
     593    session->downloadDirBlkDev = tr_malloc (PATH_MAX + 1);
     594    session->downloadDirFsType = tr_malloc (PATH_MAX + 1);
    593595    tr_bandwidthConstruct (&session->bandwidth, session, NULL);
    594596    tr_peerIdInit (session->peer_id);
     
    954956        tr_free (session->downloadDir);
    955957        session->downloadDir = tr_strdup (dir);
     958        memset (session->downloadDirBlkDev, 0, sizeof(session->downloadDirBlkDev));
     959        memset (session->downloadDirFsType, 0, sizeof(session->downloadDirFsType));
    956960    }
    957961}
     
    970974    assert (tr_isSession (session));
    971975
    972     return tr_getFreeSpace (session->downloadDir);
     976    return tr_getFreeSpace (session->downloadDir, session->downloadDirBlkDev,
     977    session->downloadDirFsType);
    973978}
    974979
     
    18801885    tr_free (session->torrentDir);
    18811886    tr_free (session->downloadDir);
     1887    tr_free (session->downloadDirBlkDev);
     1888    tr_free (session->downloadDirFsType);
    18821889    tr_free (session->incompleteDir);
    18831890    tr_free (session->blocklist_url);
  • trunk/libtransmission/session.h

    r13667 r13698  
    183183    char *                       configDir;
    184184    char *                       downloadDir;
     185    char *                       downloadDirBlkDev;
     186    char *                       downloadDirFsType;
    185187    char *                       resumeDir;
    186188    char *                       torrentDir;
Note: See TracChangeset for help on using the changeset viewer.