Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!uokmax!munnari.oz.au!yoyo.aarnet.edu.au!sirius.ucs.adelaide.edu.au!cs.adelaide.edu.au!cagney From: cagney@cs.adelaide.edu.au Newsgroups: comp.os.minix Subject: Patch to 1.5.10 du - one out with the block count Message-ID: <2867@sirius.ucs.adelaide.edu.au> Date: 16 Apr 91 05:16:29 GMT Sender: news@ucs.adelaide.edu.au Reply-To: cagney@cs.adelaide.edu.au () Organization: Comp Sci, Uni of Adelaide, Australia Lines: 34 Nntp-Posting-Host: berlioz.cs.adelaide.edu.au Below is a patch to minix du. It seems to be getting the size of files out by one (unless that's what it should do :-). The problem is best seen if you use du on a file with exactly n*BLOCK_SIZE bytes in it. eg for a file with 0 bytes old equation gave (0 + BLOCK_SIZE) / BLOCK_SIZE = 1 block new equation gives (0 + BLOCK_SIZE - 1) / BLOCK_SIZE = 0 blocks Noid cagney@berlioz% diff -c du.c du.c.orig *** du.c Tue Apr 16 14:32:27 1991 --- du.c.orig Tue Apr 16 14:32:04 1991 *************** *** 193,199 **** switch (s.st_mode & S_IFMT) { case S_IFREG: case S_IFDIR: ! total += (s.st_size + BLOCK_SIZE - 1) / BLOCK_SIZE; break; } if (all && (s.st_mode & S_IFMT) != S_IFDIR) --- 193,199 ---- switch (s.st_mode & S_IFMT) { case S_IFREG: case S_IFDIR: ! total += (s.st_size + BLOCK_SIZE) / BLOCK_SIZE; break; } if (all && (s.st_mode & S_IFMT) != S_IFDIR)