s3: adopt the new sysquotas_4B support for BSD
authorBjörn Jacke <bj@sernet.de>
Sun, 2 Sep 2012 14:08:58 +0000 (16:08 +0200)
committerBjörn Jacke <bj@sernet.de>
Sun, 2 Sep 2012 18:58:58 +0000 (20:58 +0200)
most BSD systems have ufs/ufs/quota.h and they count the quota in blocks, not
bytes and have slightly different dqblk struct members.

source3/configure.in
source3/lib/sysquotas_4B.c

index 67ccad6ed134596564e2aae280be2fba387ba611..e11f4343620250481b1d31a61a4703753b6af4f7 100644 (file)
@@ -4646,6 +4646,10 @@ AC_CHECK_HEADERS(linux/dqblk_xfs.h)
 # For sys/quota.h and linux/quota.h
 AC_CHECK_HEADERS(sys/quota.h)
 
+# For quotas on BSD systems
+AC_CHECK_HEADERS(ufs/ufs/quota.h)
+
+
 if test x"$samba_cv_found_xfs_header" != x"yes"; then
 # if we have xfs quota support <sys/quota.h> (IRIX) we should use it
 AC_CACHE_CHECK([for XFS QUOTA in <sys/quota.h>],samba_cv_HAVE_SYS_QUOTA_XFS, [
@@ -4710,6 +4714,11 @@ if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
     samba_cv_SYSQUOTA_FOUND=yes;
     AC_DEFINE(HAVE_QUOTACTL_4B,1,[Whether int quotactl(const char *path, int cmd, int id, char *addr) is available])
     samba_cv_sysquotas_file="lib/sysquotas_4B.c"
+    AC_CHECK_MEMBERS([struct dqblk.dqb_curbytes], # Darwin bytecount style
+       [ AC_DEFINE([HAVE_STRUCT_DQBLK_DQB_CURBYTES],[1],[darwin style quota bytecount])],,
+       [#include <sys/typeѕ.h>
+       #include <sys/quota.h>])
+
 fi
 fi
 
index 9badd3b75b7c5327b3749c10bb5051d8716e7f90..e3adc35015eba28bedc6f04a746703b4aa7e9fc3 100644 (file)
 #include <sys/quota.h>
 #endif
 
-/* WorkARound broken HFS access checks in hfs_quotactl. */
+#ifdef HAVE_UFS_UFS_QUOTA_H
+#include <ufs/ufs/quota.h>
+#endif
+
+#if defined(DARWINOS)
+/* WorkARound broken HFS access checks in hfs_quotactl. Darwin only(?) */
 #define HFS_QUOTACTL_WAR 1
+#endif
 
 static void xlate_qblk_to_smb(const struct dqblk * const qblk,
                        SMB_DISK_QUOTA *dp)
@@ -53,12 +59,17 @@ static void xlate_qblk_to_smb(const struct dqblk * const qblk,
 
        DEBUG(10, ("unix softlimit=%u hardlimit=%u curblock=%u\n",
            (unsigned)qblk->dqb_bsoftlimit, (unsigned)qblk->dqb_bhardlimit,
+#ifdef HAVE_STRUCT_DQBLK_DQB_CURBYTES
            (unsigned)qblk->dqb_curbytes));
+#else
+           (unsigned)qblk->dqb_curblocks));
+#endif
 
        DEBUGADD(10, ("unix softinodes=%u hardinodes=%u curinodes=%u\n",
            (unsigned)qblk->dqb_isoftlimit, (unsigned)qblk->dqb_ihardlimit,
            (unsigned)qblk->dqb_curinodes));
 
+#ifdef HAVE_STRUCT_DQBLK_DQB_CURBYTES
        /* On Darwin, quotas are counted in bytes. We report them
         * in 512b blocks because various callers have assumptions
         * about the block size.
@@ -70,6 +81,7 @@ static void xlate_qblk_to_smb(const struct dqblk * const qblk,
        dp->hardlimit = XLATE_TO_BLOCKS(qblk->dqb_bhardlimit);
        dp->curblocks = XLATE_TO_BLOCKS(qblk->dqb_curbytes);
 #undef XLATE_TO_BLOCKS
+#endif
 
        dp->ihardlimit = qblk->dqb_ihardlimit;
        dp->isoftlimit = qblk->dqb_isoftlimit;
@@ -92,9 +104,13 @@ static void xlate_smb_to_qblk(const SMB_DISK_QUOTA * const dp,
 {
        ZERO_STRUCTP(qblk);
 
+       qblk->dqb_bsoftlimit = dp->softlimit;
+       qblk->dqb_bhardlimit = dp->hardlimit;
+#ifdef HAVE_STRUCT_DQBLK_DQB_CURBYTES
        /* On Darwin, quotas are counted in bytes. */
-       qblk->dqb_bsoftlimit = dp->softlimit * dp->bsize;
-       qblk->dqb_bhardlimit = dp->hardlimit * dp->bsize;
+       qblk->dqb_bsoftlimit *= dp->bsize;
+       qblk->dqb_bhardlimit *= dp->bsize;
+#endif
        qblk->dqb_ihardlimit = dp->ihardlimit;
        qblk->dqb_isoftlimit = dp->isoftlimit;
 }