GNU file utilities
[gnulib.git] / lib / fsusage.c
index 2a1fe86..9307a40 100644 (file)
@@ -58,7 +58,7 @@ int statvfs ();
 #endif
 
 /* Return the number of TOSIZE-byte blocks used by
-   BLOCKS FROMSIZE-byte blocks, rounding up.  */
+   BLOCKS FROMSIZE-byte blocks, rounding away from zero.  */
 
 static long
 adjust_blocks (blocks, fromsize, tosize)
@@ -70,7 +70,7 @@ adjust_blocks (blocks, fromsize, tosize)
   else if (fromsize > tosize)  /* E.g., from 2048 to 512.  */
     return blocks * (fromsize / tosize);
   else                         /* E.g., from 256 to 512.  */
-    return (blocks + 1) / (tosize / fromsize);
+    return (blocks + (blocks < 0 ? -1 : +1)) / (tosize / fromsize);
 }
 
 /* Fill in the fields of FSP with information about space usage for
@@ -156,9 +156,11 @@ get_fs_usage (path, disk, fsp)
      no matter what value f_bsize has.  */
 #define convert_blocks(b) (b)
 #ifndef _SEQUENT_              /* _SEQUENT_ is DYNIX/ptx.  */
+#ifndef DOLPHIN                        /* DOLPHIN 3.8.alfa/7.18 has f_bavail */
 #define f_bavail f_bfree
 #endif
 #endif
+#endif
 
 #ifdef STAT_STATVFS            /* SVR4.  */
   struct statvfs fsd;