Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153424929
D56402.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D56402.diff
View Options
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
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd July 16, 2025
+.Dd April 15, 2026
.Dt DU 1
.Os
.Sh NAME
@@ -225,8 +225,8 @@
.Xr chflags 2 ,
.Xr fts 3 ,
.Xr libxo 3 ,
-.Xr xo_options 7 ,
.Xr symlink 7 ,
+.Xr xo_options 7 ,
.Xr quot 8
.Sh STANDARDS
The
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
@@ -35,7 +35,7 @@
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
-#include <err.h>
+
#include <errno.h>
#include <fnmatch.h>
#include <fts.h>
@@ -67,8 +67,8 @@
static bool check_threshold(FTSENT *);
static void ignoreadd(const char *);
static void ignoreclean(void);
-static int ignorep(FTSENT *);
-static int linkchk(FTSENT *);
+static bool ignorep(FTSENT *);
+static bool linkchk(FTSENT *);
static void print_file_size(FTSENT *);
static void prthumanval(const char *, int64_t);
static void record_file_size(FTSENT *);
@@ -91,6 +91,7 @@
{
FTS *fts;
FTSENT *p;
+ int64_t num;
off_t savednumber;
int ftsoptions;
int depth;
@@ -189,11 +190,12 @@
case 'r': /* Compatibility. */
break;
case 't':
- if (expand_number(optarg, &threshold) != 0 ||
- threshold == 0) {
+ if (expand_number(optarg, &num) != 0 || num == 0) {
xo_warnx("invalid threshold: %s", optarg);
usage();
- } else if (threshold < 0)
+ }
+ threshold = num;
+ if (threshold < 0)
threshold_sign = -1;
break;
case 'x':
@@ -239,7 +241,7 @@
if (sflag)
depth = 0;
- if (!*argv) {
+ if (argc == 0) {
argv = save;
argv[0] = dot;
argv[1] = NULL;
@@ -262,13 +264,12 @@
(void)signal(SIGINFO, siginfo);
if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL)
- err(1, "fts_open");
-
+ xo_err(1, "fts_open");
xo_set_version(DU_XO_VERSION);
xo_open_container("disk-usage-information");
xo_open_list("paths");
- while (errno = 0, (p = fts_read(fts)) != NULL) {
+ for (errno = 0; (p = fts_read(fts)) != NULL; errno = 0) {
switch (p->fts_info) {
case FTS_D: /* Ignore. */
if (ignorep(p))
@@ -313,7 +314,7 @@
}
xo_close_list("paths");
- if (errno)
+ if (errno != 0)
xo_err(1, "fts_read");
if (cflag) {
@@ -334,7 +335,7 @@
exit(rval);
}
-static int
+static bool
linkchk(FTSENT *p)
{
struct links_entry {
@@ -362,7 +363,7 @@
number_buckets = links_hash_initial_size;
buckets = malloc(number_buckets * sizeof(buckets[0]));
if (buckets == NULL)
- errx(1, "No memory for hardlink detection");
+ xo_errx(1, "No memory for hardlink detection");
for (i = 0; i < number_buckets; i++)
buckets[i] = NULL;
}
@@ -433,12 +434,12 @@
free_list = le;
}
}
- return (1);
+ return (true);
}
}
if (stop_allocating)
- return (0);
+ return (false);
/* Add this entry to the links cache. */
if (free_list != NULL) {
@@ -451,7 +452,7 @@
if (le == NULL) {
stop_allocating = 1;
xo_warnx("No more memory for tracking hard links");
- return (0);
+ return (false);
}
le->dev = st->st_dev;
le->ino = st->st_ino;
@@ -462,7 +463,7 @@
if (buckets[hash] != NULL)
buckets[hash]->previous = le;
buckets[hash] = le;
- return (0);
+ return (false);
}
static void
@@ -500,10 +501,10 @@
ign = calloc(1, sizeof(*ign));
if (ign == NULL)
- errx(1, "cannot allocate memory");
+ xo_errx(1, "cannot allocate memory");
ign->mask = strdup(mask);
if (ign->mask == NULL)
- errx(1, "cannot allocate memory");
+ xo_errx(1, "cannot allocate memory");
SLIST_INSERT_HEAD(&ignores, ign, next);
}
@@ -520,17 +521,18 @@
}
}
-static int
+static bool
ignorep(FTSENT *ent)
{
struct ignentry *ign;
if (nodumpflag && (ent->fts_statp->st_flags & UF_NODUMP))
- return (1);
- SLIST_FOREACH(ign, &ignores, next)
+ return (true);
+ SLIST_FOREACH(ign, &ignores, next) {
if (fnmatch(ign->mask, ent->fts_name, 0) != FNM_NOMATCH)
- return (1);
- return (0);
+ return (true);
+ }
+ return (false);
}
static void
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
@@ -295,6 +295,23 @@
sort du.out
}
+atf_test_case stdout
+stdout_head()
+{
+ atf_set "descr" "Failure to write to stdout"
+}
+stdout_body()
+{
+ (
+ trap "" PIPE
+ sleep 1
+ du 2>stderr
+ echo $? >result
+ ) | true
+ atf_check -o inline:"1\n" cat result
+ atf_check -o match:"stdout" cat stderr
+}
+
atf_init_test_cases()
{
atf_add_test_case A_flag
@@ -314,4 +331,5 @@
atf_add_test_case s_flag
atf_add_test_case si_flag
atf_add_test_case t_flag
+ atf_add_test_case stdout
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 22, 2:33 AM (14 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31947730
Default Alt Text
D56402.diff (4 KB)
Attached To
Mode
D56402: du: Complete libxo transition
Attached
Detach File
Event Timeline
Log In to Comment