aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/ls.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 7fb6b2cf7..31abbc9b5 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -584,6 +584,16 @@ static void showfiles(struct dnode **dn, unsigned nfiles)
584 584
585 585
586#if ENABLE_DESKTOP 586#if ENABLE_DESKTOP
587/* http://www.opengroup.org/onlinepubs/9699919799/utilities/ls.html
588 * If any of the -l, -n, -s options is specified, each list
589 * of files within the directory shall be preceded by a
590 * status line indicating the number of file system blocks
591 * occupied by files in the directory in 512-byte units if
592 * the -k option is not specified, or 1024-byte units if the
593 * -k option is specified, rounded up to the next integral
594 * number of units.
595 */
596/* by Jorgen Overgaard (jorgen AT antistaten.se) */
587static off_t calculate_blocks(struct dnode **dn, int nfiles) 597static off_t calculate_blocks(struct dnode **dn, int nfiles)
588{ 598{
589 uoff_t blocks = 1; 599 uoff_t blocks = 1;
@@ -593,7 +603,7 @@ static off_t calculate_blocks(struct dnode **dn, int nfiles)
593 nfiles--; 603 nfiles--;
594 } 604 }
595 605
596 /* Even though POSIX says use 512 byte blocks, coreutils use 1k */ 606 /* Even though standard says use 512 byte blocks, coreutils use 1k */
597 /* Actually, we round up by calculating (blocks + 1) / 2, 607 /* Actually, we round up by calculating (blocks + 1) / 2,
598 * "+ 1" was done when we initialized blocks to 1 */ 608 * "+ 1" was done when we initialized blocks to 1 */
599 return blocks >> 1; 609 return blocks >> 1;