Package: manpages-dev
Version: 3.74-1

The man page for quotactl reports the following for the struct dqblk under
Q_GETQUOTA:

uint64_t dqb_curspace;     /* current quota block count */

Which seems to be referencing the sys/quota.h file, which comes from the
libc6-dev package (version 2.19-18+deb8u3):

dpkg -S /usr/include/x86_64-linux-gnu/sys/quota.h

libc6-dev:amd64: /usr/include/x86_64-linux-gnu/sys/quota.h

Which also has the same comment.  The comment is incorrect, dqb_curspace is
in bytes, not blocks.

It is trivial to write a small c++ program to verify this:

#include <sys/quota.h>
#include <iostream>
#include <cstring>
#include <string>
#include <cerrno>

void printquota(std::string device, int gid) {
  struct dqblk dq;

  if(quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), device.c_str(), gid, (char*)&dq))
{
    std::cout << "Got an error: " << std::strerror(errno) << std::endl;
  }

  std::cout << "Device: " << device << " Group: " << gid << " Space: " <<
    dq.dqb_curspace << std::endl;
}

int main() {
  printquota("/dev/<your_device>",<your gid>);
}

Looking at the source code for the kernel, we can also see in
include/linux/quota.h that it doesn't say it is in blocks:

  qsize_t dqb_curspace; /* current used space */

Weaving through the kernel code that actually increments the value, it can
be seen that it is represented in bytes (include/linux/quotaops.h):

static inline int dquot_alloc_block(struct inode *inode, qsize_t nr)
{
  return dquot_alloc_space(inode, nr << inode->i_blkbits);
}

Reply via email to