Changeset 13975


Ignore:
Timestamp:
Feb 5, 2013, 2:35:01 PM (8 years ago)
Author:
jordan
Message:

(libT) #5275 'quotactl breaks compilation of libT/platform.c on Solaris' -- fixed with patch from spaam

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/platform.c

    r13969 r13975  
    1515 #ifdef __FreeBSD__
    1616  #include <ufs/ufs/quota.h> /* quotactl() */
     17 #elif defined (__sun)
     18  #include <sys/fs/ufs_quota.h> /* quotactl */
    1719 #else
    1820  #include <sys/quota.h> /* quotactl() */
    1921 #endif
    2022 #ifdef HAVE_GETMNTENT
    21   #include <mntent.h>
    22   #include <paths.h> /* _PATH_MOUNTED */
     23  #ifdef __sun
     24   #include <stdio.h>
     25   #include <sys/mntent.h>
     26   #include <sys/mnttab.h>
     27   #define _PATH_MOUNTED MNTTAB
     28  #else
     29   #include <mntent.h>
     30   #include <paths.h> /* _PATH_MOUNTED */
     31  #endif
    2332 #else /* BSD derived systems */
    2433  #include <sys/param.h>
     
    730739
    731740  FILE * fp;
     741
     742#ifdef __sun
     743  struct mnttab * mnt;
     744  fp = fopen(_PATH_MOUNTED, "r");
     745  if (fp == NULL)
     746    return NULL;
     747
     748  while (getmntent(fp, mnt))
     749    if (!tr_strcmp0 (path, mnt->mnt_mountp))
     750      break;
     751  fclose(fp);
     752  return mnt ? mnt->mnt_fstype : NULL;
     753#else
    732754  struct mntent * mnt;
    733755
     
    742764  endmntent(fp);
    743765  return mnt ? mnt->mnt_fsname : NULL;
    744 
     766#endif
    745767#else /* BSD derived systems */
    746768
     
    769791
    770792  FILE * fp;
     793#ifdef __sun
     794  struct mnttab *mnt;
     795  fp = fopen(_PATH_MOUNTED, "r");
     796  if (fp == NULL)
     797    return NULL;
     798  while (getmntent(fp, mnt))
     799    if (!tr_strcmp0 (device, mnt->mnt_mountp))
     800      break;
     801  fclose(fp);
     802  return mnt ? mnt->mnt_fstype : NULL;
     803#else
    771804  struct mntent *mnt;
    772805
     
    781814  endmntent(fp);
    782815  return mnt ? mnt->mnt_type : NULL;
    783 
     816#endif
    784817#else /* BSD derived systems */
    785818
     
    837870#if defined(__FreeBSD__) || defined(SYS_DARWIN)
    838871  if (quotactl(device, QCMD(Q_GETQUOTA, USRQUOTA), getuid(), (caddr_t) &dq) == 0)
     872    {
     873#elif defined(__sun)
     874  struct quotctl  op;
     875  int fd = open(device, O_RDONLY);
     876  if (fd < 0)
     877    return -1;
     878  op.op = Q_GETQUOTA;
     879  op.uid = getuid();
     880  op.addr = (caddr_t) &dq;
     881  if (ioctl(fd, Q_QUOTACTL, &op) == 0)
     882    {
     883      close(fd);
    839884#else
    840885  if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device, getuid(), (caddr_t) &dq) == 0)
    841 #endif
    842     {
     886    {
     887#endif
    843888      if (dq.dqb_bsoftlimit > 0)
    844889        {
     
    861906#elif defined(__UCLIBC__)
    862907      spaceused = (int64_t) btodb(dq.dqb_curblocks);
     908#elif defined(__sun)
     909      spaceused = (int64_t) dq.dqb_curblocks >> 1;
    863910#else
    864911      spaceused = btodb(dq.dqb_curspace);
     
    871918#endif
    872919    }
    873 
     920#if defined(__sun)
     921  close(fd);
     922#endif
    874923  /* something went wrong */
    875924  return -1;
Note: See TracChangeset for help on using the changeset viewer.