mirror of
git://git.suckless.org/sbase
synced 2024-12-25 00:12:42 +00:00
Always round up to the next blocksize unit in du(1)
This commit is contained in:
parent
6a680269bf
commit
0690c1a003
10
du.c
10
du.c
@ -96,6 +96,12 @@ pop(char *path)
|
||||
free(path);
|
||||
}
|
||||
|
||||
static long
|
||||
nblks(struct stat *st)
|
||||
{
|
||||
return (512 * st->st_blocks + blksize - 1) / blksize;
|
||||
}
|
||||
|
||||
static long
|
||||
du(const char *path)
|
||||
{
|
||||
@ -107,7 +113,7 @@ du(const char *path)
|
||||
|
||||
if (lstat(path, &st) < 0)
|
||||
eprintf("stat: %s:", path);
|
||||
n = 512 * st.st_blocks / blksize;
|
||||
n = nblks(&st);
|
||||
|
||||
if (!S_ISDIR(st.st_mode))
|
||||
goto done;
|
||||
@ -130,7 +136,7 @@ du(const char *path)
|
||||
n += du(dent->d_name);
|
||||
continue;
|
||||
}
|
||||
m = 512 * st.st_blocks / blksize;
|
||||
m = nblks(&st);
|
||||
n += m;
|
||||
if (aflag && !sflag) {
|
||||
if (S_ISLNK(st.st_mode))
|
||||
|
Loading…
Reference in New Issue
Block a user