1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

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>
This commit is contained in:
Bjoern Jacke 2019-02-05 17:23:35 -06:00 committed by Bjoern Jacke
parent 21e930adec
commit 0d815dbb10

View File

@ -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;
}