summaryrefslogtreecommitdiff
path: root/source3/lib/sysquotas_4B.c
diff options
context:
space:
mode:
authorBjoern Jacke <bj@sernet.de>2019-02-05 17:23:35 -0600
committerBjoern Jacke <bjacke@samba.org>2019-02-17 13:33:13 +0100
commit0d815dbb10188ec7b9bd505668fe75b274b43fec (patch)
tree823993ded9c2ba6072eb288b28b6b0418a278f2e /source3/lib/sysquotas_4B.c
parent21e930adecf9307666c088e8e9a46e3a56eb6cdd (diff)
downloadsamba-0d815dbb10188ec7b9bd505668fe75b274b43fec.tar.gz
sysquotas_4B: make quota block calculation adopt to platform quota block size
the correct QUOTABLOCK_SIZE for platform is taken from sysquotas.h Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org>
Diffstat (limited to 'source3/lib/sysquotas_4B.c')
-rw-r--r--source3/lib/sysquotas_4B.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/source3/lib/sysquotas_4B.c b/source3/lib/sysquotas_4B.c
index ee56432211e..3fca68ad047 100644
--- a/source3/lib/sysquotas_4B.c
+++ b/source3/lib/sysquotas_4B.c
@@ -52,6 +52,11 @@
#define HFS_QUOTACTL_WAR 1
#endif
+#ifdef HAVE_STRUCT_DQBLK_DQB_CURBYTES
+/* we handle the byte vs. block count dynamically via QUOTABLOCK_SIZE 1 */
+#define dqb_curblocks dqb_curbytes
+#endif
+
static void xlate_qblk_to_smb(const struct dqblk * const qblk,
SMB_DISK_QUOTA *dp)
{
@@ -59,35 +64,25 @@ 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.
- */
-#define XLATE_TO_BLOCKS(bytes) (((bytes) + 1) / 512)
- dp->bsize = 512;
-
- dp->softlimit = XLATE_TO_BLOCKS(qblk->dqb_bsoftlimit);
- dp->hardlimit = XLATE_TO_BLOCKS(qblk->dqb_bhardlimit);
- dp->curblocks = XLATE_TO_BLOCKS(qblk->dqb_curbytes);
-#undef XLATE_TO_BLOCKS
-#else
- dp->bsize = DEV_BSIZE;
+ dp->bsize = QUOTABLOCK_SIZE;
dp->softlimit = qblk->dqb_bsoftlimit;
dp->hardlimit = qblk->dqb_bhardlimit;
dp->curblocks = qblk->dqb_curblocks;
+/* our Darwin quotas used to never return 0byte usage but this is probably not needed,
+ * let's comment this out for now
+#ifdef HAVE_STRUCT_DQBLK_DQB_CURBYTES
+ if (dp->curblocks == 0) {
+ dp->curblocks = 1;
+ }
#endif
+ */
dp->ihardlimit = qblk->dqb_ihardlimit;
dp->isoftlimit = qblk->dqb_isoftlimit;
@@ -110,13 +105,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->bsize;
- qblk->dqb_bhardlimit *= dp->bsize;
-#endif
+ if (dp->bsize == QUOTABLOCK_SIZE) {
+ qblk->dqb_bsoftlimit = dp->softlimit;
+ qblk->dqb_bhardlimit = dp->hardlimit;
+ } else {
+ qblk->dqb_bsoftlimit = dp->softlimit * dp->bsize / QUOTABLOCK_SIZE;
+ qblk->dqb_bhardlimit = dp->hardlimit * dp->bsize / QUOTABLOCK_SIZE;
+ }
qblk->dqb_ihardlimit = dp->ihardlimit;
qblk->dqb_isoftlimit = dp->isoftlimit;
}