diff --git a/usr.bin/du/du.1 b/usr.bin/du/du.1 --- a/usr.bin/du/du.1 +++ b/usr.bin/du/du.1 @@ -137,7 +137,7 @@ Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte based on powers of 1000. .It Fl t Ar threshold -Display only entries for which size exceeds +Exclude entries smaller than .Ar threshold . If .Ar threshold diff --git a/usr.bin/du/du.c b/usr.bin/du/du.c --- a/usr.bin/du/du.c +++ b/usr.bin/du/du.c @@ -320,7 +320,9 @@ howmany(p->fts_statp->st_size, cblocksize) : howmany(p->fts_statp->st_blocks, cblocksize); - if (aflag || p->fts_level == 0) { + if ((aflag || p->fts_level == 0) && threshold <= + threshold_sign * howmany(curblocks * cblocksize, + blocksize)) { if (hflag > 0) { prthumanval(curblocks); (void)printf("\t%s\n", p->fts_path); diff --git a/usr.bin/du/tests/du_test.sh b/usr.bin/du/tests/du_test.sh --- a/usr.bin/du/tests/du_test.sh +++ b/usr.bin/du/tests/du_test.sh @@ -176,6 +176,23 @@ atf_check -o inline:'1.5M\tA\n1.6M\tB\n' du -A --si A B } +atf_test_case a_t_flags +a_t_flags_head() +{ + atf_set "descr" "Verify the use of -a and -t together" +} + +a_t_flags_body() +{ + mkdir -p testdir/nested + cd testdir + atf_check truncate -s 2M nested/A + atf_check truncate -s 1M nested/B + + atf_check -o inline:'2.0M\tnested/A\n3.0M\tnested/\n' \ + du -aAht 1536K nested/ +} + atf_init_test_cases() { atf_add_test_case A_flag @@ -186,4 +203,5 @@ atf_add_test_case k_flag atf_add_test_case m_flag atf_add_test_case si_flag + atf_add_test_case a_t_flags }