Am 04.02.2013 um 22:23 schrieb Adrian Knoth:

Hi Adrian,

I've just noticed that upstream decided to divide by 1024 in newer
versions of src/fsio.c:

    /* In order to return a size in KB, as get_fs_size() does, we need
     * to divide by 1024.
    *fs_size = (((off_t) fs.f_bavail * (off_t) fs.f_frsize) / 1024);

So they're effectively hiding the bug.

Fixed bug by that change:

I suggest to at least put a comment before pr_fs_getsize2 that the
returned number is in KB, not in bytes.

Current code in 1.3.5b:

/* Note: The size provided by pr_fs_getsize2() is in KB, not bytes. */
static void format_size_str(char *buf, size_t buflen, off_t size) {
  char *units[] = {"K", "M", "G", "T", "P"};
  unsigned int nunits = 5;
  register unsigned int i = 0;
  int res;

  /* Determine the appropriate units label to use. */
  while (size > 1024 &&
         i < nunits) {

    size /= 1024;

and for int pr_fs_getsize2() from fsio.c.

/* Returns the size in KB via the `fs_size' argument. */
int pr_fs_getsize2(char *path, off_t *fs_size) {
  return fs_getsize(-1, path, fs_size);

Is that sufficient for you or should be forward that bug to upstream anyway?

--   #206401

Reply via email to